/* Header */
.header-controls {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    z-index: 100;
}

.theme-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #2196F3;
    transition: .4s;
    border-radius: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    z-index: 2;
}

input:checked+.slider {
    background-color: #333;
}

input:checked+.slider:before {
    transform: translateX(26px);
}

body.light-mode .slider {
    background-color: #f1c40f;
}

.lang-button {
    padding: 10px 20px;
    font-size: 16px;
    border-radius: 20px;
    border: none;
    background: #2196F3;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.lang-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.lang-button:active::before {
    width: 200px;
    height: 200px;
}

body.light-mode .lang-button {
    background-color: #4f46e5;
}

.lang-button:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 15px rgba(33, 150, 243, 0.4);
}

.lang-button:active {
    transform: translateY(0) scale(0.95);
}

/* Countdown */
.countdown-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 1.5rem;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    box-shadow: var(--shadow-lg);
    border: var(--glass-border);
    margin-bottom: 2rem;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.countdown-container:hover {
    transform: translateY(-4px) scale(1.01);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

.countdown-numbers {
    display: flex;
    gap: 2rem;
    justify-content: center;
}

body.light-mode .countdown-container {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.countdown-numbers span {
    font-size: 3rem;
    font-weight: 700;
    font-family: "Space Grotesk", sans-serif;
    min-width: 70px;
    text-align: center;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.countdown-labels {
    display: flex;
    gap: 2rem;
    justify-content: center;
}

.countdown-labels span {
    font-size: 0.85rem;
    opacity: 0.7;
    min-width: 70px;
    text-align: center;
    font-family: "Poppins", sans-serif;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.exam-started {
    text-align: center;
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* Mobile Countdown Optimization */
@media (max-width: 768px) {
    .countdown-container {
        padding: 0.75rem;
        margin-bottom: 1.25rem;
        gap: 0.5rem;
        border-radius: 1rem;
    }

    .countdown-container:hover {
        transform: none;
        box-shadow: var(--shadow-lg);
    }

    .countdown-numbers {
        gap: 0.75rem;
    }

    .countdown-numbers span {
        font-size: 1.75rem;
        min-width: 45px;
        filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
    }

    .countdown-labels {
        gap: 0.75rem;
    }

    .countdown-labels span {
        font-size: 0.65rem;
        min-width: 45px;
        letter-spacing: 0.5px;
    }

    .exam-started {
        font-size: 1.25rem;
    }
}

/* Group Buttons */
.button-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    border: 1px solid var(--input-border);
    padding: 0.85rem 1.75rem;
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    letter-spacing: 0.5px;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-3px) scale(1.02);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    border-color: var(--primary-color);
}

.btn:active {
    transform: translateY(-1px) scale(0.98);
    transition: all 0.1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.5);
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

body.light-mode .btn {
    background: linear-gradient(135deg, #7c3aed, #8b5cf6);
    /* Violet Gradient */
    color: white;
    border: none;
    box-shadow: 0 4px 10px rgba(124, 58, 237, 0.3);
}

body.light-mode .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(124, 58, 237, 0.4);
}

body.light-mode .btn.active {
    background: linear-gradient(135deg, #5b21b6, #6d28d9);
    /* Deep Violet */
    color: #ffffff;
}

/* Form Container Slide Animation */
#examFormContainer {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Nice spring-like ease */
    margin-top: 0;
}

#examFormContainer.visible {
    grid-template-rows: 1fr;
    margin-top: 2rem;
    /* Only add margin when visible */
}

/* We need this inner wrapper directly inside #examFormContainer for grid transition to work */
.exam-form-wrapper {
    overflow: hidden;
    min-height: 0;
    /* Crucial for grid animation */
}

/* Form */
.form-container,
.results-container {
    background: rgba(30, 41, 59, 0.6);
    /* Darker glass for better text readability */
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: var(--glass-border);
    border-radius: 1.5rem;
    padding: 2.5rem;
    /* margin-top: 2rem; Removed, handled by #examFormContainer.visible */
    box-shadow: var(--shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04));
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.results-container {
    margin-top: 2rem;
}

/* Light Mode Container Fixes */
body.light-mode .form-container,
body.light-mode .results-container,
body.light-mode .countdown-container {
    background: #ffffff;
    border: 1px solid #e7e5e4;
    /* Soft Stone 200 border */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    /* Gentle soft shadow */
}

body.light-mode .input-field {
    background: #fafaf9;
    /* Stone 50 - Warm tint */
    border: 1px solid #e7e5e4;
    color: #57534e;
}

body.light-mode .btn {
    background: #4f46e5;
    /* Solid Indigo */
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

body.light-mode .btn:hover {
    background: #4338ca;
    /* Darker Indigo */
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(79, 70, 229, 0.3);
}

body.light-mode .btn.active {
    background: #312e81;
    /* Deep Indigo */
    color: #ffffff;
}

/* Remove any yellow from header buttons in light mode */
body.light-mode .slider {
    background-color: #e7e5e4;
    /* Stone gray inactive */
}

input:checked+.slider {
    background-color: #7c3aed;
    /* Violet active */
}

body.light-mode .lang-button {
    background-color: #7c3aed;
}

.subject {
    background-color: transparent;
    padding: 1.5rem;
    border-radius: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--input-border);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.subject:hover {
    background-color: var(--input-background);
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.subject h3 {
    margin-top: 0;
    font-size: 1.1rem;
    color: var(--primary-color);
    font-weight: 600;
}

.input-group label {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.9;
}

.input-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

@media (min-width: 640px) {
    .input-group {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Modern Stepper Input */
.stepper-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid var(--input-border);
    border-radius: 0.75rem;
    background-color: rgba(0, 0, 0, 0.2);
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stepper-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.25);
    transform: scale(1.02);
}

body.light-mode .stepper-wrapper {
    background-color: #ffffff;
    /* pure white inputs */
    border-color: rgba(0, 0, 0, 0.15);
    /* darker border */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    /* subtle lift */
}

.stepper-btn {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    color: var(--primary-color);
    border: none;
    width: 2.5rem;
    height: 2.5rem;
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-weight: bold;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

.stepper-btn::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(var(--primary-rgb), 0.3) 0%, transparent 70%);
    transform: scale(0);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: 50%;
}

.stepper-btn:hover {
    background: rgba(var(--primary-rgb), 0.15);
    transform: scale(1.1);
}

.stepper-btn:hover::after {
    transform: scale(1);
}

.stepper-btn:active {
    background: rgba(var(--primary-rgb), 0.25);
    transform: scale(0.9);
    transition: all 0.1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stepper-wrapper .input-field {
    width: 100%;
    border: none;
    margin: 0;
    text-align: center;
    background: transparent;
    color: var(--text-color);
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    padding: 0;
    height: 2.5rem;
    appearance: textfield;
    -moz-appearance: textfield;
}

/* Remove default arrows */
.stepper-wrapper .input-field::-webkit-outer-spin-button,
.stepper-wrapper .input-field::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.error-message {
    color: #ef4444;
    /* Keep red for errors, creates urgency */
    font-size: 0.75rem;
    min-height: 1.25rem;
    font-weight: 500;
    margin-top: 0.25rem;
    opacity: 0.9;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

th,
td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--input-border);
}

th {
    background-color: rgba(59, 130, 246, 0.2);
}

.total {
    font-weight: bold;
    color: var(--primary-color);
}

/* Results */
.result-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
}

.result-gif {
    max-width: 100%;
    max-height: 300px;
    height: auto;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: none;
    /* Hidden by default until show class added to parent if needed, holding logic */
}

.result-message.show .result-gif {
    display: block;
}

/* Footer */
#footerContainer {
    margin-top: auto;
    padding: 1rem;
    width: 100%;
    z-index: 50;
    /* Default position static relies on flex body to push to bottom */
}

.footer-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.85rem;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.footer-content:hover {
    opacity: 1;
}

.footer-text {
    color: var(--text-color);
}

.footer-text a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-text a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

.footer-separator {
    color: var(--text-color);
    opacity: 0.5;
}

.footer-link {
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.3s ease;
}

.footer-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Mobile Footer */
@media (max-width: 768px) {
    #footerContainer {
        position: static;
        bottom: auto;
        left: auto;
        padding: 2rem 1rem 1rem 1rem;
        text-align: center;
    }

    .footer-content {
        font-size: 0.75rem;
        gap: 0.5rem;
        justify-content: center;
        flex-wrap: wrap;
    }

    #docsBtn {
        order: -1;
        width: 100%;
        font-size: 1rem;
        font-weight: 600;
        margin-bottom: 0.25rem;
    }

    .footer-separator {
        display: none;
    }
}

/* --- PREMIUM CHANGELOG REDESIGN --- */
#changelogModal,
#docsModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#changelogModal.active,
#docsModal.active {
    visibility: visible;
    opacity: 1;
    pointer-events: all;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.premium-modal {
    background: rgba(15, 23, 42, 0.8) !important;
    /* Dark glass base */
    backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    width: 100%;
    max-width: 550px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 50px 100px -20px rgba(0, 0, 0, 0.5);
    transform: scale(0.9) translateY(20px);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.light-mode .premium-modal {
    background: rgba(255, 255, 255, 0.85) !important;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.1);
}

#changelogModal.active .premium-modal {
    transform: scale(1) translateY(0);
}

/* Hero Section */
.modal-hero {
    position: relative;
    padding: 2.5rem 2rem 2rem;
    overflow: hidden;
    flex-shrink: 0;
}

.hero-blobs {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.6;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(50px);
}

.blob-1 {
    top: -50px;
    left: -50px;
    width: 150px;
    height: 150px;
    background: var(--primary-color);
    animation: blobFloat 10s infinite alternate;
}

.blob-2 {
    bottom: -30px;
    right: -30px;
    width: 120px;
    height: 120px;
    background: var(--secondary-color);
    animation: blobFloat 8s infinite alternate-reverse;
}

@keyframes blobFloat {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(30px, 30px);
    }
}

.hero-text {
    position: relative;
    z-index: 2;
}

.hero-text h2 {
    margin: 0;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -1px;
    font-family: 'Cal Sans', sans-serif;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

body.light-mode .hero-text h2 {
    background: linear-gradient(135deg, var(--text-color) 0%, var(--primary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
}

.hero-text p {
    margin: 0.5rem 0 0;
    font-size: 0.95rem;
    opacity: 0.7;
    color: var(--text-color);
}

.modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    backdrop-filter: blur(5px);
}

body.light-mode .modal-close {
    background: rgba(0, 0, 0, 0.05);
}

.modal-close:hover {
    background: var(--primary-color);
    color: white;
    transform: rotate(90deg);
}

/* Feed & Cards */
.modal-body {
    padding: 1rem 2rem 2rem;
    overflow-y: auto;
    position: relative;
    z-index: 1;
}

/* Custom Scrollbar */
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

body.light-mode .modal-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
}

.timeline-feed {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.timeline-item {
    position: relative;
    padding-left: 20px;
    border-left: 2px dashed rgba(255, 255, 255, 0.1);
    animation: slideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

body.light-mode .timeline-item {
    border-left-color: rgba(0, 0, 0, 0.1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.2);
}

.timeline-content {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 1.25rem;
    transition: all 0.3s ease;
}

body.light-mode .timeline-content {
    background: #ffffff;
    border-color: var(--input-border);
    box-shadow: var(--shadow-sm);
}

.timeline-content:hover {
    transform: translateX(5px);
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--primary-color);
}

body.light-mode .timeline-content:hover {
    background: #ffffff;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.version-tag {
    display: inline-block;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.3);
}

.version-date {
    display: inline-block;
    margin-left: 0.5rem;
    font-size: 0.8rem;
    opacity: 0.6;
    font-family: monospace;
}

.changelog-list {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.changelog-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-color);
}

.change-icon {
    font-size: 1rem;
    line-height: 1.4;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.change-text {
    opacity: 0.9;
}

/* Footer Link Button (Reset) */
.footer-link-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
    color: var(--text-color);
    transition: all 0.3s ease;
    text-decoration: none;
    /* In case */
    display: inline;
}

.footer-link-btn:hover {
    color: var(--primary-color);
    text-decoration: underline;
}