/* Ahmed's Math Academy - Custom Styles */

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in-down {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-in-left {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slide-in-right {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scale-up {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Animation Classes */
.animate-fade-in {
    animation: fade-in 0.6s ease-out forwards;
}

.animate-fade-in-up {
    animation: fade-in-up 0.8s ease-out forwards;
}

.animate-fade-in-down {
    animation: fade-in-down 0.8s ease-out forwards;
}

.animate-slide-in-left {
    animation: slide-in-left 0.6s ease-out forwards;
}

.animate-slide-in-right {
    animation: slide-in-right 0.6s ease-out forwards;
}

.animate-scale-up {
    animation: scale-up 0.5s ease-out forwards;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* ============================================
   MOBILE NAVIGATION
   ============================================ */

/* Mobile menu button animation */
.mobile-menu-btn {
    position: relative;
    z-index: 60;
    transition: transform 0.3s ease;
}

.mobile-menu-btn:active {
    transform: scale(0.95);
}

/* Mobile menu container */
#mobile-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 40;
}

#mobile-menu.show {
    max-height: 100vh;
    overflow-y: auto;
}

/* Mobile menu items */
#mobile-menu a {
    display: block;
    padding: 0.875rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    font-size: 0.9375rem;
}

#mobile-menu a:active {
    background-color: #f3f4f6;
    transform: scale(0.98);
}

/* Mobile menu section headers */
#mobile-menu .menu-section-header {
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #9ca3af;
    padding: 1rem 1rem 0.5rem;
    border-top: 1px solid #e5e7eb;
    margin-top: 0.75rem;
}

/* Mobile menu demo items styling */
#mobile-menu .demo-item {
    margin-left: 0.5rem;
    padding-left: 1rem;
    border-left: 2px solid #e5e7eb;
}

/* Smooth height transition helper */
@media (max-width: 768px) {
    .navbar {
        position: relative;
    }
    
    /* Better touch targets for mobile */
    #mobile-menu a {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    /* Prevent body scroll when menu is open */
    body.mobile-menu-open {
        overflow: hidden;
    }
}

/* Hamburger to X animation */
.hamburger {
    display: inline-block;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.hamburger.active {
    transform: rotate(90deg);
}

/* ============================================
   DROPDOWN MENU
   ============================================ */

.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    left: 0;
    margin-top: 0.5rem;
    width: 14rem;
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease-out;
    z-index: 50;
}

.dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: block;
    padding: 0.75rem 1rem;
    color: #374151;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background-color: #f3f4f6;
    color: #6366f1;
}

.dropdown-item:first-child {
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
}

.dropdown-item:last-child {
    border-bottom-left-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.card-hover {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 
                0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: white;
    color: #6366f1;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
    border: 2px solid #6366f1;
    cursor: pointer;
}

.btn-secondary:hover {
    background: #f5f7ff;
    transform: translateY(-2px);
}

/* ============================================
   FLASH MESSAGES
   ============================================ */

.flash-message {
    animation: fade-in-down 0.5s ease-out forwards;
}

.flash-success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

.flash-error {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.flash-warning {
    background-color: #fef3c7;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

.flash-info {
    background-color: #dbeafe;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

/* ============================================
   FORM STYLING
   ============================================ */

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input.error {
    border-color: #ef4444;
}

.form-label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.form-error {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* ============================================
   PROGRESS BAR
   ============================================ */

.progress-bar {
    height: 0.5rem;
    background-color: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 9999px;
    transition: width 0.5s ease;
}

/* ============================================
   LEVEL CARDS
   ============================================ */

.level-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
}

.level-card.active {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.level-card.completed {
    border-color: #10b981;
    background: linear-gradient(135deg, #d1fae5 0%, #ecfdf5 100%);
}

.level-card.locked {
    opacity: 0.6;
    background: #f9fafb;
}

.level-card:not(.locked):hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

/* ============================================
   BADGES & STATS
   ============================================ */

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.stat-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.stat-card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* ============================================
   QUIZ STYLES
   ============================================ */

.quiz-option {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 0.75rem;
}

.quiz-option:hover {
    border-color: #6366f1;
    background: #f5f7ff;
    transform: translateX(4px);
}

.quiz-option.selected {
    border-color: #6366f1;
    background: linear-gradient(135deg, #f5f7ff 0%, #ede9fe 100%);
}

.quiz-option.correct {
    border-color: #10b981;
    background: #d1fae5;
}

.quiz-option.incorrect {
    border-color: #ef4444;
    background: #fee2e2;
}

.quiz-timer {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-weight: 600;
}

/* ============================================
   STREAK INDICATOR
   ============================================ */

.streak-indicator {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: 9999px;
    font-weight: 700;
    color: #92400e;
}

.streak-flame {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ============================================
   BACKGROUND PATTERNS
   ============================================ */

.bg-grid-pattern {
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
}

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */

@media (max-width: 768px) {
    .card-hover:hover {
        transform: none;
    }
    
    .level-card:not(.locked):hover {
        transform: none;
    }
}

/* ============================================
   LOADING SPINNER
   ============================================ */

.spinner {
    border: 3px solid #f3f4f6;
    border-top: 3px solid #6366f1;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */

::-webkit-scrollbar {
    width: 10px;
}

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

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}
