body {
    font-family: "Be Vietnam Pro", Arial, sans-serif;
    background-color: #f0f4f8;
    transition: all 0.3s ease;
}

.quiz-card {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border: 1px solid transparent;
}

.btn-primary { background-color: #2563eb; color: white; }
.btn-primary:hover { background-color: #1d4ed8; }
.btn-secondary { background-color: #e2e8f0; color: #1e293b; }
.btn-secondary:hover { background-color: #cbd5e1; }

.app-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 1rem;
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 10px 15px;
    border-radius: 0 0 12px 12px;
    background-color: rgba(240, 244, 248, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    margin-left: -1rem;
    margin-right: -1rem;
}

.theme-toggle-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.3s;
}

.legacy-body { font-family: "Be Vietnam Pro", Arial, sans-serif; background-color: #d7e6f7; }
.legacy-body #app { padding: 0 10px; }

.subject-item-legacy {
    border: 1px solid #ccc;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    background-color: #f7f7f7;
    margin-bottom: 10px;
    transition: all 0.3s;
    width: 100%;
    max-width: 400px;
    border-radius: 8px;
}

.subject-item-legacy:hover { background-color: #e7e7e7; transform: translateY(-2px); }
.subject-item-legacy h3 { font-size: 18px; font-weight: bold; color: #333; margin: 0; }
.subject-item-legacy p { font-size: 14px; color: #666; margin: 5px 0 0 0; }

.gateway-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    align-items: stretch;
}

.gateway-card {
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
}

.gateway-card .gateway-icon {
    font-size: 28px;
    color: #2563eb;
}

.helper-text {
    font-size: 13px;
    color: #475569;
    line-height: 1.5;
}

.inline-error {
    display: none;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #991b1b;
    border-radius: 6px;
    font-size: 14px;
}

.inline-error.active { display: block; }

.legacy-quiz-layout {
    max-width: 770px;
    width: 100%;
    margin: 0 auto;
    padding: 10px;
    background-color: #d7e6f7;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.legacy-quiz-layout .question-content-container { border: none; padding: 0; }
.legacy-quiz-layout .question-list-container {
    border-top: 1px solid #000;
    padding-top: 15px;
}
#question-header.legacy-question-header { color: #990000; font-size: 14px; font-weight: normal; margin-bottom: 0px; }

#question-text.legacy-question-text {
    font-size: 16px;
    font-weight: normal;
    margin-bottom: 5px;
    background-color: transparent;
    border: 1px solid #000;
    padding: 10px;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legacy-answer-container label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 5px 0;
    font-size: 15px;
    border: 1px solid #000;
    padding: 8px 10px;
    cursor: pointer;
}

.legacy-answer-container input { margin-top: 3px; }

.legacy-option-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.legacy-media-frame {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.72);
    padding: 8px;
}

.legacy-media-frame img {
    width: 100%;
    max-width: 320px;
    max-height: 240px;
    object-fit: contain;
    border-radius: 4px;
    display: block;
}

#question-list.legacy-question-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    width: 100%;
    align-content: flex-start;
}

.legacy-question-nav-item {
    border: 1px solid #999;
    width: 28px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    color: #000;
}

.legacy-question-nav-item.current { background-color: #ccc; font-weight: bold; border-width: 2px; }
.legacy-question-nav-item.skipped { background-color: #FFCC00; border-color: #e6b800; }
.legacy-question-nav-item.answered.correct { background-color: #006600; border-color: #004d00; color: white; }
.legacy-question-nav-item.answered.wrong { background-color: #990000; border-color: #800000; color: white; }

.legacy-btn-container { display: flex; justify-content: space-between; align-items: center; padding-top: 20px; }

.legacy-btn,
.legacy-btn-primary,
.admin-edit-btn,
.admin-add-btn {
    padding: 5px 15px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid #adadad;
    font-size: 14px;
}

.legacy-btn,
.admin-edit-btn { background-color: #f0f0f0; color: #333; }

.legacy-btn-primary,
.admin-add-btn { background-color: #2563eb; color: white; border-color: #1e4ed8; }

.legacy-login-input {
    width: 100%;
    padding: 8px 10px;
    font-size: 16px;
    border: 1px solid #999;
    margin-bottom: 15px;
}

.legacy-login-btn {
    padding: 10px 20px;
    font-size: 16px;
    background-color: #2563eb;
    color: white;
    border: 1px solid #1e4ed8;
    cursor: pointer;
    width: 100%;
}

.admin-panel {
    background-color: #fff;
    border: 1px solid #999;
    margin-top: 30px;
    width: 100%;
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
}

.admin-panel-header {
    background-color: #f0f0f0;
    font-weight: bold;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.admin-panel-header-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.admin-panel-body { padding: 20px; overflow-x: auto; }
.admin-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }

.admin-toolbar-btn {
    padding: 6px 14px;
    border: 1px solid #94a3b8;
    background: #e2e8f0;
    color: #0f172a;
    border-radius: 999px;
    cursor: pointer;
    font-size: 14px;
}

.admin-toolbar-btn.active { background: #2563eb; color: white; border-color: #1d4ed8; }

.admin-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.admin-summary-card {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 12px;
    background: #f8fafc;
}

.admin-summary-card strong { display: block; font-size: 20px; margin-top: 4px; }

.admin-filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
    align-items: end;
}

.admin-form-field { display: flex; flex-direction: column; gap: 6px; }
.admin-form-field label, .admin-form-field span { font-size: 14px; font-weight: bold; }

.admin-form-field input[type="text"],
.admin-form-field input[type="email"],
.admin-form-field input[type="password"],
.admin-form-field input[type="number"],
.admin-form-field textarea,
.admin-form-field select {
    width: 100%;
    border: 1px solid #94a3b8;
    border-radius: 6px;
    padding: 8px 10px;
    background: white;
    color: #0f172a;
}

.admin-form-field textarea { min-height: 96px; resize: vertical; }
.admin-inline-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { border: 1px solid #ccc; padding: 8px 12px; text-align: left; font-size: 14px; vertical-align: top; }
.admin-table th { background-color: #f7f7f7; font-weight: bold; }
.admin-table tr:nth-child(even) { background-color: #fcfcfc; }
.admin-table tr:hover { background-color: #f1f1f1; }
.admin-delete-btn { background-color: #dc2626; color: white; padding: 4px 8px; border-radius: 4px; border: none; font-size: 12px; cursor: pointer; }
.admin-delete-btn:hover { background-color: #b91c1c; }

.admin-form-modal {
    width: min(900px, 100%);
    max-height: 86vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.admin-form-scroll { padding: 18px 20px 20px; overflow-y: auto; }

.admin-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}

.admin-answer-row {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    background: #f8fafc;
}

.admin-answer-row textarea { min-height: 70px; }

.empty-state-panel {
    border: 1px dashed #94a3b8;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    color: #475569;
    background: #f8fafc;
}

body.dark-mode {
    background-color: #020617;
    background-image:
        radial-gradient(circle at 0% 30%, rgba(29, 78, 216, 0.5) 0%, transparent 50%),
        radial-gradient(circle at 100% 30%, rgba(30, 58, 138, 0.5) 0%, transparent 50%),
        radial-gradient(circle at 50% 55%, rgba(14, 165, 233, 0.25) 0%, transparent 50%),
        radial-gradient(circle at 50% -20%, #172554 0%, transparent 70%),
        radial-gradient(circle at 50% 100%, #0f172a 0%, transparent 60%);
    background-attachment: fixed;
    color: #e2e8f0;
}

body.dark-mode .app-header {
    background-color: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

body.dark-mode .quiz-card,
body.dark-mode .admin-panel,
body.dark-mode .subject-item-legacy,
body.dark-mode table,
body.dark-mode .admin-answer-row,
body.dark-mode .admin-summary-card,
body.dark-mode .empty-state-panel,
body.dark-mode .legacy-media-frame {
    background-color: rgba(15, 23, 42, 0.6) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #e2e8f0 !important;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

body.dark-mode .legacy-body,
body.dark-mode .legacy-quiz-layout {
    background-color: rgba(15, 23, 42, 0.2) !important;
    box-shadow: 0 0 60px -15px rgba(56, 189, 248, 0.15) !important;
    backdrop-filter: blur(2px);
}

body.dark-mode .subject-item-legacy:hover {
    background-color: rgba(56, 189, 248, 0.15) !important;
    border-color: rgba(56, 189, 248, 0.5) !important;
    transform: translateY(-3px);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
}

body.dark-mode .subject-item-legacy h3,
body.dark-mode .gateway-card .gateway-icon { color: #38bdf8 !important; text-shadow: 0 0 5px rgba(56, 189, 248, 0.3); }
body.dark-mode .subject-item-legacy p,
body.dark-mode .helper-text { color: #94a3b8 !important; }
body.dark-mode h1, body.dark-mode h2, body.dark-mode h3 { color: #f1f5f9 !important; }
body.dark-mode p, body.dark-mode label, body.dark-mode span { color: #cbd5e1; }

body.dark-mode input[type="text"],
body.dark-mode input[type="email"],
body.dark-mode input[type="password"],
body.dark-mode input[type="number"],
body.dark-mode textarea,
body.dark-mode select {
    background-color: rgba(30, 41, 59, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

body.dark-mode input:focus,
body.dark-mode textarea:focus,
body.dark-mode select:focus {
    border-color: #38bdf8 !important;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
    outline: none;
}

body.dark-mode #question-header.legacy-question-header { color: #fbbf24 !important; }
body.dark-mode #question-text.legacy-question-text {
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: #f1f5f9 !important;
    background-color: rgba(0, 0, 0, 0.2) !important;
}

body.dark-mode .legacy-answer-container label {
    border-color: rgba(255, 255, 255, 0.2) !important;
    background-color: rgba(255, 255, 255, 0.03) !important;
}

body.dark-mode .legacy-answer-container label:hover {
    background-color: rgba(56, 189, 248, 0.1) !important;
    border-color: rgba(56, 189, 248, 0.4) !important;
}

body.dark-mode .legacy-btn,
body.dark-mode .legacy-login-btn,
body.dark-mode .btn-secondary,
body.dark-mode .admin-edit-btn {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #e2e8f0 !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

body.dark-mode .legacy-btn:hover,
body.dark-mode .btn-secondary:hover,
body.dark-mode .admin-edit-btn:hover {
    background-color: rgba(255, 255, 255, 0.2) !important;
}

body.dark-mode .legacy-btn-primary,
body.dark-mode .btn-primary,
body.dark-mode .admin-add-btn,
body.dark-mode .admin-toolbar-btn.active {
    background-color: rgba(56, 189, 248, 0.2) !important;
    color: #38bdf8 !important;
    border: 1px solid rgba(56, 189, 248, 0.5) !important;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

body.dark-mode .legacy-btn-primary:hover,
body.dark-mode .admin-add-btn:hover {
    background-color: rgba(56, 189, 248, 0.3) !important;
}

body.dark-mode .admin-panel-header { background-color: rgba(255, 255, 255, 0.05) !important; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
body.dark-mode .admin-table th { background-color: rgba(56, 189, 248, 0.1) !important; color: #38bdf8 !important; border-color: rgba(255,255,255,0.1) !important; }
body.dark-mode .admin-table td { border-color: rgba(255,255,255,0.1) !important; color: #e2e8f0 !important; }
body.dark-mode .admin-table tr:nth-child(even) { background-color: rgba(255,255,255,0.02) !important; }
body.dark-mode .admin-table tr:hover { background-color: rgba(56, 189, 248, 0.1) !important; }
body.dark-mode .admin-toolbar-btn { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.16); color: #cbd5e1; }
body.dark-mode .legacy-question-nav-item { border-color: rgba(255,255,255,0.2) !important; color: #e2e8f0 !important; }
body.dark-mode .legacy-question-nav-item.current { background-color: rgba(255,255,255,0.2) !important; color: #fff !important; border-color: white !important; }
body.dark-mode .legacy-question-nav-item.answered.correct.current { background-color: #006600 !important; border-color: #004d00 !important; color: #fff !important; }
body.dark-mode .legacy-question-nav-item.answered.wrong.current { background-color: #990000 !important; border-color: #800000 !important; color: #fff !important; }
body.dark-mode .legacy-question-list-container { border-top-color: rgba(255,255,255,0.2) !important; }
body.dark-mode .theme-toggle-btn {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fbbf24;
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.4);
}

body.dark-mode footer { background-color: rgba(15, 23, 42, 0.6) !important; border-top-color: rgba(255, 255, 255, 0.1) !important; }
body.dark-mode footer p, body.dark-mode footer span { color: #94a3b8 !important; }
body.dark-mode footer .bg-white { background-color: rgba(255, 255, 255, 0.05) !important; border-color: rgba(255, 255, 255, 0.1) !important; }

.live-dot { animation: pulse-green 2s infinite; }

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

@media (max-width: 640px) {
    .admin-panel-header { align-items: flex-start; }
    .admin-panel-header-buttons { width: 100%; }
    .legacy-btn-container { flex-direction: column; align-items: stretch; gap: 10px; }
    .legacy-btn-container > div { width: 100%; display: flex; gap: 10px; }
    .legacy-btn-container button { flex: 1; }
    .legacy-quiz-layout {
        padding: 8px 0;
        gap: 14px;
    }
    #button-container {
        flex-direction: column;
        align-items: stretch !important;
    }
    #button-container > div {
        width: 100%;
        display: flex;
        gap: 10px;
    }
    #button-container button {
        width: 100%;
    }
}
