:root {
    /* ACADEMIC THEME */
    --primary: #279b37; 
    --primary-dark: #279b37;
    --accent: #f59e0b;
    
    /* NEUTRALS */
    --slate-50: #f8fafc; --slate-100: #f1f5f9; --slate-200: #e2e8f0;
    --slate-500: #64748b; --slate-700: #334155; --slate-800: #1e293b; --slate-900: #0f172a;
    
    /* SYSTEM */
    --success: #10b981; --danger: #ef4444;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --border: var(--slate-200);
    --font-main: 'Inter', sans-serif;
    --font-heading: 'Merriweather', serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; outline: none; -webkit-tap-highlight-color: transparent; }
body { font-family: var(--font-main); background: var(--slate-50); color: var(--slate-800); }

body.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--slate-100);
}

a { text-decoration: none; color: inherit; }

/* --- GLOBAL ICON RESET (This was missing) --- */
svg { 
    width: 20px; 
    height: 20px; 
    fill: none; 
    stroke: currentColor; 
    stroke-width: 2; 
    stroke-linecap: round; 
    stroke-linejoin: round; 
    display: inline-block;
    vertical-align: middle;
}

/* --- UTILS --- */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; width: 100%; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; } .gap-4 { gap: 16px; }
.text-sm { font-size: 13px; } .text-muted { color: var(--slate-500); }
.font-bold { font-weight: 600; }

/* --- BUTTONS --- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 6px; font-weight: 500; font-size: 14px; cursor: pointer; border: 1px solid transparent; transition: 0.2s; white-space: nowrap; }
/* Force specific size for button icons */
.btn svg { width: 16px; height: 16px; } 
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: white; border-color: var(--slate-200); color: var(--slate-800); }
.btn-outline:hover { background: var(--slate-50); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* --- LAYOUT GRID --- */
.app-layout { display: flex; min-height: 100vh; position: relative; }

/* --- SIDEBAR --- */
.sidebar { 
    width: 260px; background: white; border-right: 1px solid var(--border); 
    display: flex; flex-direction: column; position: fixed; height: 100vh; z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6); z-index: 90;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.visible { opacity: 1; pointer-events: auto; }

.brand { 
    height: 64px; display: flex; align-items: center; padding: 0 24px; 
    border-bottom: 1px solid var(--border); font-family: var(--font-heading); 
    font-weight: 700; font-size: 18px; color: var(--primary-dark);
}
.brand span { color: var(--accent); margin-left: 2px; }
.brand svg { width: 24px; height: 24px; margin-right: 8px; color: var(--primary); }

.nav-menu { flex: 1; padding: 20px 12px; overflow-y: auto; }
.nav-item { 
    display: flex; align-items: center; gap: 12px; padding: 12px; 
    color: var(--slate-500); border-radius: 6px; margin-bottom: 4px; 
    font-size: 14px; font-weight: 500; transition: 0.2s; 
}
.nav-item:hover { background: var(--slate-50); color: var(--primary); }
.nav-item.active { background: var(--slate-100); color: var(--primary-dark); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; opacity: 0.8; }

/* --- MAIN CONTENT --- */
.main-content { flex: 1; margin-left: 260px; display: flex; flex-direction: column; width: 100%; }

/* --- HEADER --- */
.top-header { 
    height: 64px; background: white; border-bottom: 1px solid var(--border); 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 0 32px; position: sticky; top: 0; z-index: 40;
}
.page-title { font-family: var(--font-heading); font-size: 18px; font-weight: 700; color: var(--slate-800); }
.mobile-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; color: var(--slate-800); padding: 8px; }

.user-profile { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.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; 
}

/* --- COMPONENTS --- */
.card { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 24px; box-shadow: var(--shadow-sm); }

/* Progress Bar */
.progress-track { width: 100%; height: 8px; background: var(--slate-100); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; background: var(--success); width: 0%; transition: width 1s; }

/* Status Badges */
.badge { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* Tables */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; margin-top: 16px; min-width: 600px; }
.data-table th { text-align: left; padding: 12px; font-size: 12px; color: var(--slate-500); border-bottom: 1px solid var(--border); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.data-table td { padding: 16px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.data-table tr:last-child td { border-bottom: none; }

/* Grids */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; margin-bottom: 32px; }
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }

/* Course Cards */
.course-card { background: white; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; transition: transform 0.2s; }
.course-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.course-img { height: 140px; background: var(--slate-200); position: relative; }
.course-img img { width: 100%; height: 100%; object-fit: cover; }
.course-body { padding: 20px; }
.course-code { font-size: 11px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: 0.05em; }
.course-title { font-family: var(--font-heading); font-size: 16px; font-weight: 700; margin: 8px 0; }

/* --- CLASSROOM SPECIFIC --- */
.classroom-grid { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
.video-wrapper { position: relative; padding-bottom: 56.25%; height: 0; background: black; border-radius: 8px; overflow: hidden; margin-bottom: 20px; }
.video-wrapper iframe, .video-wrapper img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

.module-list { list-style: none; }
.module-item { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; overflow: hidden; }
.module-header { background: var(--slate-50); padding: 12px 16px; font-weight: 600; font-size: 13px; color: var(--slate-800); border-bottom: 1px solid var(--border); }
.lesson-item { 
    display: flex; align-items: center; gap: 10px; padding: 10px 16px; 
    font-size: 13px; color: var(--slate-600); cursor: pointer; transition: 0.2s; 
    border-bottom: 1px solid var(--slate-50); 
}
.lesson-item:last-child { border-bottom: none; }
.lesson-item:hover { background: var(--slate-50); color: var(--primary); }
.lesson-item.active { background: #eff6ff; color: var(--primary-dark); font-weight: 500; border-left: 3px solid var(--primary); }
.lesson-icon { width: 16px; height: 16px; opacity: 0.7; }

/* --- SETTINGS FORMS --- */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--slate-700); }
.form-control { 
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); 
    border-radius: 6px; font-size: 14px; font-family: inherit; transition: 0.2s; background: white;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1); }
.settings-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; overflow-x: auto; }
.settings-tab { padding: 10px 16px; font-size: 14px; color: var(--slate-500); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.settings-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }


/* --- MESSAGING SYSTEM --- */
.chat-container { display: grid; grid-template-columns: 300px 1fr; height: calc(100vh - 100px); background: white; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.chat-sidebar { border-right: 1px solid var(--border); overflow-y: auto; background: var(--slate-50); }
.chat-item { padding: 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: 0.2s; display: flex; align-items: center; gap: 12px; }
.chat-item:hover { background: white; }
.chat-item.active { background: white; border-left: 3px solid var(--primary); }
.chat-main { display: flex; flex-direction: column; background: white; }
.chat-header { padding: 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: white; }
.chat-messages { flex: 1; padding: 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; background: var(--slate-50); }
.message-bubble { max-width: 70%; padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.5; position: relative; }
.msg-in { align-self: flex-start; background: white; border: 1px solid var(--border); border-top-left-radius: 0; }
.msg-out { align-self: flex-end; background: var(--primary); color: white; border-top-right-radius: 0; }
.chat-input-area { padding: 16px; border-top: 1px solid var(--border); background: white; display: flex; gap: 10px; }


/* --- RESPONSIVE QUERIES --- */

/* Tablet & Smaller Laptops: Stack Classroom to avoid squishing */
@media (max-width: 1024px) {
    .classroom-grid { grid-template-columns: 1fr; }
}

/* Mobile Devices */
@media (max-width: 768px) {
    /* Layout */
    .sidebar { transform: translateX(-100%); box-shadow: 5px 0 25px rgba(0,0,0,0.1); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; width: 100%; }
    
    /* Critical: Enforce Padding */
    .container { padding: 16px 16px !important; width: 100%; box-sizing: border-box; }
    
    /* Header */
    .top-header { padding: 0 16px; gap: 12px; }
    .mobile-toggle { display: flex; }
    .page-title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .user-profile .hidden-mobile { display: none; }
    
    /* Grids */
    .stats-grid { grid-template-columns: 1fr; gap: 16px; }
    .course-grid { grid-template-columns: 1fr; gap: 16px; }
    
    /* Components */
    .card { padding: 16px; }
    .course-img { height: 120px; }
    
    /* Classroom */
    .content-area { width: 100%; }


    .chat-container { grid-template-columns: 1fr; height: auto; min-height: 500px; display: flex; flex-direction: column; }
    .chat-sidebar { height: 200px; } /* Stack on mobile */
    .chat-main { flex: 1; height: 400px; }
}