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

:root {
    --primary: #00C96B;
    --primary-hover: #00A858;
    --primary-light: rgba(0, 201, 107, 0.1);
    --bg-dark: #0F1117;
    --bg-card: #1A1D27;
    --bg-input: #252833;
    --text-primary: #F1F1F3;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    --border: #2D3142;
    --success: #10B981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --error: #EF4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --warning: #F59E0B;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* === Screens === */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* === Login Screen === */
#login-screen {
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    background-image: 
        radial-gradient(ellipse at 20% 50%, rgba(108, 99, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(108, 99, 255, 0.05) 0%, transparent 40%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.logo-area {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    margin-bottom: 1rem;
    display: inline-block;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.app-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* === Form === */
.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.input-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.error-msg {
    display: block;
    font-size: 0.75rem;
    color: var(--error);
    margin-top: 0.375rem;
}

.hidden {
    display: none !important;
}

/* === Buttons === */
.btn-primary {
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

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

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-input);
    border-color: var(--text-muted);
}

.btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-ghost {
    padding: 0.5rem 0.75rem;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}

/* === Header === */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-title {
    font-size: 1rem;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-email {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* === Content Area === */
.content-area {
    flex: 1;
    padding: 2rem;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.section-desc {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.9375rem;
}

/* === Quiz Grid === */
.quiz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.quiz-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.quiz-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(108, 99, 255, 0.15);
}

.quiz-card-icon {
    width: 44px;
    height: 44px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.quiz-card-title {
    font-size: 1.0625rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.quiz-card-desc {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.quiz-card-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* === Quiz Content === */
.quiz-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.progress-bar-container {
    width: 100%;
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.question-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.question-text {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.5;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.option-btn {
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

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

.option-btn.correct {
    border-color: var(--success);
    background: var(--success-bg);
}

.option-btn.wrong {
    border-color: var(--error);
    background: var(--error-bg);
}

.option-letter {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.option-btn.selected .option-letter {
    background: var(--primary);
    color: white;
}

/* === Quiz Actions === */
.quiz-actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.quiz-actions .btn-primary {
    width: auto;
}

/* === Results === */
.results-content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
}

.results-card {
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.results-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 0 auto 1.5rem;
}

.results-icon.pass {
    background: var(--success-bg);
}

.results-icon.fail {
    background: var(--error-bg);
}

.results-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.results-score {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.results-message {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.9375rem;
}

/* === Certificate === */
.certificate-section {
    margin-bottom: 2rem;
}

.certificate {
    background: linear-gradient(135deg, #1E2130, #252840);
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.certificate::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(108, 99, 255, 0.05) 0%, transparent 60%);
    pointer-events: none;
}

.certificate-header h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

.certificate-body p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.cert-name {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin: 0.5rem 0;
}

.cert-quiz-name {
    font-size: 1rem;
    color: var(--primary);
    margin: 0.5rem 0 1rem;
}

.cert-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* === Quiz Intro === */
.intro-card {
    max-width: 700px;
    margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
}

.intro-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.intro-content {
    font-size: 0.9375rem;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.intro-content p {
    margin-bottom: 1rem;
}

.intro-content strong {
    color: var(--text-primary);
}

.intro-content ul {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
}

.intro-content ul li {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
}

.intro-content em {
    color: var(--text-muted);
    font-style: italic;
}

.intro-confirm {
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
}

.intro-question {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.intro-actions {
    display: flex;
    gap: 1rem;
}

.intro-actions .btn-primary {
    width: auto;
}

/* === Timer === */
.timer-display {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-variant-numeric: tabular-nums;
}

/* === Results Time === */
.results-time {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* === Admin Panel === */
.admin-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.select-input {
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

.select-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.admin-table thead {
    background: var(--bg-input);
}

.admin-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.admin-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.admin-table tbody tr:hover {
    background: var(--bg-input);
}

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

.rank-cell {
    font-weight: 700;
    color: var(--primary);
}

.score-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.score-badge.passed {
    background: var(--success-bg);
    color: var(--success);
}

.score-badge.failed {
    background: var(--error-bg);
    color: var(--error);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem !important;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    width: auto;
}

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

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

/* === Responsive === */
@media (max-width: 640px) {
    .content-area {
        padding: 1.5rem 1rem;
    }

    .app-header {
        padding: 0.75rem 1rem;
    }

    .login-container {
        margin: 1rem;
        padding: 1.5rem;
    }

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

    .quiz-actions {
        flex-direction: column;
    }

    .quiz-actions .btn-primary,
    .quiz-actions .btn-secondary {
        width: 100%;
    }
}
