/* ============================================
   Dashboard Bootstrap - Main Stylesheet
   ============================================ */

/* CSS Variables */
:root {
    --primary-color: #6c63ff;
    --secondary-color: #4a44b5;
    --success-color: #2ecc71;
    --info-color: #3498db;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --light-color: #f8f9fc;
    --dark-color: #2c3e50;
    --gradient-primary: linear-gradient(135deg, #6c63ff 0%, #4a44b5 100%);
    --gradient-success: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    --gradient-warning: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    --gradient-danger: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    --sidebar-width: 260px;
    --transition-speed: 0.3s;
    --bs-navbar-active-color: #ebebeb;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    background-color: #f5f7fb;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #4a5568;
    margin: 0;
    padding: 0;
}

#wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.container-fluid {
    width: 100%;
    max-width: 100%;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
    pointer-events: none;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
    pointer-events: all;
}

/* Sidebar Styles */
#sidebar {
    min-height: 100vh;
    width: var(--sidebar-width);
    background: var(--gradient-primary);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transition: transform var(--transition-speed) ease;
    box-shadow: 0 0 35px 0 rgba(49, 57, 66, 0.1);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    padding: 1.5rem 1rem;
    display: flex;
    align-items: center;
    color: white;
    font-weight: 700;
    font-size: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand i {
    font-size: 1.5rem;
    margin-right: 0.75rem;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-item {
    position: relative;
    margin-bottom: 0.25rem;
}

.nav-link {
    color: rgba(255, 255, 255, 0.8);
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.nav-link:hover, .nav-link.active {
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border-left-color: white;
}

.nav-link i {
    font-size: 1.1rem;
    margin-right: 0.75rem;
    width: 20px;
    text-align: center;
}

/* Main Content */
#content {
    margin-left: var(--sidebar-width);
    transition: all var(--transition-speed) ease;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
}

/* Topbar */
.topbar {
    background: white;
    box-shadow: 0 1px 15px rgba(0, 0, 0, 0.04);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
}

.topbar > div {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    max-width: 400px;
    width: 100%;
    flex: 1;
}

.search-box input {
    padding-left: 2.5rem;
    border-radius: 50px;
    border: 1px solid #e2e8f0;
    background-color: #f8fafc;
    transition: all 0.3s;
}

.search-box input:focus {
    background-color: white;
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
    border-color: var(--primary-color);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #a0aec0;
}

.user-profile img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e2e8f0;
    transition: all 0.3s;
}

.user-profile img:hover {
    border-color: var(--primary-color);
}

/* Cards */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    transition: all 0.3s ease;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}

.card-header {
    background: white;
    border-bottom: 1px solid #edf2f7;
    padding: 1.25rem 1.5rem;
    font-weight: 600;
}

/* Stat Cards */
.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
}

.stat-card.primary::before {
    background: var(--gradient-primary);
}

.stat-card.success::before {
    background: var(--gradient-success);
}

.stat-card.warning::before {
    background: var(--gradient-warning);
}

.stat-card.danger::before {
    background: var(--gradient-danger);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: white;
}

.stat-icon.primary {
    background: var(--gradient-primary);
}

.stat-icon.success {
    background: var(--gradient-success);
}

.stat-icon.warning {
    background: var(--gradient-warning);
}

.stat-icon.danger {
    background: var(--gradient-danger);
}

/* Charts */
.chart-container {
    position: relative;
    height: 300px;
    min-height: 300px;
    /* Reserve space immediately to prevent layout shifts during chart rendering */
    visibility: visible;
}

/* Progress Bars */
.progress {
    height: 8px;
    border-radius: 10px;
    background-color: #edf2f7;
}

.progress-bar {
    border-radius: 10px;
}

/* Tables */
.table th {
    border-top: none;
    font-weight: 600;
    color: #4a5568;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background-color: #f8fafc;
}

.table td {
    vertical-align: middle;
    padding: 1rem 0.75rem;
}

.table-hover tbody tr:hover {
    background-color: rgba(108, 99, 255, 0.04);
}

.badge {
    font-weight: 500;
    border-radius: 6px;
}

/* Toggle Button */
#sidebarToggle {
    background: transparent;
    border: none;
    color: #4a5568;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.3s;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

#sidebarToggle:hover {
    color: var(--primary-color);
    background: rgba(108, 99, 255, 0.1);
    border-radius: 6px;
}

#sidebarToggle:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Analytics Specific Styles */
.metric-card {
    text-align: center;
    padding: 1.5rem;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.metric-label {
    color: #718096;
    font-size: 0.9rem;
}

.metric-change {
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.change-positive {
    color: var(--success-color);
}

.change-negative {
    color: var(--danger-color);
}

.chart-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chart-filter-btn {
    border: 1px solid #e2e8f0;
    background: white;
    padding: 0.4rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.chart-filter-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Data Tables Custom Styling */
.dataTables_wrapper {
    padding: 0;
}

.dataTables_filter {
    margin-bottom: 1rem;
}

.dataTables_filter label {
    display: flex;
    align-items: center;
}

.dataTables_filter input {
    margin-left: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}

.dataTables_length label {
    display: flex;
    align-items: center;
}

.dataTables_length select {
    margin: 0 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.25rem 2rem 0.25rem 0.5rem;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 16px 12px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
}

.data-table-card {
    overflow: hidden;
}

/* Reserve space for DataTable to prevent scrollbar appearing/disappearing */
#dataTable {
    min-height: 400px;
}

/* Reserve space for tables to prevent scrollbar appearing/disappearing */
.table-responsive {
    min-height: 400px;
}

/* Reserve space for table containers on users page */
.card-body .table-responsive {
    min-height: 500px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 0.75rem;
}

.user-avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.user-avatar-lg {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Action Buttons */
.action-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 6px;
    margin: 0 2px;
    padding: 0;
    transition: all 0.2s;
    cursor: pointer;
}

.action-btn.view {
    color: #3498db;
}

.action-btn.edit {
    color: #2ecc71;
}

.action-btn.delete {
    color: #e74c3c;
}

.action-btn:hover {
    transform: translateY(-2px);
    opacity: 0.8;
}

.action-btn:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.action-btn i {
    font-size: 1.1rem;
}

/* Status Badges */
.status-badge {
    padding: 0.4rem 0.75rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-active {
    background: rgba(46, 204, 113, 0.1);
    color: #27ae60;
}

.status-inactive {
    background: rgba(189, 195, 199, 0.1);
    color: #7f8c8d;
}

.status-pending {
    background: rgba(241, 196, 15, 0.1);
    color: #f39c12;
}

.status-blocked {
    background: rgba(231, 76, 60, 0.1);
    color: #c0392b;
}

/* Role Badges */
.role-badge {
    padding: 0.4rem 0.75rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 500;
}

.role-admin {
    background: rgba(108, 99, 255, 0.1);
    color: var(--primary-color);
}

.role-editor {
    background: rgba(46, 204, 113, 0.1);
    color: #27ae60;
}

.role-author {
    background: rgba(52, 152, 219, 0.1);
    color: #2980b9;
}

.role-user {
    background: rgba(149, 165, 166, 0.1);
    color: #7f8c8d;
}

/* Earnings Specific Styles */
.earning-badge {
    padding: 0.4rem 0.75rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-completed {
    background: rgba(46, 204, 113, 0.1);
    color: #27ae60;
}

.badge-pending {
    background: rgba(241, 196, 15, 0.1);
    color: #f39c12;
}

.badge-failed {
    background: rgba(231, 76, 60, 0.1);
    color: #c0392b;
}

.subscription-card {
    text-align: center;
    padding: 1.5rem;
}

.subscription-icon {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1rem;
    color: white;
}

.subscription-icon.basic {
    background: var(--gradient-primary);
}

.subscription-icon.pro {
    background: var(--gradient-success);
}

.subscription-icon.enterprise {
    background: var(--gradient-warning);
}

.price {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 1rem 0;
}

.price-period {
    font-size: 1rem;
    color: #718096;
}

.subscription-features {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0;
}

.subscription-features li {
    padding: 0.5rem 0;
    color: #4a5568;
}

.subscription-features li i {
    margin-right: 0.5rem;
    color: var(--success-color);
}

/* Settings Specific Styles */
.settings-nav {
    position: sticky;
    top: 100px;
}

.settings-nav .nav-link {
    color: #4a5568;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

.settings-nav .nav-link:hover, .settings-nav .nav-link.active {
    background: rgba(108, 99, 255, 0.1);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.settings-nav .nav-link i {
    width: 20px;
    text-align: center;
    margin-right: 0.75rem;
}

.setting-section {
    margin-bottom: 2rem;
}

.setting-section:last-child {
    margin-bottom: 0;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid #edf2f7;
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-info {
    flex: 1;
}

.setting-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.setting-description {
    color: #718096;
    font-size: 0.9rem;
}

.setting-control {
    margin-left: 1rem;
}

.form-switch .form-check-input {
    width: 3rem;
    height: 1.5rem;
}

.form-switch .form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.avatar-upload {
    position: relative;
    display: inline-block;
}

.avatar-upload-btn {
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    cursor: pointer;
}

/* User Specific Styles */
.user-card {
    text-align: center;
    padding: 2rem 1.5rem;
}

.user-stats {
    display: flex;
    justify-content: space-around;
    margin: 1.5rem 0;
}

.user-stat {
    text-align: center;
}

.user-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.user-stat-label {
    font-size: 0.85rem;
    color: #718096;
}

.activity-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #edf2f7;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    color: white;
}

.activity-icon.login {
    background: var(--gradient-success);
}

.activity-icon.profile {
    background: var(--gradient-primary);
}

.activity-icon.purchase {
    background: var(--gradient-warning);
}

.activity-icon.settings {
    background: var(--gradient-primary);
}

/* Custom Form Styling */
.form-control, .form-select {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.form-select {
    padding-right: 2.5rem;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.form-select-sm {
    padding-right: 2rem;
    padding-left: 0.5rem;
    background-position: right 0.5rem center;
    font-size: 0.875rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
}

.form-label {
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 0.5rem;
}

/* Danger Zone */
.danger-zone {
    border: 1px solid #fed7d7;
    background: #fff5f5;
    border-radius: 12px;
    padding: 1.5rem;
}

.danger-zone .btn-danger {
    background: #e53e3e;
    border-color: #e53e3e;
}

/* Pagination Styling */
.dataTables_paginate .paginate_button {
    border: 1px solid #e2e8f0 !important;
    border-radius: 6px !important;
    margin: 0 2px !important;
    padding: 0.5rem 0.75rem !important;
}

.dataTables_paginate .paginate_button.current {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
}

.dataTables_paginate .paginate_button:hover {
    background: #f8fafc !important;
    border-color: #cbd5e0 !important;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(108, 99, 255, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(108, 99, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(108, 99, 255, 0); }
}

/* Mobile: Hide sidebar by default */
@media (max-width: 992px) {
    .sidebar-overlay {
        display: block;
        opacity: 0;
        pointer-events: none;
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: all;
    }
    
    /* Sidebar hidden by default on mobile */
    #sidebar {
        transform: translateX(-100%);
        visibility: visible;
    }
    
    /* Show sidebar when active */
    #sidebar.active {
        transform: translateX(0);
    }
    
    #content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    /* Ensure hamburger button is visible and clickable on mobile */
    #sidebarToggle {
        display: flex !important;
        z-index: 1001;
        position: relative;
        cursor: pointer;
    }
    
    /* Make sure sidebar is above overlay when active */
    #sidebar.active {
        z-index: 1000;
    }
}

/* Desktop: Sidebar visible by default, can be toggled */
@media (min-width: 993px) {
    /* Sidebar visible by default on desktop */
    #sidebar {
        transform: translateX(0);
    }
    
    /* Hide sidebar when not active (user clicked hamburger to hide) */
    #sidebar:not(.active) {
        transform: translateX(-100%);
    }
    
    /* Show sidebar when active */
    #sidebar.active {
        transform: translateX(0);
    }
    
    /* Content adjusts based on sidebar state */
    #content.sidebar-open {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }
    
    #content:not(.sidebar-open) {
        margin-left: 0;
        width: 100%;
    }
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .topbar {
        padding: 0.75rem 1rem;
    }
    
    .search-box {
        max-width: 100%;
        margin: 0 0.5rem;
    }
    
    .table-controls {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .settings-nav {
        position: static;
        margin-bottom: 2rem;
    }
    
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
        width: 100%;
        max-width: 100%;
    }
    
    .card {
        margin-bottom: 1rem;
    }
    
    .chart-container {
        height: 250px;
    }
}

@media (max-width: 768px) {
    .topbar {
        padding: 0.5rem 0.75rem;
    }
    
    .search-box {
        display: none;
    }
    
    .search-box.mobile-visible {
        display: block;
        width: 100%;
        margin: 0.5rem 0;
    }
    
    .user-profile span {
        display: none !important;
    }
    
    .metric-value {
        font-size: 1.5rem;
    }
    
    .chart-container {
        height: 200px;
    }
    
    .sidebar-brand {
        padding: 1rem 0.75rem;
        font-size: 1.1rem;
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .card-header {
        padding: 1rem;
    }
}

@media (max-width: 576px) {
    .topbar {
        flex-wrap: wrap;
    }
    
    .topbar > div {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .chart-container {
        height: 180px;
    }
    
    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .metric-value {
        font-size: 1.25rem;
    }
    
    .card-body {
        padding: 1rem;
    }
}

