/* --- GLOBAL RESETS --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f4f7f6; /* Light grey background */
    color: #333;
}

/* --- 1. NAVBAR SECTION --- */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 40px;
    background-color: white;
    border-bottom: 1px solid #eee;
    box-shadow: 0 2px 10px rgba(42, 148, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-brand {
    display: flex;
    align-items: center;
}

.logo-box {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 22px;
    margin-right: 12px;
}

.brand-text h1 {
    font-size: 22px;
    color: #333;
    font-weight: 800;
}

.brand-text p {
    font-size: 11px;
    color: #777;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 30px;
}

.nav-links li {
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
}

.nav-links li i {
    margin-right: 8px;
    font-size: 16px;
    color: #667eea;
}

.user-profile {
    background-color: #f3e8ff;
    padding: 8px 20px;
    border-radius: 20px;
    border: 1px solid #d8b4fe;
    color: #5a189a;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-profile .logout-btn {
    background-color: #ff6b6b;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.hamburger {
    display: none;
    font-size: 24px;
    cursor: pointer;
    color: #333;
}

/* --- 2. MAIN CONTENT SECTION --- */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
}

.hero-title {
    color: #667eea; /* Dark Purple */
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 10px;
}

.hero-subtitle {
    color: #666;
    margin-bottom: 30px;
}

/* Search Row */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 40px;
    margin-bottom: 20px;
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    border-left: 4px solid #667eea;
    padding-left: 10px;
    color: #333;
}

.search-bar {
    position: relative;
}

.search-bar input {
    padding: 10px 15px 10px 35px;
    border-radius: 8px;
    border: 1px solid #ddd;
    width: 250px;
}

.search-bar i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
}

/* --- THE GRID (The Cards) --- */
.card-grid {
    display: grid;
    /* This creates responsive columns: 4 columns on big screens */
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(39, 159, 9, 0.02);
    display: flex;
    align-items: flex-start;
    gap: 15px;
    transition: transform 0.2s;
    cursor: pointer;
    border: 1px solid transparent;
    position: relative;
}

.card:hover {
    transform: translateY(-5px); /* Moves up slightly on hover */
    border-color: #667eea;
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.1);
}

.delete-card-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ff6b6b;
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 10;
}

.card:hover .delete-card-btn {
    opacity: 1;
}

.card-title {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    margin-bottom: 15px;
    line-height: 1.4;
}

/* --- 3. FOOTER SECTION --- */
.footer {
    background-color: white;
    padding: 50px 40px;
    margin-top: 60px;
    border-top: 1px solid #eaeaea;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 Columns */
    gap: 40px;
}

.footer-col h3 {
    font-size: 14px;
    margin-bottom: 20px;
    color: #333;
}

.footer-col ul {
    list-style: none;
}

.footer-col ul li {
    margin-bottom: 10px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
}

.footer-col ul li:hover {
    color: #667eea;
}

/* Contact Form in Footer */
.footer-form input, 
.footer-form textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 13px;
    font-family: inherit;
}

.footer-form textarea {
    resize: vertical;
    min-height: 60px;
}

.footer-form button {
    width: 100%;
    padding: 10px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.3s;
}

.footer-form button:hover {
    background: #5568d3;
}

.brand-col img {
    width: 40px;
    margin-bottom: 15px;
}

.brand-desc {
    font-size: 12px; 
    color: #777; 
    line-height: 1.6;
}

.social-links {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.social-links a {
    width: 32px;
    height: 32px;
    background-color: #f0f0f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 14px;
}

.social-links a:hover {
    background-color: #667eea;
    color: white;
    transform: translateY(-3px);
}

/* --- CHILD BUTTONS SECTION --- */
.expand-btn {
    background-color: #667eea;
    border: none;
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
    margin-top: 5px;
    font-size: 20px;
}

.expand-btn:hover {
    background-color: #5568d3;
}

.child-buttons {
    position: static;
    background: white;
    border: 1px solid #c6cfff;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    z-index: 100;
    min-width: 150px;
    max-width: 180px;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.child-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.3s;
    text-align: left;
}

.child-btn:hover {
    background: linear-gradient(135deg, #5568d3, #653c91);
    transform: translateX(5px);
}

/* --- AUTHENTICATION PAGES --- */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 80px);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.auth-card {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
}

.auth-card h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
    font-size: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 5px rgba(102, 126, 234, 0.3);
}

.auth-link {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: #666;
}

.auth-link a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* --- BUTTON STYLES --- */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ddd;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-success {
    background: linear-gradient(135deg, #21cc12, #0aab0a);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(10, 171, 10, 0.4);
}

/* --- QUIZ PAGE STYLES --- */
.quiz-container {
    max-width: 900px;
    margin: 40px auto;
    padding: 0 20px;
}

.quiz-header {
    background: white;
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.quiz-header h2 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 24px;
}

.quiz-info {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #666;
}

.quiz-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

#questionText {
    font-size: 18px;
    color: #333;
    margin-bottom: 25px;
    font-weight: 600;
    line-height: 1.6;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.option-label {
    display: flex;
    align-items: center;
    padding: 15px;
    background: #f9f9f9;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.option-label:hover {
    background: #f0f0f0;
    border-color: #667eea;
}

.option-label input[type="radio"] {
    margin-right: 12px;
    cursor: pointer;
    width: 20px;
    height: 20px;
}

.option-label span {
    font-size: 16px;
    color: #333;
}

.view-answer-btn {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    margin-top: 15px;
    padding: 5px 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.view-answer-btn:hover {
    text-decoration: underline;
}

.answer-box {
    background-color: #f0fdf4; /* Light green background */
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    padding: 15px;
    margin-top: 10px;
    color: #166534; /* Dark green text */
    font-size: 14px;
    line-height: 1.5;
}

.answer-box strong {
    color: #15803d;
    font-weight: 700;
}

.quiz-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.quiz-controls button {
    padding: 12px 24px;
    font-size: 16px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: #f0f0f0;
    border-radius: 3px;
    margin-top: 20px;
    overflow: hidden;
}

#progressFill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s;
}

/* --- RESULTS PAGE STYLES --- */
.results-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 80px);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.results-card {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 500px;
    text-align: center;
}

.results-card h2 {
    color: #667eea;
    margin-bottom: 30px;
    font-size: 28px;
}

.score-display {
    margin: 30px 0;
}

.score-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 36px;
    font-weight: bold;
}

.percentage {
    font-size: 24px;
    color: #667eea;
    font-weight: bold;
}

.results-details {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin: 25px 0;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #ddd;
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-item span {
    color: #666;
}

.detail-item strong {
    color: #667eea;
}

.results-message {
    font-size: 16px;
    color: #666;
    margin: 20px 0;
    padding: 15px;
    background: #f0f0f0;
    border-radius: 6px;
}

.results-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 25px;
}

.results-actions button {
    padding: 12px 24px;
    font-size: 16px;
}

/* --- LEADERBOARD PAGE STYLES --- */
.leaderboard-container {
    max-width: 1000px;
    margin: 40px auto;
    padding: 0 20px;
}

.leaderboard-header {
    text-align: center;
    margin-bottom: 30px;
}

.leaderboard-header h2 {
    color: #667eea;
    font-size: 28px;
    margin-bottom: 10px;
}

.leaderboard-header p {
    color: #666;
    font-size: 16px;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.leaderboard-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.leaderboard-table tbody tr:hover {
    background: #f9f9f9;
}

.leaderboard-table th {
    font-weight: 600;
    font-size: 14px;
}

.leaderboard-table td {
    color: #333;
    font-size: 15px;
}

/* --- RESPONSIVE DESIGN --- */
@media (max-width: 768px) {
    .navbar {
        flex-wrap: wrap;
        padding: 15px 20px;
    }

    .nav-brand {
        flex-grow: 1;
    }

    .hamburger {
        display: block;
        margin-left: 15px;
    }

    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 10px;
        margin-top: 15px;
        padding-top: 15px;
        border-top: 1px solid #eee;
        order: 3;
    }

    .nav-links.active {
        display: flex;
    }

    .card-grid {
        grid-template-columns: 1fr; /* Single column on mobile */
        gap: 15px;
    }

    .card {
        padding: 15px; /* Reduce padding on mobile */
        flex-direction: column; /* Stack elements vertically */
        align-items: stretch; /* Full width elements */
    }

    .delete-card-btn {
        opacity: 1;
    }

    .card-info {
        width: 100%;
    }

    .expand-btn {
        align-self: flex-end; /* Position expand button to the right */
        margin-top: 10px;
    }

    .child-buttons {
        flex-direction: column; /* Keep vertical on mobile */
        gap: 5px;
        padding: 15px;
        min-width: unset; /* Remove min-width for full width */
        max-width: unset;
    }

    .child-btn {
        width: 100%; /* Full width buttons on mobile */
        text-align: left;
        justify-content: flex-start;
        padding: 14px 10px;
        font-size: 15px;
    }

    .content-header .filters {
        flex-direction: column;
        align-items: stretch;
    }

    .content-header .filters select,
    .content-header .filters button {
        width: 100%;
    }

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

    .quiz-controls button {
        width: 100%;
    }

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

    .results-actions button {
        width: 100%;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 10px;
        font-size: 12px;
    }

    .auth-card {
        padding: 25px;
    }

    .quiz-header {
        padding: 20px;
    }

    .quiz-content {
        padding: 20px;
    }

    #questionText {
        font-size: 16px;
    }

    .hero-title {
        font-size: 2.2rem;
    }
}

/* --- FOOTER CONTACT BUTTON --- */
.footer-contact-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.footer-contact-header h3 {
    margin-bottom: 0;
}

.footer-contact-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: transform 0.3s;
}

.footer-contact-btn:hover {
    transform: scale(1.1);
}

.contact-popup {
    display: none;
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 320px;
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 5px 30px rgba(0,0,0,0.2);
    z-index: 1001;
    border: 1px solid #eee;
    animation: slideUp 0.3s ease-out;
}

.contact-popup h3 {
    cursor: move;
    user-select: none;
}

.contact-popup.active {
    display: block;
}

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

/* --- MOBILE RESPONSIVE --- */
@media (max-width: 768px) {
    /* Navbar */
    .navbar {
        padding: 10px 15px;
    }
    
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: 15px;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    }
    
    .nav-links.active {
        display: flex;
    }
    
    .hamburger {
        display: block !important;
        font-size: 24px;
        cursor: pointer;
        padding: 5px;
    }
    
    .brand-text h1 {
        font-size: 16px;
    }
    
    .brand-text p {
        display: none;
    }
    
    .user-profile {
        display: none;
    }
    
    .user-profile.active {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%;
        right: 0;
        background: white;
        padding: 15px;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    }
    
    /* Cards Grid */
    #cardGrid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
        padding: 15px !important;
    }
    
    .card {
        padding: 20px !important;
    }
    
    .card-title {
        font-size: 16px !important;
    }
    
    /* Forms */
    .form-container, .container {
        padding: 15px !important;
        margin: 10px !important;
    }
    
    input, select, textarea {
        padding: 12px !important;
        font-size: 16px !important;
    }
    
    button {
        padding: 12px 20px !important;
        font-size: 14px !important;
        min-height: 44px;
    }
    
    /* Quiz Page */
    .quiz-container {
        padding: 15px !important;
    }
    
    .question-text {
        font-size: 16px !important;
        padding: 15px !important;
    }
    
    .option-btn {
        padding: 15px !important;
        font-size: 14px !important;
        margin: 8px 0 !important;
    }
    
    /* Admin Panel */
    .admin-tabs {
        flex-wrap: wrap;
    }
    
    .admin-tabs button {
        padding: 10px 12px !important;
        font-size: 12px !important;
    }
    
    /* Footer */
    .footer-content {
        flex-direction: column;
        text-align: center;
        padding: 20px !important;
    }
    
    /* User Profile */
    #userProfile {
        gap: 8px !important;
    }
    
    #username {
        font-size: 14px !important;
    }
    
    /* Dropdowns */
    select {
        padding: 10px !important;
        font-size: 14px !important;
    }
    
    /* Contact Popup */
    .contact-popup {
        width: calc(100% - 30px) !important;
        left: 15px !important;
        right: 15px !important;
        bottom: 80px !important;
    }
    
    /* Login/Register Forms */
    .auth-container {
        padding: 20px 15px !important;
    }
    
    /* Leaderboard */
    .leaderboard-table {
        font-size: 12px !important;
    }
    
    .leaderboard-table th, .leaderboard-table td {
        padding: 8px 4px !important;
    }
    
    /* General spacing */
    .container {
        padding: 15px;
    }
    
    h2 {
        font-size: 20px !important;
    }
    
    /* Hero section */
    .hero-title {
        font-size: 24px !important;
    }
    
    .hero-subtitle {
        font-size: 14px !important;
    }
    
    /* Cards in grid */
    .content-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .filters {
        width: 100%;
    }
    
    .filters select {
        width: 100%;
    }
    
    /* Subject/MCQ pages */
    .mcq-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Results page */
    .result-details {
        padding: 15px !important;
    }
    
    /* Profile page */
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
}

/* Extra small phones */
@media (max-width: 480px) {
    .logo-box {
        width: 35px !important;
        height: 35px !important;
        font-size: 18px !important;
    }
    
    .brand-text h1 {
        font-size: 14px !important;
    }
    
    .btn-secondary, .btn-primary {
        padding: 10px 15px !important;
        font-size: 13px !important;
    }
    
    .card-meta {
        font-size: 12px !important;
    }
}
