@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* =============================================
   DESIGN TOKENS
   ============================================= */
:root {
    --primary:        #4F46E5;
    --primary-hover:  #4338CA;
    --primary-light:  #EEF2FF;
    --secondary:      #10B981;
    --secondary-hover:#059669;
    --secondary-light:#ECFDF5;
    --danger:         #EF4444;
    --danger-hover:   #DC2626;
    --danger-light:   #FEF2F2;
    --warning:        #F59E0B;
    --warning-light:  #FFFBEB;

    --dark:   #111827;
    --text:   #374151;
    --muted:  #6B7280;
    --border: #E5E7EB;
    --bg:     #F9FAFB;
    --white:  #FFFFFF;

    --sidebar-width: 240px;
    --header-height: 64px;

    --radius-sm: 6px;
    --radius:    8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow:    0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}

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

html { font-size: 16px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

.modal-overlay, .modal-content, .option-btn, .btn,
.form-control, input, select, textarea {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    user-select: text !important;
    pointer-events: auto !important;
}

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

.hidden { display: none !important; }

/* =============================================
   BUTTONS
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s, box-shadow 0.15s, transform 0.1s;
    background-color: var(--primary);
    color: var(--white);
    white-space: nowrap;
    line-height: 1.4;
}
.btn:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}
.btn:active { transform: translateY(1px); }

.btn-secondary { background-color: var(--white); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background-color: var(--bg); box-shadow: var(--shadow); }

.btn-success { background-color: var(--secondary); }
.btn-success:hover { background-color: var(--secondary-hover); }

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

.btn-small { padding: 0.375rem 0.875rem; font-size: 0.8125rem; }

.btn-icon {
    padding: 0.5rem;
    min-width: 2rem;
    justify-content: center;
}

/* =============================================
   FORM CONTROLS
   ============================================= */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-bottom: 1rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    line-height: 1.5;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.form-control::placeholder { color: #9CA3AF; }

textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

.form-row {
    display: flex;
    gap: 1rem;
}
.form-row .form-group { flex: 1; }

/* =============================================
   CARDS
   ============================================= */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

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

.card-header h2 {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--dark);
}

.card h2 {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 1.25rem;
}

/* =============================================
   TABLES
   ============================================= */
.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead tr {
    background-color: var(--bg);
}

th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background-color: #FAFAFA; }

/* =============================================
   BADGES / STATUS
   ============================================= */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}
.badge-success { background: var(--secondary-light); color: #065F46; }
.badge-danger  { background: var(--danger-light);    color: #991B1B; }
.badge-warning { background: var(--warning-light);   color: #92400E; }
.badge-primary { background: var(--primary-light);   color: #3730A3; }

/* =============================================
   LANDING PAGE
   ============================================= */
.landing-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 50%, #3B82F6 100%);
    padding: 1rem;
}

.landing-card {
    background: var(--white);
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 460px;
    color: var(--text);
}

.landing-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.landing-brand .brand-icon {
    width: 56px;
    height: 56px;
    background: var(--primary-light);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.75rem;
}

.landing-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.25rem;
}

.landing-brand p {
    font-size: 0.9rem;
    color: var(--muted);
}

.login-form-card { width: 100%; }

.login-form-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 1.5rem;
    text-align: center;
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 1.5rem 0;
}

.login-error {
    display: none;
    padding: 0.75rem 1rem;
    background: var(--danger-light);
    color: #991B1B;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-top: 0.75rem;
}

.back-link {
    display: block;
    text-align: center;
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--muted);
}
.back-link:hover { color: var(--primary); }

/* Landing index specific */
.landing-container {
    background: var(--white);
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 520px;
    text-align: center;
}

.landing-container h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.landing-container > p {
    color: var(--muted);
    margin-bottom: 2rem;
}

.landing-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.landing-links .btn {
    width: 100%;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
}

.landing-links .link-muted {
    font-size: 0.875rem;
    color: var(--muted);
    cursor: pointer;
    background: none;
    border: none;
    text-decoration: underline;
    margin-top: 0.25rem;
}
.landing-links .link-muted:hover { color: var(--primary); }

/* =============================================
   ADMIN / SUPERADMIN APP LAYOUT
   ============================================= */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--dark);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .brand-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--white);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-brand .brand-sub {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.4);
    margin-top: 0.2rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.3);
    padding: 0.75rem 0.75rem 0.25rem;
    margin-top: 0.5rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255,255,255,0.65);
    background: transparent;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s;
}

.nav-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--white);
    text-decoration: none;
}

.nav-btn.active {
    background: var(--primary);
    color: var(--white);
}

.nav-btn .nav-icon { font-size: 1rem; opacity: 0.8; min-width: 1.25rem; text-align: center; }

.sidebar-footer {
    padding: 1rem 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* Main content area */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--dark);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--muted);
    background: var(--bg);
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--border);
}

.page-content {
    padding: 1.75rem;
    flex: 1;
}

/* Inline form inside card header */
.inline-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.inline-form .form-control { margin-bottom: 0; }

/* =============================================
   STUDENT PLAYER
   ============================================= */
.student-body {
    background: #0A0A0A;
    color: var(--white);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.player-header {
    height: var(--header-height);
    padding: 0 1.5rem;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.player-header-info h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60vw;
}

.player-header-info p {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.45);
    margin-top: 0.1rem;
}

.player-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 1rem;
}

.video-wrapper {
    position: relative;
    width: 100%;
    max-width: 960px;
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0,0,0,0.7);
    border: 1px solid rgba(255,255,255,0.06);
}

video { width: 100%; display: block; }

.player-custom-logo {
    position: absolute;
    top: 16px;
    right: 16px;
    max-width: 120px;
    max-height: 64px;
    z-index: 40;
    pointer-events: none;
    opacity: 0.85;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

/* =============================================
   QUESTION MODAL
   ============================================= */
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.88);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 1rem;
}

.modal-content {
    background: var(--white);
    color: var(--text);
    padding: 2rem;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 580px;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    margin-bottom: 1.5rem;
}

.modal-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.modal-content h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--dark);
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    margin-bottom: 1.25rem;
}

.option-btn {
    text-align: left;
    padding: 0.875rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    cursor: pointer;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--text);
    transition: all 0.15s;
    line-height: 1.5;
}

.option-btn:hover:not(:disabled) {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

.option-btn.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    font-weight: 500;
    color: var(--primary);
}

.option-btn.correct {
    border-color: var(--secondary);
    background: var(--secondary-light);
    color: #065F46;
    font-weight: 500;
}

.option-btn.wrong {
    border-color: var(--danger);
    background: var(--danger-light);
    color: #991B1B;
}

.option-btn:disabled { cursor: not-allowed; opacity: 0.7; }

.feedback-msg {
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.feedback-msg.success {
    background: var(--secondary-light);
    color: #065F46;
    border: 1px solid #A7F3D0;
}
.feedback-msg.error {
    background: var(--danger-light);
    color: #991B1B;
    border: 1px solid #FCA5A5;
}

/* =============================================
   EMBED PLAYER
   ============================================= */
html.embed-html, body.embed-body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background: #000;
    overflow: hidden;
}

.embed-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
}

/* =============================================
   QUESTION FORM PANEL (Admin)
   ============================================= */
.question-form-panel {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

/* =============================================
   CREDENTIALS BOX (Superadmin)
   ============================================= */
.credentials-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.credentials-box h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* =============================================
   EMPTY STATE
   ============================================= */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}
.empty-state p { font-size: 0.9rem; margin-top: 0.5rem; }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
    :root { --sidebar-width: 0px; }
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .form-row { flex-direction: column; }
    .inline-form { flex-direction: column; align-items: stretch; }
}
