:root {
    --primary: #8b5cf6;
    --accent: #06b6d4;
    --bg-deep: #020617;
    --glass: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-white: #f8fafc;
    --text-dim: #94a3b8;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-deep);
    color: var(--text-white);
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- Watermark --- */
.watermark-bg {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) rotate(-25deg);
    font-size: 14vw;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.07);
    z-index: -2;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
}

/* --- LOGO STYLING --- */
.brand-logo-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 25px;
}
.main-logo {
    width: 80px; height: auto; max-height: 80px;
    filter: drop-shadow(0 10px 15px rgba(139, 92, 246, 0.3));
    margin-bottom: 15px;
    transition: transform 0.3s ease;
}
.brand-name {
    font-weight: 800; letter-spacing: 4px; font-size: 1.3rem;
    color: var(--primary); text-transform: uppercase;
}
.brand-name span { color: #fff; }

.app-container {
    position: relative; z-index: 10;
    max-width: 1400px; margin: 0 auto; padding: 60px 20px 20px;
}

header { text-align: center; margin-bottom: 40px; }
header h1 { font-size: 2.8rem; margin: 10px 0; font-weight: 800; }
header p { color: var(--text-dim); }

.search-wrapper { max-width: 500px; margin: 0 auto 50px; position: relative; }
.search-wrapper input {
    width: 100%; padding: 18px 20px 18px 55px;
    background: var(--glass); border: 1px solid var(--glass-border);
    border-radius: 20px; color: white; outline: none;
    backdrop-filter: blur(15px); transition: 0.3s;
}
.search-wrapper input:focus { border-color: var(--primary); box-shadow: 0 0 20px rgba(139, 92, 246, 0.2); }
.search-wrapper i { position: absolute; left: 22px; top: 20px; color: var(--text-dim); }

.subject-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 25px;
    margin-bottom: 80px;
}

.subject-card {
    background: var(--glass); border: 1px solid var(--glass-border);
    border-radius: 24px; backdrop-filter: blur(20px);
    transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); overflow: hidden;
}
.subject-card:hover { transform: translateY(-8px); border-color: var(--primary); }

.card-header { padding: 25px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.header-content { display: flex; align-items: center; gap: 14px; flex: 1; }
.subject-checkbox-wrapper { cursor: pointer; display: flex; align-items: center; justify-content: center; }
.subject-checkbox { width: 20px; height: 20px; border: 2px solid var(--text-dim); border-radius: 6px; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; }
.subject-checkbox i { font-size: 10px; color: white; display: none; }
.subject-checkbox.checked { background: var(--primary); border-color: var(--primary); }
.subject-checkbox.checked i { display: block; }
.card-header h3 { font-size: 1.15rem; display: flex; align-items: center; gap: 12px; }
.card-header i.sub-icon { color: var(--primary); font-size: 1.3rem; }
.chevron { transition: 0.3s; color: var(--text-dim); }

/* --- SCROLLABLE TOPICS AREA --- */
.topics-area {
    max-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    transition: max-height 0.5s ease;
    background: rgba(0, 0, 0, 0.2);
}

.subject-card.active .topics-area { 
    max-height: 400px; /* Window for scrolling through long syllabi */
    border-top: 1px solid var(--glass-border); 
}

/* Custom Scrollbar for the topics */
.topics-area::-webkit-scrollbar { width: 5px; }
.topics-area::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 10px; }

.subject-card.active .chevron { transform: rotate(180deg); color: var(--primary); }

.topic-row { padding: 14px 25px; display: flex; align-items: center; gap: 15px; cursor: pointer; transition: 0.2s; }
.topic-row:hover { background: rgba(255, 255, 255, 0.05); }

.custom-check {
    width: 22px; height: 22px; border: 2px solid var(--text-dim);
    border-radius: 7px; display: flex; align-items: center; justify-content: center;
}
.topic-row.selected .custom-check { background: var(--primary); border-color: var(--primary); }
.custom-check i { font-size: 11px; display: none; color: white; }
.topic-row.selected .custom-check i { display: block; }
.topic-row span { color: var(--text-dim); }
.topic-row.selected span { color: #fff; font-weight: 600; }

/* --- FOOTER (UNCHANGED) --- */
footer {
    border-top: 1px solid var(--glass-border);
    padding: 40px 0; margin-top: 50px; text-align: center;
}
.footer-content p { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 15px; }
.footer-links { display: flex; justify-content: center; gap: 20px; }
.footer-links a { color: var(--primary); text-decoration: none; font-size: 0.85rem; font-weight: 600; }
.footer-links a:hover { color: #fff; }

.fab-container {
    position: fixed; bottom: -100px; left: 50%; transform: translateX(-50%);
    transition: 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); z-index: 1000;
}
.fab-container.show { bottom: 40px; }

.generate-btn {
    padding: 18px 45px; background: linear-gradient(135deg, var(--primary), #6366f1);
    color: white; border: none; border-radius: 50px; cursor: pointer;
    font-weight: 700; box-shadow: 0 15px 40px rgba(139, 92, 246, 0.4);
    display: flex; align-items: center; gap: 12px;
}

/* Responsive: make subject cards stack and adjust grid */
@media (max-width: 1200px) {
    .subject-grid { grid-template-columns: repeat(3, 1fr); gap: 20px; }
    header h1 { font-size: 2.4rem; }
    .app-container { padding: 40px 16px 20px; }
}

@media (max-width: 768px) {
    .subject-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
    header h1 { font-size: 2rem; }
    .brand-logo-box { margin-bottom: 15px; }
    .search-wrapper { margin-bottom: 30px; }
    .fab-container { bottom: 20px; }
    .generate-btn { padding: 12px 20px; font-size: 0.95rem; }
}

@media (max-width: 480px) {
    .subject-grid { grid-template-columns: 1fr; gap: 12px; }
    header h1 { font-size: 1.6rem; }
    header p { font-size: 0.95rem; }
    .search-wrapper input { padding: 12px 14px 12px 44px; }
    .generate-btn { width: calc(100% - 40px); padding: 12px; left: 20px; right: 20px; }
    .top-nav { padding: 8px; gap: 8px; }
}

/* Touch optimizations for subjects page */
@media (pointer: coarse) {
    .subject-card { padding: 18px; }
    .topic-row { padding: 16px; }
    .generate-btn { padding: 14px 18px; font-size: 1rem; }
    .nav-link { padding: 12px 14px; }
}

/* --- NAVIGATION --- */
.top-nav {
    display: flex; justify-content: space-between; align-items: center;
    max-width: 100%; margin-bottom: 30px; padding: 10px 5px;
}
.nav-link {
    display: flex; align-items: center; gap: 8px; padding: 10px 18px;
    background: var(--glass); border: 1px solid var(--glass-border);
    border-radius: 12px; color: var(--text-white); text-decoration: none;
    font-size: 0.9rem; font-weight: 600; backdrop-filter: blur(10px);
}
.nav-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
    margin-left: 10px;
    display: none;
}

.select-all-row { background: rgba(139, 92, 246, 0.1); border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.select-all-row.selected { background: var(--primary) !important; }

.subject-card {
    padding: 15px;
    background: rgba(255,255,255,0.08);
    border-radius: 12px;
    cursor: pointer;
    transition: 0.3s ease;
}

.subject-card:hover {
    transform: translateY(-4px);
}

.subject-card.selected {
    background: linear-gradient(135deg, #00c6ff, #0072ff);
    color: white;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
    display: none;
}

.modal-content {
    background: linear-gradient(135deg, rgba(20, 30, 60, 0.95), rgba(40, 20, 60, 0.95));
    border: 2px solid rgba(139, 92, 246, 0.3);
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: white;
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: #999;
    font-size: 28px;
    cursor: pointer;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 24px;
}

.student-name-input {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}

.student-name-input label {
    display: block;
    color: white;
    margin-bottom: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.student-name-input input {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(139, 92, 246, 0.3);
    border-radius: 10px;
    color: white;
    font-size: 16px;
    transition: all 0.3s ease;
}

.student-name-input input:focus {
    outline: none;
    border-color: #06b6d4;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.3);
}

.student-name-input input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.modal-body p {
    color: #ccc;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-body p strong {
    color: #06b6d4;
}

.question-count-input {
    margin-bottom: 20px;
}

.question-count-input label {
    display: block;
    color: white;
    margin-bottom: 10px;
    font-weight: 500;
}

.question-count-input input {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(139, 92, 246, 0.3);
    border-radius: 10px;
    color: white;
    font-size: 16px;
    transition: all 0.3s ease;
}

.question-count-input input:focus {
    outline: none;
    border-color: #06b6d4;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.3);
}

.question-count-input input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.info-text {
    font-size: 13px;
    color: #999;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(139, 92, 246, 0.2);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.btn-cancel,
.btn-confirm,
.btn-secondary {
    padding: 10px 24px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: auto;
    white-space: nowrap;
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-secondary {
    background: rgba(251, 146, 60, 0.2);
    color: #fb923c;
    border: 1px solid rgba(251, 146, 60, 0.3);
}

.btn-secondary:hover {
    background: rgba(251, 146, 60, 0.3);
    border-color: rgba(251, 146, 60, 0.5);
}

.btn-confirm {
    background: linear-gradient(135deg, #8b5cf6, #06b6d4);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.4);
}

.btn-confirm:active {
    transform: translateY(0);
}
