/* ========================================
   PROFESSIONAL ADMIN PANEL CSS
   ======================================== */

/* ---------- Root Variables ---------- */
:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #818CF8;
    --secondary: #64748B;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;
    --dark: #1E293B;
    --gray-50: #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E1;
    --gray-400: #94A3B8;
    --gray-500: #64748B;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1E293B;
    --gray-900: #0F172A;
    --sidebar-width: 260px;
    --header-height: 70px;
    --border-radius: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Reset & Base ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* ---------- Layout ---------- */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: var(--dark);
    color: white;
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    background: rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    min-height: var(--header-height);
}

.sidebar-brand .brand-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.sidebar-brand .brand-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    white-space: nowrap;
}

.sidebar-brand .brand-text small {
    display: block;
    font-size: 11px;
    font-weight: 400;
    opacity: 0.7;
    letter-spacing: 0;
}

.sidebar-nav {
    padding: 16px 12px;
}

.sidebar-nav .nav-section {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 12px 8px;
    opacity: 0.4;
    font-weight: 600;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin: 2px 0;
    border-radius: 8px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
}

.sidebar-nav .nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

.sidebar-nav .nav-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.sidebar-nav .nav-item .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-nav .nav-item .nav-label {
    font-size: 14px;
    font-weight: 500;
}

.sidebar-nav .nav-item .nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

/* ---------- Main Content ---------- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

/* ---------- Header ---------- */
.top-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 32px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(10px);
    background: rgba(255,255,255,0.95);
}

.top-header .header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-header .header-left .menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-600);
    padding: 4px;
}

.top-header .header-left .page-title h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-800);
}

.top-header .header-left .page-title .breadcrumb {
    font-size: 13px;
    color: var(--gray-500);
}

.top-header .header-left .page-title .breadcrumb span {
    color: var(--gray-700);
}

.top-header .header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-header .header-right .search-box {
    position: relative;
}

.top-header .header-right .search-box input {
    padding: 8px 16px 8px 38px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
    width: 220px;
    transition: var(--transition);
    background: var(--gray-50);
}

.top-header .header-right .search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    width: 280px;
}

.top-header .header-right .search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

.top-header .header-right .header-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    color: var(--gray-600);
    font-size: 18px;
}

.top-header .header-right .header-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    transform: translateY(-1px);
}

.top-header .header-right .header-btn .notification-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid white;
}

.top-header .header-right .user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.top-header .header-right .user-menu:hover {
    background: var(--gray-50);
    border-color: var(--gray-200);
}

.top-header .header-right .user-menu .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.top-header .header-right .user-menu .user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.top-header .header-right .user-menu .user-info .user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
}

.top-header .header-right .user-menu .user-info .user-role {
    font-size: 12px;
    color: var(--gray-500);
}

/* ---------- Page Content ---------- */
.page-content {
    padding: 32px;
}

/* ---------- Stats Cards ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-200);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 12px;
}

.stat-card .stat-icon.blue {
    background: #EFF6FF;
    color: #3B82F6;
}
.stat-card .stat-icon.green {
    background: #ECFDF5;
    color: #10B981;
}
.stat-card .stat-icon.yellow {
    background: #FFFBEB;
    color: #F59E0B;
}
.stat-card .stat-icon.purple {
    background: #F5F3FF;
    color: #8B5CF6;
}
.stat-card .stat-icon.red {
    background: #FEF2F2;
    color: #EF4444;
}
.stat-card .stat-icon.indigo {
    background: #EEF2FF;
    color: #4F46E5;
}

.stat-card .stat-label {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-card .stat-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    margin-top: 8px;
    padding: 2px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.stat-card .stat-change.up {
    color: var(--success);
    background: #ECFDF5;
}

.stat-card .stat-change.down {
    color: var(--danger);
    background: #FEF2F2;
}

/* ---------- Tables ---------- */
.table-container {
    background: white;
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    margin-top: 20px;
}

.table-container .table-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.table-container .table-header .table-title {
    font-size: 16px;
    font-weight: 600;
}

.table-container .table-header .table-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead {
    background: var(--gray-50);
}

table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    border-bottom: 1px solid var(--gray-200);
}

table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
}

table tbody tr {
    transition: var(--transition);
}

table tbody tr:hover {
    background: var(--gray-50);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    color: white;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover {
    background: #059669;
}

.btn-warning {
    background: var(--warning);
    color: white;
}
.btn-warning:hover {
    background: #D97706;
}

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover {
    background: #DC2626;
}

.btn-secondary {
    background: var(--gray-500);
    color: white;
}
.btn-secondary:hover {
    background: var(--gray-600);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}
.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-primary {
    background: #EFF6FF;
    color: #3B82F6;
}
.badge-success {
    background: #ECFDF5;
    color: #10B981;
}
.badge-warning {
    background: #FFFBEB;
    color: #F59E0B;
}
.badge-danger {
    background: #FEF2F2;
    color: #EF4444;
}
.badge-info {
    background: #EEF2FF;
    color: #4F46E5;
}

/* ---------- Modals ---------- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-header .close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-400);
    transition: var(--transition);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-header .close-btn:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ---------- Form Elements ---------- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 4px;
}

.form-group .form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
    transition: var(--transition);
    background: white;
}

.form-group .form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group .form-control.error {
    border-color: var(--danger);
}

.form-group .form-control.success {
    border-color: var(--success);
}

.form-group .form-help {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ---------- Toast Notifications ---------- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 16px 20px;
    border-radius: var(--border-radius);
    color: white;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
    min-width: 300px;
    max-width: 450px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast-success {
    background: var(--success);
}
.toast-error {
    background: var(--danger);
}
.toast-warning {
    background: var(--warning);
}
.toast-info {
    background: var(--info);
}

.toast .toast-icon {
    font-size: 20px;
}

.toast .toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ---------- Loading Spinner ---------- */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .top-header .header-left .menu-toggle {
        display: block;
    }
    
    .top-header .header-right .search-box input {
        width: 160px;
    }
    
    .top-header .header-right .search-box input:focus {
        width: 200px;
    }
}

@media (max-width: 768px) {
    .page-content {
        padding: 16px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .top-header {
        padding: 0 16px;
    }
    
    .top-header .header-right .search-box {
        display: none;
    }
    
    .top-header .header-right .user-menu .user-info {
        display: none;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .top-header .header-left .page-title h1 {
        font-size: 16px;
    }
    
    .table-container .table-header {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ---------- Mobile Overlay ---------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}