/* =====================================================
   MLK College Formation - CSS Base + Theme System
   ===================================================== */

:root {
    --primary:        #1e40af;
    --primary-light:  #3b82f6;
    --primary-dark:   #1e3a8a;
    --secondary:      #f59e0b;
    --secondary-dark: #d97706;
    --bg-color:       #f8fafc;
    --text-color:     #1f2937;
    --sidebar-width:  260px;
    --topbar-height:  60px;
    --card-radius:    12px;
    --transition:     .2s ease;
}

/* =====================================================
   RESET & BASE
   ===================================================== */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* =====================================================
   THEME COLORS
   ===================================================== */
.bg-primary       { background-color: var(--primary) !important; }
.btn-primary      { background-color: var(--primary); border-color: var(--primary); }
.btn-primary:hover{ background-color: var(--primary-dark); border-color: var(--primary-dark); }
.text-primary     { color: var(--primary) !important; }
.border-primary   { border-color: var(--primary) !important; }

.btn-secondary    { background-color: var(--secondary); border-color: var(--secondary); color: #000; }
.btn-secondary:hover{ background-color: var(--secondary-dark); border-color: var(--secondary-dark); }

/* =====================================================
   CARDS
   ===================================================== */
.card {
    border: 1px solid #e5e7eb;
    border-radius: var(--card-radius);
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    background: #fff;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 1rem 1.25rem;
    border-radius: var(--card-radius) var(--card-radius) 0 0;
}

/* Stat Cards */
.stat-card {
    background: #fff;
    border-radius: var(--card-radius);
    padding: 1.25rem;
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1); }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #fff;
    flex-shrink: 0;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-color);
}

.stat-label {
    font-size: .8rem;
    color: #6b7280;
    margin-top: .2rem;
}

/* =====================================================
   SIDEBAR LAYOUT (Admin)
   ===================================================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: #0f172a;
    color: #cbd5e1;
    z-index: 1000;
    overflow-y: auto;
    transition: width var(--transition);
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed { width: 70px; }
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-section,
.sidebar.collapsed .nav-link span { display: none; }
.sidebar.collapsed .sidebar-logo { max-width: 40px; }

.sidebar-brand {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid #1e293b;
}

.sidebar-brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    display: block;
    white-space: nowrap;
}

.sidebar-logo { max-height: 40px; max-width: 180px; object-fit: contain; }

.sidebar-section {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #64748b;
    padding: 1rem 1rem .3rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .6rem 1rem;
    color: #94a3b8;
    border-radius: 8px;
    margin: .1rem .5rem;
    font-size: .9rem;
    transition: background var(--transition), color var(--transition);
}

.sidebar-nav .nav-link:hover {
    background: #1e293b;
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--primary);
    color: #fff;
}

.sidebar-nav .nav-link i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
}

/* =====================================================
   MAIN CONTENT (Admin)
   ===================================================== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition);
    background: var(--bg-color);
}

.main-content.expanded { margin-left: 70px; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.topbar-title {
    font-weight: 600;
    font-size: 1.1rem;
    flex: 1;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.sidebar-toggle { padding: .25rem; color: #374151; }

.content-area { padding: 1.5rem; }

/* =====================================================
   STUDENT NAVBAR
   ===================================================== */
.student-navbar {
    background: #fff;
    border-bottom: 2px solid var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    padding: .5rem 0;
}

.student-navbar .brand-text {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--primary);
}

.student-navbar .nav-link {
    color: #374151;
    font-weight: 500;
    padding: .4rem .75rem;
    border-radius: 8px;
    transition: background var(--transition);
}

.student-navbar .nav-link:hover,
.student-navbar .nav-link.active {
    background: rgba(30, 64, 175, .08);
    color: var(--primary);
}

.student-main { min-height: calc(100vh - 130px); background: var(--bg-color); }

.student-footer {
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 1rem 0;
    margin-top: 2rem;
}

/* =====================================================
   TABLES
   ===================================================== */
.table th {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #6b7280;
    background: #f9fafb;
}

.table td { vertical-align: middle; }

.table-hover tbody tr:hover { background-color: #f8fafc; }

/* =====================================================
   FORMS
   ===================================================== */
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 .2rem rgba(30, 64, 175, .15);
}

.form-label { font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }

/* =====================================================
   BADGES & STATUS
   ===================================================== */
.badge { font-size: .72rem; font-weight: 600; border-radius: 6px; padding: .3em .6em; }

/* =====================================================
   BUTTONS
   ===================================================== */
.btn { font-weight: 500; border-radius: 8px; }
.btn-sm { border-radius: 6px; font-size: .8rem; }

/* =====================================================
   COURSE CARDS
   ===================================================== */
.course-card {
    border: 1px solid #e5e7eb;
    border-radius: var(--card-radius);
    background: #fff;
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
}

.course-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
}

.course-card-thumbnail {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.course-card-thumb-placeholder {
    width: 100%;
    height: 180px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: rgba(255,255,255,.5);
}

.course-card-body { padding: 1.25rem; }

/* =====================================================
   VIDEO PLAYER (Protected)
   ===================================================== */
.player-container {
    position: relative;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 16/9;
}

.player-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Overlay to prevent right-click interactions */
.player-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.player-watermark {
    position: absolute;
    bottom: 10px;
    right: 10px;
    color: rgba(255,255,255,.25);
    font-size: .75rem;
    pointer-events: none;
    z-index: 2;
    user-select: none;
}

/* =====================================================
   PROGRESS
   ===================================================== */
.progress { border-radius: 100px; background: #e5e7eb; }
.progress-bar {
    background: var(--primary);
    border-radius: 100px;
    transition: width .6s ease;
}

/* =====================================================
   MODULE/LESSON SIDEBAR
   ===================================================== */
.lesson-sidebar {
    border: 1px solid #e5e7eb;
    border-radius: var(--card-radius);
    background: #fff;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    position: sticky;
    top: 80px;
}

.module-item { border-bottom: 1px solid #f3f4f6; }

.module-header {
    padding: .75rem 1rem;
    background: #f8fafc;
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.lesson-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1rem .6rem 2rem;
    font-size: .87rem;
    border-bottom: 1px solid #f9fafb;
    transition: background var(--transition);
    cursor: pointer;
}

.lesson-item:hover { background: #f8fafc; }
.lesson-item.active { background: rgba(30, 64, 175, .06); color: var(--primary); }
.lesson-item.completed .lesson-icon { color: #10b981; }
.lesson-item.locked { color: #9ca3af; cursor: not-allowed; }

.lesson-icon { font-size: 1rem; flex-shrink: 0; }

/* =====================================================
   ALERTS
   ===================================================== */
.alert { border-radius: 10px; border: none; }
.alert-success  { background: #d1fae5; color: #065f46; }
.alert-danger   { background: #fee2e2; color: #991b1b; }
.alert-warning  { background: #fef3c7; color: #92400e; }
.alert-info     { background: #dbeafe; color: #1e40af; }

/* =====================================================
   EXAM INTERFACE
   ===================================================== */
.question-card {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    background: #fff;
}

.question-number {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    text-align: center;
    line-height: 28px;
    font-size: .8rem;
    font-weight: 700;
    margin-bottom: .5rem;
}

.answer-option {
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: .6rem 1rem;
    margin-bottom: .4rem;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: .65rem;
}

.answer-option:hover { border-color: var(--primary); background: rgba(30,64,175,.04); }
.answer-option.selected { border-color: var(--primary); background: rgba(30,64,175,.08); }

/* Exam timer */
.exam-timer {
    position: fixed;
    top: 80px;
    right: 1.5rem;
    background: var(--primary);
    color: #fff;
    padding: .5rem 1rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.1rem;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
}

.exam-timer.danger { background: #dc2626; animation: pulse 1s infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .7; } }

/* =====================================================
   BREADCRUMB
   ===================================================== */
.breadcrumb { background: none; padding: 0; margin-bottom: 1.25rem; }
.breadcrumb-item + .breadcrumb-item::before { content: "›"; color: #9ca3af; }
.breadcrumb-item.active { color: #6b7280; }

/* =====================================================
   DRAG & DROP SORTABLE
   ===================================================== */
.sortable-ghost { opacity: .4; }
.drag-handle { cursor: grab; color: #9ca3af; }
.drag-handle:active { cursor: grabbing; }

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    :root { --sidebar-width: 250px; }
    .stat-value { font-size: 1.3rem; }
    .exam-timer { top: auto; bottom: 1rem; right: 1rem; }
}

@media (max-width: 576px) {
    .content-area { padding: 1rem; }
    .stat-card { flex-direction: column; text-align: center; }
    .stat-icon { width: 44px; height: 44px; font-size: 1.2rem; }
}

/* =====================================================
   DRAG REORDER
   ===================================================== */
.list-group-item.sortable-chosen { background: #f0f7ff; border-color: var(--primary); }

/* =====================================================
   UTILITIES
   ===================================================== */
.cursor-pointer { cursor: pointer; }
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.rounded-xl { border-radius: 12px !important; }
.shadow-sm-hover:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1) !important; }
