:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #f43f5e;
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --success: #10b981;
    --warning: #f59e0b;
    --accent: #818cf8;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

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

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-container img {
    height: 40px;
}

.logo-container h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
    font-size: 0.95rem;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}

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

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.card h3 {
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

.tag {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-weight: 600;
    text-transform: uppercase;
}

.tag-blue {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
}

.tag-purple {
    background: rgba(168, 85, 247, 0.1);
    color: #c084fc;
}

.tag-red {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
}

.section-title {
    margin-bottom: 2rem;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

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

/* Print Styles */
@media print {

    /* Hide everything except the modal content and its children */
    body>*:not(#modal-container),
    .no-print,
    .modal-header,
    .search-input-container,
    .close-modal,
    button,
    .floating-summary,
    header,
    footer,
    section {
        display: none !important;
    }

    #modal-container {
        display: block !important;
        position: static !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        background: white !important;
    }

    .modal-overlay {
        display: block !important;
        position: static !important;
        background: white !important;
        backdrop-filter: none !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        height: auto !important;
    }

    .modal-card,
    .modal-content {
        display: block !important;
        position: static !important;
        width: 100% !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        transform: none !important;
        background: white !important;
        color: black !important;
    }

    .modal-body {
        padding: 0 !important;
        overflow: visible !important;
        height: auto !important;
    }

    #print-area {
        display: block !important;
        width: 100% !important;
        background: white !important;
        color: black !important;
    }

    .print-page {
        page-break-after: always !important;
        break-after: page !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .print-page:last-child {
        page-break-after: avoid !important;
        break-after: auto !important;
    }

    .questions-two-columns {
        column-count: 2 !important;
        column-gap: 2cm !important;
        column-rule: 1px solid #ddd !important;
    }

    .question {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
        margin-bottom: 1.2rem !important;
    }

    .print-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 10pt;
    }

    .print-table th,
    .print-table td {
        border: 1px solid #000 !important;
        padding: 6px !important;
    }

    @page {
        size: A4 portrait !important;
        margin: 1cm !important;
    }
}

.reveal {
    animation: fadeIn 0.6s ease-out forwards;
}

/* Base modal overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(2, 6, 23, 0.95);
    /* Slightly darker for better contrast */
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 2rem;
}

/* Exam Preview Styles (How it looks on screen) */
#print-area {
    background: white !important;
    color: black !important;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    margin: 0 auto;
    width: 100%;
    min-width: 800px;
    /* Simulates A4 width, forcing horizontal scroll on mobile */
}

#print-area * {
    color: black !important;
}

.print-page {
    background: white;
    margin-bottom: 2rem;
    padding: 1rem;
}

.questions-two-columns {
    column-count: 2;
    column-gap: 3rem;
    column-rule: 1px solid #eee;
    padding-top: 1rem;
}

.question {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.4;
}

.question p {
    margin: 0;
}

.question strong {
    display: block;
    margin-bottom: 0.5rem;
}

.options-list {
    margin-left: 1rem;
}

.options-list p {
    margin-bottom: 0.2rem;
}

.modal-card,
.modal-content {
    background: #1e293b;
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 900px;
    /* Increased for preview */
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: fadeIn 0.3s ease-out;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    padding: 1.5rem 2rem;
    overscroll-behavior: contain;
}

/* Scrollbar for preview */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

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

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.search-input-container {
    padding: 1rem 1.5rem;
    background: #1e293b;
    border-bottom: 1px solid var(--border);
}

.selection-list {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.selection-item {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.5;
    font-size: 0.95rem;
    word-break: break-word;
}

.selection-item:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--accent);
    transform: translateX(5px);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-control:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.05);
}

.modal-select-trigger {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-size: 1rem;
    cursor: pointer;
    min-height: 48px;
    display: flex;
    align-items: center;
    transition: all 0.2s;
    line-height: 1.4;
}

.modal-select-trigger.disabled {
    opacity: 0.5;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.05);
}

.modal-select-trigger:hover {
    border-color: var(--accent);
    background: rgba(129, 140, 248, 0.05);
}

.modal-select-trigger.active {
    border-color: var(--accent);
    font-weight: 500;
}

/* Floating Summary */
.floating-summary {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
    transition: all 0.3s ease;
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
        padding-bottom: 6rem;
        /* Prevent floating button from blocking content */
    }

    header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .floating-summary {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        display: flex;
        justify-content: center;
    }

    .floating-summary>button {
        width: 100%;
        max-width: 400px;
        padding: 1rem !important;
        font-size: 1rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}