/* ============================================
   Flexcel ⚡ - Media Ajar Informatika K8
   Custom Styles
   ============================================ */

/* ---- Base ---- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    overflow-x: hidden;
}

/* ---- Page Sections ---- */
.page-section {
    display: none;
}

.page-section.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

/* ---- Term Highlight ---- */
.term-hl {
    background: linear-gradient(120deg, #bbf7d0 0%, #86efac 100%);
    padding: 0.1em 0.35em;
    border-radius: 0.25em;
    border-bottom: 1.5px dashed #22c55e;
    font-weight: 700;
    cursor: default;
}

/* ---- Navigation Links ---- */
.nav-link {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #4b5563;
    border-radius: 0.75rem;
    transition: all 0.2s ease;
    border: none;
    background: none;
    cursor: pointer;
}

.nav-link:hover {
    color: #15803d;
    background-color: #f0fdf4;
}

.nav-link.active {
    color: #15803d;
    background-color: #dcfce7;
}

.mobile-nav-link {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #4b5563;
    border-radius: 0.75rem;
    transition: all 0.2s ease;
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
}

.mobile-nav-link:hover, .mobile-nav-link.active {
    color: #15803d;
    background-color: #dcfce7;
}

/* ---- Feature Card ---- */
.feature-card {
    background: white;
    border-radius: 1.5rem;
    padding: 2rem;
    border: 1px solid #f3f4f6;
    transition: all 0.3s ease;
    cursor: default;
}

.feature-card:hover {
    box-shadow: 0 20px 60px -15px rgba(0, 0, 0, 0.1);
    transform: translateY(-4px);
    border-color: #dcfce7;
}

/* ---- Materi Card ---- */
.materi-card {
    background: white;
    border-radius: 1.5rem;
    border: 1px solid #f3f4f6;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
}

.materi-card:hover {
    box-shadow: 0 20px 60px -15px rgba(0, 0, 0, 0.15);
    transform: translateY(-6px);
}

/* ---- Content Card ---- */
.content-card {
    background: white;
    border-radius: 1.5rem;
    padding: 2rem;
    border: 1px solid #f3f4f6;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* ---- Materi Tabs ---- */
.materi-tab {
    display: inline-flex;
    align-items: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.materi-tab:hover {
    border-color: #22c55e;
    color: #15803d;
}

.materi-tab.active {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.3);
}

/* ---- Materi Content ---- */
.materi-content {
    display: none;
}

.materi-content.active {
    display: block;
    animation: slideUp 0.5s ease-out;
}

/* ---- Formula Box ---- */
.formula-box {
    background: #f0fdf4;
    border: 2px dashed #86efac;
    border-radius: 1rem;
    padding: 1.25rem;
    text-align: center;
}

.formula-syntax {
    font-family: 'Courier New', monospace;
    font-size: 1.125rem;
    font-weight: 700;
    color: #15803d;
    letter-spacing: 0.025em;
}

/* ---- Spreadsheet Demo ---- */
.spreadsheet-demo {
    border-collapse: collapse;
    font-size: 0.875rem;
}

.spreadsheet-demo th {
    background: #e5e7eb;
    padding: 0.5rem 1rem;
    text-align: center;
    font-weight: 600;
    color: #4b5563;
    border: 1px solid #d1d5db;
    font-size: 0.75rem;
}

.spreadsheet-demo td {
    padding: 0.5rem 1rem;
    border: 1px solid #e5e7eb;
    text-align: center;
}

.spreadsheet-demo .row-header {
    background: #e5e7eb;
    font-weight: 600;
    color: #4b5563;
    font-size: 0.75rem;
    width: 2rem;
}

.spreadsheet-demo .cell-highlight {
    background: #f0fdf4;
    font-weight: 600;
    color: #15803d;
}

.spreadsheet-demo .formula-cell {
    background: #eff6ff;
    font-weight: 600;
    color: #1d4ed8;
    font-family: monospace;
}

/* ---- Kisi-Kisi Item ---- */
.kisi-item {
    display: flex;
    align-items: start;
    padding: 0.75rem 1rem;
    background: #f9fafb;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    color: #374151;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.kisi-item:hover {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

/* ---- Quiz Category Button ---- */
.quiz-category-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

/* ---- Quiz Option Button ---- */
.quiz-option {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 1rem 1.25rem;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-size: 0.9375rem;
    color: #374151;
}

.quiz-option:hover:not(.selected):not(.disabled) {
    border-color: #a78bfa;
    background: #f5f3ff;
}

.quiz-option .option-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: #e5e7eb;
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 0.875rem;
    margin-right: 0.75rem;
    flex-shrink: 0;
    transition: all 0.2s;
}

.quiz-option:hover:not(.selected):not(.disabled) .option-letter {
    background: #ddd6fe;
    color: #7c3aed;
}

.quiz-option.correct {
    border-color: #22c55e;
    background: #f0fdf4;
}

.quiz-option.correct .option-letter {
    background: #22c55e;
    color: white;
}

.quiz-option.wrong {
    border-color: #ef4444;
    background: #fef2f2;
}

.quiz-option.wrong .option-letter {
    background: #ef4444;
    color: white;
}

.quiz-option.disabled {
    cursor: default;
    opacity: 0.7;
}

/* ---- Game Difficulty Button ---- */
.game-diff-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid;
}

.game-diff-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ---- Toast Notification ---- */
#toast.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* ---- Scroll Animation ---- */
.scroll-animate {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease-out;
}

.scroll-animate.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Confetti ---- */
.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    animation: confettiDrop 2s ease-out forwards;
}

@keyframes confettiDrop {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(300px) rotate(720deg);
        opacity: 0;
    }
}

/* ---- Shake Animation ---- */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.shake {
    animation: shake 0.3s ease-out;
}

/* ---- Pulse Animation for Correct ---- */
@keyframes correctPulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
    70% { box-shadow: 0 0 0 15px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.correct-pulse {
    animation: correctPulse 0.6s ease-out;
}

/* ---- Custom Scrollbar ---- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #bbf7d0;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #22c55e;
}

/* ---- Selection Color ---- */
::selection {
    background: #bbf7d0;
    color: #14532d;
}

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

    .formula-syntax {
        font-size: 0.8rem;
        word-break: break-all;
    }

    .spreadsheet-demo {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .spreadsheet-demo td, .spreadsheet-demo th {
        padding: 0.35rem 0.4rem;
        font-size: 0.7rem;
        white-space: nowrap;
    }

    .quiz-category-btn {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    #game-input {
        font-size: 1rem;
    }

    h1.text-4xl, h1.text-5xl {
        font-size: 1.75rem !important;
    }

    h2.text-3xl {
        font-size: 1.5rem !important;
    }
}

/* ---- Mobile Bottom Nav ---- */
.bottom-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.35rem 0.5rem;
    font-size: 0.625rem;
    font-weight: 600;
    color: #9ca3af;
    border-radius: 0.75rem;
    border: none;
    background: none;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    min-width: 0;
}

.bottom-nav-btn:hover {
    color: #15803d;
}

.bottom-nav-btn.active {
    color: #15803d;
}

.bottom-nav-btn.active i {
    background: linear-gradient(135deg, #22c55e, #10b981);
    color: white;
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.75rem;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.35);
}

/* Bottom nav safe area padding on mobile */
@media (max-width: 767px) {
    body {
        padding-bottom: 4.5rem;
    }

    #toast {
        bottom: 5.5rem !important;
    }

    /* Hide the slide-out mobile menu on small screens since bottom nav exists */
    #mobile-menu-btn {
        display: none !important;
    }
    #mobile-menu {
        display: none !important;
    }
}

/* ---- Avatar Option ---- */
.avatar-option {
    cursor: pointer;
    user-select: none;
}

/* ---- Share Modal ---- */
#share-modal .animate-bounce-in {
    animation: bounceIn 0.5s ease-out;
}

/* ---- Loading screen hide ---- */
.loading-hidden {
    opacity: 0 !important;
    pointer-events: none;
}

/* ---- Game Input Focus ---- */
#game-input:focus {
    outline: none;
}

/* ---- Timer Warning ---- */
.timer-warning {
    color: #ef4444 !important;
    animation: pulse 0.5s infinite;
}

/* ---- Print Styles ---- */
@media print {
    nav, #toast, #achievement-modal, #loading-screen {
        display: none !important;
    }
    .page-section {
        display: block !important;
    }
}
