﻿/* ============================================================
   Shishywritti – Beautiful UI v2
   ============================================================ */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
    --bg:        #f0f4f8;
    --card:      #ffffff;
    --text:      #1a202c;
    --muted:     #718096;
    --border:    #e2e8f0;

    --primary:        #4f46e5;
    --primary-dark:   #3730a3;
    --primary-light:  #eef2ff;

    --success:        #059669;
    --success-light:  #ecfdf5;
    --danger:         #e53e3e;
    --danger-light:   #fff5f5;
    --warn:           #d97706;
    --warn-light:     #fffbeb;
    --info:           #0284c7;
    --info-light:     #f0f9ff;

    --header-from:    #312e81;
    --header-to:      #4f46e5;

    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  16px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.06);
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html { scroll-behavior: smooth; }

body {
    font-family: "Inter", "Segoe UI", Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────── */
.site-header {
    background: linear-gradient(135deg, var(--header-from) 0%, var(--header-to) 100%);
    box-shadow: 0 2px 12px rgba(49,46,129,0.4);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1000px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
}

.header-logo {
    height: 60px;
    width: auto;
    border-radius: 8px;
    background: rgba(255,255,255,0.12);
    padding: 4px;
    object-fit: contain;
    flex-shrink: 0;
}

.header-text {
    display: flex;
    flex-direction: column;
}

.header-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.header-subtitle {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.75);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.top-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.top-nav a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    transition: background 0.15s, color 0.15s;
}

.top-nav a:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.nav-logout {
    background: rgba(220,38,38,0.25) !important;
    color: #fca5a5 !important;
}

.nav-logout:hover {
    background: rgba(220,38,38,0.45) !important;
    color: #fff !important;
}

/* ── Page body ───────────────────────────────────────────── */
.page-body {
    max-width: 800px;
    margin: 32px auto;
    padding: 0 16px 40px;
    width: 100%;
    flex: 1;
}

/* ── Footer ─────────────────────────────────────────────── */
.site-footer {
    text-align: center;
    padding: 16px;
    color: var(--muted);
    font-size: 0.82rem;
    border-top: 1px solid var(--border);
    background: #fff;
}

/* ── Flash messages ─────────────────────────────────────── */
.flash-stack {
    margin-bottom: 20px;
}

.flash {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.93rem;
    border-left: 4px solid;
    box-shadow: var(--shadow-sm);
}

.flash.error {
    background: var(--danger-light);
    color: #9b1c1c;
    border-color: var(--danger);
}

.flash.success {
    background: var(--success-light);
    color: #065f46;
    border-color: var(--success);
}

.flash.info {
    background: var(--info-light);
    color: #0c4a6e;
    border-color: var(--info);
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-md);
}

.card + .card {
    margin-top: 20px;
}

.card-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.success-card {
    border-top: 4px solid var(--success);
}

/* ── Page title ──────────────────────────────────────────── */
.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--muted);
    margin-bottom: 24px;
    font-size: 0.93rem;
}

/* ── Forms ───────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

input,
select,
textarea {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: var(--radius-md);
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.1s, box-shadow 0.15s, opacity 0.15s;
    box-shadow: var(--shadow-sm);
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
    opacity: 0.92;
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
}

.btn.success {
    background: linear-gradient(135deg, #059669 0%, #065f46 100%);
    color: #fff;
}

.btn.danger {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    color: #fff;
}

.btn.secondary {
    background: #f1f5f9;
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: none;
}

.btn.secondary:hover {
    background: #e2e8f0;
}

.btn.outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    box-shadow: none;
}

.btn.outline:hover {
    background: var(--primary-light);
}

.btn.lg {
    padding: 13px 28px;
    font-size: 1rem;
    border-radius: var(--radius-lg);
}

.btn.full {
    width: 100%;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
    align-items: center;
}

/* ── Key-value pairs ─────────────────────────────────────── */
.kv {
    margin: 14px 0;
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 6px 12px;
}

.kv dt {
    font-weight: 600;
    color: var(--muted);
    font-size: 0.88rem;
    align-self: center;
}

.kv dd {
    color: var(--text);
    font-size: 0.95rem;
}

/* ── Pill badges ─────────────────────────────────────────── */
.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    background: var(--primary-light);
    color: var(--primary-dark);
    letter-spacing: 0.02em;
}

.pill.green  { background: var(--success-light); color: #065f46; }
.pill.red    { background: var(--danger-light);  color: #9b1c1c; }
.pill.yellow { background: var(--warn-light);    color: #92400e; }

/* ── Note / info box ─────────────────────────────────────── */
.note-box {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: #fffbeb;
    border: 1.5px solid #fde68a;
    color: #78350f;
    font-size: 0.9rem;
}

.note-box code {
    word-break: break-all;
    background: rgba(0,0,0,0.06);
    padding: 1px 4px;
    border-radius: 4px;
}

/* ── Helper links ────────────────────────────────────────── */
.helper-links {
    margin-top: 14px;
}

.helper-links a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.helper-links a:hover {
    text-decoration: underline;
}

/* ── Muted text ──────────────────────────────────────────── */
.muted {
    color: var(--muted);
}

/* ── Divider ─────────────────────────────────────────────── */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* ── Table ───────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    margin-top: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

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

th {
    background: linear-gradient(135deg, var(--header-from) 0%, var(--header-to) 100%);
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 10px;
    text-align: left;
    white-space: nowrap;
}

td {
    border-bottom: 1px solid var(--border);
    text-align: left;
    padding: 10px;
    vertical-align: middle;
}

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

tr:hover td {
    background: #f8fafc;
}

/* ── Exam UI ─────────────────────────────────────────────── */
.exam-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    border-radius: var(--radius-lg);
    color: #fff;
    box-shadow: var(--shadow-md);
}

.exam-title {
    font-weight: 800;
    font-size: 1.1rem;
}

.timer {
    font-size: 1.6rem;
    font-weight: 800;
    color: #fbbf24;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
    text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.timer.low {
    color: #ef4444;
    animation: pulse 1s infinite;
}

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

.question-nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 20px;
}

.question-btn {
    border: 2px solid var(--border);
    background: #fff;
    border-radius: var(--radius-md);
    padding: 8px 4px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.15s;
    color: var(--muted);
}

.question-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.question-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(79,70,229,0.35);
}

.question-btn.answered {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
    box-shadow: 0 4px 12px rgba(5,150,105,0.3);
}

.question-content {
    display: none;
}

.question-content.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

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

.question-image-wrap {
    margin: 16px 0;
    background: #f8fafc;
    border-radius: var(--radius-md);
    padding: 12px;
    border: 1px solid var(--border);
    text-align: center;
}

.question-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius-md);
    object-fit: contain;
}

.answer-input {
    min-height: 46px;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    letter-spacing: 0.05em;
}

.mobile-submit-bar {
    display: none;
}

.mobile-submit-btn {
    width: 100%;
}

/* ── Result page ─────────────────────────────────────────── */
.result-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 20px 0;
}

.result-box {
    border-radius: var(--radius-md);
    padding: 16px 12px;
    color: #fff;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.result-box.success { background: linear-gradient(135deg, #059669, #065f46); }
.result-box.danger  { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.result-box.info    { background: linear-gradient(135deg, #0284c7, #075985); }
.result-box.warn    { background: linear-gradient(135deg, #d97706, #92400e); }

/* ── Step banner (enrollment) ────────────────────────────── */
.step-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    color: #fff;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
}

.step-banner h2 {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.step-banner p {
    opacity: 0.85;
    font-size: 0.93rem;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 720px) {
    .header-inner {
        padding: 10px 14px;
        gap: 10px;
    }

    .header-logo {
        height: 48px;
    }

    .header-title {
        font-size: 1.2rem;
    }

    .question-nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .result-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mobile-submit-bar {
        display: block;
        position: sticky;
        bottom: 10px;
        padding: 8px 0;
    }

    .actions .btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    .kv {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px 12px;
    }

    .top-nav {
        width: 100%;
        justify-content: flex-start;
        gap: 2px;
    }

    .top-nav a {
        font-size: 0.8rem;
        padding: 5px 8px;
    }

    .page-body {
        margin-top: 20px;
        padding: 0 12px 32px;
    }

    .card {
        padding: 18px 16px;
    }

    .question-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .result-grid {
        grid-template-columns: 1fr 1fr;
    }

    th, td {
        padding: 8px 6px;
        font-size: 0.82rem;
    }
}
