/* ==========================================================================
   CSS Variables & Tokens
   ========================================================================== */
:root {
    /* Color Palette */
    --primary-color: #4f46e5;      /* Indigo 600 */
    --primary-hover: #4338ca;      /* Indigo 700 */
    --secondary-color: #0ea5e9;    /* Sky 500 */
    --bg-color: #f3f4f6;           /* Gray 100 */
    --surface-color: #ffffff;      /* White */
    --text-primary: #111827;       /* Gray 900 */
    --text-secondary: #6b7280;     /* Gray 500 */
    --border-color: #e5e7eb;       /* Gray 200 */
    
    /* Semantic Colors */
    --success: #10b981;            /* Emerald 500 */
    --danger: #ef4444;             /* Red 500 */
    --warning: #f59e0b;            /* Amber 500 */
    --info: #3b82f6;               /* Blue 500 */

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #4f46e5 0%, #0ea5e9 100%);
    
    /* Shadows & Effects */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    
    /* Typography */
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    
    /* Dimensions */
    --sidebar-width: 260px;
    --topbar-height: 70px;
    --border-radius: 12px;
    --border-radius-sm: 6px;
    --border-radius-lg: 16px;
    --transition: all 0.3s ease;
}

/* Dark Theme Variables (Optional extension) */
.dark-theme {
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(30, 41, 59, 0.5);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; }
img { max-width: 100%; height: auto; display: block; }

/* ==========================================================================
   Typography
   ========================================================================== */
h1, h2, h3, h4, h5, h6 { font-weight: 600; line-height: 1.2; }
h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
p { color: var(--text-secondary); }

/* ==========================================================================
   Login Page Styles
   ========================================================================== */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: url('https://images.unsplash.com/photo-1550439062-609e1531270e?ixlib=rb-4.0.3&auto=format&fit=crop&w=1920&q=80') center/cover no-repeat;
    position: relative;
}

.login-body::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
}

.login-header .logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 40px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header .logo-icon {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 15px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-header .logo-icon img.login-logo {
    width: 84px;
    height: 84px;
    object-fit: contain;
    margin-bottom: 10px;
}

.sidebar-header .logo-icon img.sidebar-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 6px;
}

.login-header h2 {
    color: #111827; /* Force dark text regardless of theme for login */
}

.login-header p {
    color: #4b5563;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    left: 14px;
    color: #9ca3af;
}

.input-wrapper input {
    width: 100%;
    padding: 12px 14px 12px 40px;
    border: 1px solid #d1d5db;
    border-radius: var(--border-radius);
    outline: none;
    transition: var(--transition);
    font-size: 0.95rem;
}

.input-wrapper input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.toggle-password {
    position: absolute;
    right: 14px;
    left: auto !important;
    cursor: pointer;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    font-size: 0.875rem;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #4b5563;
}

.forgot-pwd {
    color: var(--primary-color);
    font-weight: 500;
}

.forgot-pwd:hover {
    text-decoration: underline;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 1rem;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary.btn-sm {
    width: auto;
    padding: 8px 14px;
    font-size: 0.9rem;
    border-radius: var(--border-radius-sm);
}

.loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden { display: none !important; }

.error-message {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 15px;
    text-align: center;
    padding: 10px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--border-radius-sm);
}

/* ==========================================================================
   Dashboard Layout
   ========================================================================== */
.dashboard-body {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header .logo-icon {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-right: 12px;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    margin: 0;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
}

.sidebar-nav ul {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.nav-item i {
    width: 24px;
    font-size: 1.1rem;
    margin-right: 12px;
}

.nav-item:hover {
    background-color: rgba(79, 70, 229, 0.05);
    color: var(--primary-color);
}

.nav-item.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
}

.sidebar-footer {
    padding: 20px 16px;
    border-top: 1px solid var(--border-color);
}

.admin-profile {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    padding: 0 8px;
}

.admin-profile .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-right: 12px;
}

.admin-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.admin-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.logout-btn {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    font-weight: 500;
}

.logout-btn:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: var(--danger);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    height: var(--topbar-height);
    background-color: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    z-index: 90;
}

.search-bar {
    position: relative;
    width: 300px;
}

.search-bar i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-bar input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background-color: var(--bg-color);
    outline: none;
    transition: var(--transition);
}

.search-bar input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background-color: var(--surface-color);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: var(--transition);
}

.icon-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface-color);
}

.content-wrapper {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

.content-section {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.content-section.active {
    display: block;
}

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

.section-header {
    margin-bottom: 32px;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

/* ==========================================================================
   Components (Cards, Tables, Forms)
   ========================================================================== */
/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background-color: var(--surface-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-4px);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-right: 20px;
    color: white;
}

.bg-blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.bg-purple { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.bg-green { background: linear-gradient(135deg, #10b981, #059669); }
.bg-orange { background: linear-gradient(135deg, #f59e0b, #d97706); }

.stat-details h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 4px;
}

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

/* Cards */
.card {
    background-color: var(--surface-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 24px;
}

/* Tables */
.table-card {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: rgba(0,0,0,0.02);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background-color: rgba(79, 70, 229, 0.02);
}

.data-table td {
    font-size: 0.95rem;
    color: var(--text-primary);
    vertical-align: middle;
}

.action-btns {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-sm);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: var(--transition);
}

.btn-edit { background-color: var(--info); }
.btn-delete { background-color: var(--danger); }
.btn-icon:hover { opacity: 0.8; transform: scale(1.05); }

/* Status Badges */
.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-success { background-color: rgba(16, 185, 129, 0.1); color: var(--success); }
.status-pending { background-color: rgba(245, 158, 11, 0.1); color: var(--warning); }

/* Courses Grid */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.course-card {
    background-color: var(--surface-color);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.course-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-5px);
}

.course-thumb {
    height: 180px;
    background-color: #e5e7eb;
    position: relative;
    overflow: hidden;
}

.course-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.course-card:hover .course-thumb img {
    transform: scale(1.05);
}

.course-price-tag {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.875rem;
    backdrop-filter: blur(4px);
}

.course-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.course-content h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.course-content p {
    font-size: 0.9rem;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.course-actions {
    display: flex;
    gap: 10px;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

.course-actions button {
    flex: 1;
    padding: 8px;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    transition: var(--transition);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--bg-color);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
    animation: fadeInModal 0.3s ease;
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--surface-color);
    width: 100%;
    max-width: 500px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: var(--transition);
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-modal {
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.close-modal:hover {
    color: var(--danger);
}

.modal-body {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .col {
    flex: 1;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-family: var(--font-family);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
    background-color: var(--surface-color);
    color: var(--text-primary);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

textarea.form-control {
    resize: vertical;
}

.w-100 { width: 100%; }

/* Buttons General */
.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
    border-radius: var(--border-radius-sm);
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: var(--transition);
}

.btn-sm:hover {
    background: var(--border-color);
}

button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 250px;
    background: var(--surface-color);
    border-radius: var(--border-radius-sm);
    padding: 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 4px solid var(--primary-color);
    animation: slideInRight 0.3s ease forwards;
}

.toast.success { border-left-color: var(--success); }
.toast.success i { color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.error i { color: var(--danger); }

.toast-message {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateY(-10px); }
}

/* Responsive */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        height: 100%;
    }
    
    .sidebar.open {
        left: 0;
        box-shadow: var(--shadow-lg);
    }
    
    .content-wrapper {
        padding: 20px;
    }
    
    .flex-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        flex-direction: column;
    }
}
