/* English Adventure - Custom Styles */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

body {
    font-family: 'Nunito', sans-serif;
    position: relative;
}

/* Subtle background pattern (CSS only - dots) */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image:
        radial-gradient(circle, rgba(139, 92, 246, 0.06) 1.5px, transparent 1.5px),
        radial-gradient(circle, rgba(59, 130, 246, 0.05) 1px, transparent 1px);
    background-size: 32px 32px, 20px 20px;
    background-position: 0 0, 10px 10px;
}

body > * {
    position: relative;
    z-index: 1;
}

[x-cloak] {
    display: none !important;
}

/* Top accent gradient bar */
.top-accent-bar {
    height: 4px;
    background: linear-gradient(90deg, #f472b6, #a78bfa, #60a5fa, #34d399, #fbbf24, #f472b6);
    background-size: 200% 100%;
    animation: gradientSlide 4s linear infinite;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

@keyframes gradientSlide {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

/* Dragon video */
.dragon-video {
    border-radius: 1rem;
    max-width: 200px;
}

/* Animations */
@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

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

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(59, 130, 246, 0.5); }
    50% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.8); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

@keyframes sparkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.95); }
}

@keyframes shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

@keyframes rainbow-glow {
    0% { box-shadow: 0 0 8px rgba(244, 114, 182, 0.6); }
    25% { box-shadow: 0 0 12px rgba(167, 139, 250, 0.6); }
    50% { box-shadow: 0 0 12px rgba(96, 165, 250, 0.6); }
    75% { box-shadow: 0 0 12px rgba(52, 211, 153, 0.6); }
    100% { box-shadow: 0 0 8px rgba(244, 114, 182, 0.6); }
}

@keyframes dragonBob {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-6px) rotate(2deg); }
    75% { transform: translateY(-3px) rotate(-1deg); }
}

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

@keyframes lockPulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.1); opacity: 1; }
}

.animate-bounce-in { animation: bounceIn 0.6s ease-out; }
.animate-slide-up { animation: slideUp 0.4s ease-out; }
.animate-pulse-glow { animation: pulse-glow 2s infinite; }
.animate-shake { animation: shake 0.5s ease-in-out; }
.animate-fade-in { animation: fadeIn 0.3s ease-out; }
.animate-wiggle { animation: wiggle 1s ease-in-out infinite; }
.animate-float { animation: float 3s ease-in-out infinite; }
.animate-pop { animation: pop 0.3s ease-out; }
.animate-sparkle { animation: sparkle 2s ease-in-out infinite; }
.animate-dragon-bob { animation: dragonBob 4s ease-in-out infinite; }
.animate-slide-in-left { animation: slideInLeft 0.5s ease-out; }

/* Exercise cards */
.option-btn {
    transition: all 0.2s ease;
}
.option-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.option-btn:active:not(:disabled) {
    transform: translateY(0);
}

/* Word chips for ordering exercise */
.word-chip {
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
}
.word-chip:hover {
    transform: scale(1.05);
}
.word-chip.selected {
    opacity: 0.4;
    pointer-events: none;
}

/* Flashcard */
.flashcard {
    perspective: 1000px;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.flashcard:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.2);
}
.flashcard-inner {
    transition: transform 0.6s;
    transform-style: preserve-3d;
    position: relative;
}
.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}
.flashcard-front, .flashcard-back {
    backface-visibility: hidden;
}
.flashcard-back {
    transform: rotateY(180deg);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Progress bar animation */
.progress-bar {
    transition: width 0.5s ease-in-out;
}

/* Matching exercise */
.match-item {
    transition: all 0.2s ease;
    cursor: pointer;
}
.match-item:hover:not(.matched) {
    transform: scale(1.03);
}
.match-item.selected {
    ring: 3px;
    transform: scale(1.05);
}
.match-item.matched {
    opacity: 0.6;
    pointer-events: none;
}

/* Streak fire */
.streak-fire {
    display: inline-block;
    border-radius: 50%;
}

/* Chat assistant action buttons */
.chat-assistant-actions {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    max-width: 100%;
}

.chat-assistant-action-btn {
    flex: 0 0 auto;
}

.chat-scroll-hidden {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.chat-scroll-hidden::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.chat-message-row {
    width: 100%;
    min-width: 0;
}

.chat-message-bubble {
    min-width: 0;
}

.chat-message-bubble-user {
    max-width: 80%;
}

.chat-message-bubble-assistant {
    max-width: 75%;
}

.chat-message-bubble-with-inline-actions {
    max-width: calc(100% - 13rem);
}

.chat-message-bubble-with-inline-actions-admin {
    max-width: calc(100% - 16rem);
}

.chat-message-bubble-with-delete {
    max-width: calc(100% - 3.5rem);
}

.chat-assistant-actions-inline {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.375rem;
}

.chat-assistant-actions-delete-only {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start;
    gap: 0;
}

.chat-assistant-actions-inline .chat-assistant-action-translate {
    grid-column: auto !important;
    justify-self: auto !important;
}

@media (min-width: 768px) {
    .chat-assistant-actions {
        display: grid;
        grid-template-columns: repeat(2, 2.5rem);
        gap: 0.375rem;
        align-items: start;
    }

    .chat-assistant-action-translate {
        grid-column: 1 / span 2;
        justify-self: center;
    }
}

/* Logro notification */
.logro-popup {
    animation: bounceIn 0.6s ease-out, fadeIn 0.3s ease-out;
}

/* Admin user selector */
.user-tab {
    background-color: #f3f4f6;
    color: #4b5563;
}
.user-tab:hover {
    background-color: #e5e7eb;
}
.active-user-tab {
    background: linear-gradient(135deg, #14b8a6, #3b82f6) !important;
    color: white !important;
}

/* Custom tooltips (default: above) */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    background: #1e293b;
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    border: 6px solid transparent;
    border-top-color: #1e293b;
    pointer-events: none;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 999;
}
[data-tooltip]:hover::after,
[data-tooltip]:hover::before,
[data-tooltip]:active::after,
[data-tooltip]:active::before,
[data-tooltip]:focus::after,
[data-tooltip]:focus::before {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}
/* Tooltip below (for elements near top of screen like nav) */
[data-tooltip-pos="bottom"]::after {
    bottom: auto;
    top: calc(100% + 10px);
}
[data-tooltip-pos="bottom"]::before {
    bottom: auto;
    top: calc(100% + 4px);
    border-top-color: transparent;
    border-bottom-color: #1e293b;
}

/* Nav link active state */
.nav-link-active {
    background: linear-gradient(135deg, #0ea5e9, #6366f1);
    color: white;
}

/* === Fun Kid Styles === */

/* User profile card */
.user-card {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.user-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent, rgba(244, 114, 182, 0.1), transparent, rgba(167, 139, 250, 0.1), transparent);
    animation: rotate 6s linear infinite;
    opacity: 0;
    transition: opacity 0.3s;
}
.user-card:hover::before {
    opacity: 1;
}
@keyframes rotate {
    100% { transform: rotate(360deg); }
}
.user-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(139, 92, 246, 0.15);
}

/* Welcome banner on dashboard */
.welcome-banner {
    background: linear-gradient(135deg, #fdf2f8, #ede9fe, #dbeafe);
    border: 2px solid rgba(167, 139, 250, 0.2);
    position: relative;
    overflow: hidden;
}
.welcome-banner::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(135deg, transparent 40%, rgba(244, 114, 182, 0.05) 50%, transparent 60%);
    background-size: 200% 200%;
    animation: shimmer 3s linear infinite;
    pointer-events: none;
}

/* Stats cards */
.stat-card {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}
.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 0 0 1rem 1rem;
}
.stat-card-amber::after { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.stat-card-blue::after { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.stat-card-emerald::after { background: linear-gradient(90deg, #10b981, #34d399); }

/* Unit header (collapsible) */
.unit-header {
    transition: all 0.3s ease;
    cursor: pointer;
    user-select: none;
    overflow: visible;
    position: relative;
    z-index: 2;
}
.unit-header:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.15);
}

/* Lesson card styles */
.lesson-card {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.lesson-card-unlocked:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.2);
}
.lesson-card-completed {
    border-left: 4px solid #10b981;
}
.lesson-card-available {
    border-left: 4px solid #3b82f6;
    animation: lessonUnlock 0.6s ease-out;
}
@keyframes lessonUnlock {
    0% { transform: scale(0.95); opacity: 0; box-shadow: 0 0 0 rgba(59, 130, 246, 0); }
    50% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.3); }
    100% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 rgba(59, 130, 246, 0); }
}

/* Unlock celebration animations */
@keyframes unlockGlow {
    0% { box-shadow: 0 0 0 rgba(251, 191, 36, 0); transform: scale(0.8); opacity: 0; }
    30% { box-shadow: 0 0 30px rgba(251, 191, 36, 0.6); transform: scale(1.05); opacity: 1; }
    60% { box-shadow: 0 0 50px rgba(139, 92, 246, 0.4); transform: scale(0.98); }
    100% { box-shadow: 0 0 0 rgba(251, 191, 36, 0); transform: scale(1); opacity: 1; }
}
@keyframes unlockStars {
    0% { opacity: 0; transform: scale(0) rotate(0deg); }
    50% { opacity: 1; transform: scale(1.3) rotate(180deg); }
    100% { opacity: 1; transform: scale(1) rotate(360deg); }
}
.unlock-celebration {
    animation: unlockGlow 1.2s ease-out;
}
.unlock-stars::after {
    content: '✨';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 24px;
    animation: unlockStars 0.8s ease-out;
    z-index: 5;
}
.unlock-new {
    position: relative;
}
.unlock-new::before {
    content: '¡NUEVO!';
    position: absolute;
    top: -8px;
    right: 10px;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 8px;
    z-index: 5;
    animation: bounceIn 0.6s ease-out, float 2s ease-in-out infinite 0.6s;
}

/* Unlock toast notification */
@keyframes toastSlideIn {
    0% { transform: translateX(-50%) translateY(-30px); opacity: 0; }
    15% { transform: translateX(-50%) translateY(0); opacity: 1; }
    85% { transform: translateX(-50%) translateY(0); opacity: 1; }
    100% { transform: translateX(-50%) translateY(-30px); opacity: 0; }
}
.unlock-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    padding: 12px 24px;
    border-radius: 16px;
    font-weight: 800;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 30px rgba(245, 158, 11, 0.4);
    z-index: 9999;
    animation: toastSlideIn 3.5s ease-in-out forwards;
    white-space: nowrap;
}
.unlock-toast-icon {
    font-size: 24px;
    animation: wiggle 1s ease-in-out infinite;
}
.lesson-card-failed {
    border-left: 4px solid #f59e0b;
}

/* Locked lesson styling */
.lesson-card-locked {
    position: relative;
    border-left: 4px solid transparent;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
}
.lesson-card-locked::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 10px,
        rgba(148, 163, 184, 0.03) 10px,
        rgba(148, 163, 184, 0.03) 20px
    );
    pointer-events: none;
    border-radius: inherit;
}

/* Lock icon animation */
.lock-icon {
    animation: lockPulse 3s ease-in-out infinite;
    display: inline-block;
}

/* Achievement styles */
.achievement-card {
    transition: all 0.3s ease;
    position: relative;
}
.achievement-card:hover {
    transform: translateY(-3px);
}
.achievement-unlocked {
    background: linear-gradient(135deg, #fdf2f8, #fef3c7, #dbeafe);
    border: 2px solid rgba(251, 191, 36, 0.3);
}
.achievement-unlocked:hover {
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.3);
}
.achievement-unlocked .achievement-icon {
    animation: float 3s ease-in-out infinite;
}
.achievement-glow {
    animation: rainbow-glow 3s linear infinite;
}
.achievement-locked {
    filter: grayscale(0.8);
    opacity: 0.5;
    border: 2px dashed rgba(148, 163, 184, 0.3);
}
.achievement-locked:hover {
    filter: grayscale(0.5);
    opacity: 0.7;
}
.achievement-locked .achievement-icon {
    filter: blur(1px);
}

/* Vocabulary category header */
.vocab-category-header {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    margin-bottom: 0.75rem;
}

/* Vocab flashcard enhancements */
.vocab-card {
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.vocab-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 12px 30px rgba(139, 92, 246, 0.15);
}

/* Talk with Drako card */
.drako-talk-card {
    position: relative;
    overflow: hidden;
}
.drako-talk-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shimmer 3s linear infinite;
}

/* Image lightbox zoom */
@keyframes lightboxZoom {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Character images are clickable (lightbox), except in nav/links */
img[src*="/recursos/personajes/"] {
    cursor: zoom-in;
}
nav img[src*="/recursos/personajes/"],
a img[src*="/recursos/personajes/"] {
    cursor: pointer;
}

/* Emoji rendering fix */
.emoji-display {
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif;
    font-style: normal;
    line-height: 1;
}

/* Unit chevron rotation */
.unit-chevron {
    transition: transform 0.3s ease;
}
.unit-open .unit-chevron {
    transform: rotate(180deg);
}

/* Stagger animation for lesson cards within a unit */
.lesson-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.lesson-stagger > *:nth-child(2) { animation-delay: 0.1s; }
.lesson-stagger > *:nth-child(3) { animation-delay: 0.15s; }
.lesson-stagger > *:nth-child(4) { animation-delay: 0.2s; }
.lesson-stagger > *:nth-child(5) { animation-delay: 0.25s; }

/* ============================================ */
/* Dark Mode                                    */
/* ============================================ */
.dark body::before {
    background-image:
        radial-gradient(circle, rgba(139, 92, 246, 0.08) 1.5px, transparent 1.5px),
        radial-gradient(circle, rgba(59, 130, 246, 0.06) 1px, transparent 1px);
}

/* Cards */
.dark .bg-white { background-color: #1e293b !important; }
.dark .bg-white\/80 { background-color: rgba(30, 41, 59, 0.9) !important; }
.dark .shadow { box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important; }
.dark .shadow-lg { box-shadow: 0 4px 15px rgba(0,0,0,0.4) !important; }

/* Text */
.dark .text-gray-800 { color: #e2e8f0 !important; }
.dark .text-gray-700 { color: #cbd5e1 !important; }
.dark .text-gray-600 { color: #94a3b8 !important; }
.dark .text-gray-500 { color: #64748b !important; }
.dark .text-gray-400 { color: #475569 !important; }
.dark .text-gray-300 { color: #475569 !important; }

/* Backgrounds */
.dark .bg-gray-50 { background-color: #334155 !important; }
.dark .bg-gray-100 { background-color: #374151 !important; }
.dark .bg-gray-200 { background-color: #4b5563 !important; }

/* Colored backgrounds - softer in dark */
.dark .bg-amber-50 { background-color: rgba(251, 191, 36, 0.1) !important; }
.dark .bg-orange-50 { background-color: rgba(251, 146, 60, 0.1) !important; }
.dark .bg-blue-50 { background-color: rgba(59, 130, 246, 0.1) !important; }
.dark .bg-emerald-50 { background-color: rgba(16, 185, 129, 0.1) !important; }
.dark .bg-red-50 { background-color: rgba(239, 68, 68, 0.1) !important; }
.dark .bg-purple-50 { background-color: rgba(139, 92, 246, 0.1) !important; }

/* Borders */
.dark .border-gray-200 { border-color: #374151 !important; }
.dark .border-gray-300 { border-color: #4b5563 !important; }

/* Welcome banner */
.dark .welcome-banner {
    background: linear-gradient(135deg, #1e1b4b, #1e293b, #0f172a) !important;
    border-color: rgba(139, 92, 246, 0.3) !important;
}

/* Lesson cards */
.dark .lesson-card-locked {
    background: linear-gradient(135deg, #1e293b, #0f172a) !important;
}

/* Achievements */
.dark .achievement-unlocked {
    background: linear-gradient(135deg, #1e1b4b, #422006, #172554) !important;
}
.dark .achievement-locked {
    border-color: rgba(75, 85, 99, 0.3) !important;
}

/* Stat cards */
.dark .stat-card { background-color: #1e293b !important; }

/* Input fields */
.dark input[type="text"],
.dark input:not([type]) {
    background-color: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}
.dark input::placeholder { color: #64748b !important; }

/* Flashcard back */
.dark .flashcard-back {
    background: linear-gradient(135deg, #1e293b, #0f172a) !important;
}

/* Chat messages */
.dark .from-blue-50 { --tw-gradient-from: #1e293b !important; }
.dark .to-indigo-50 { --tw-gradient-to: #1e1b4b !important; }

/* Mobile dropdown */
.dark .border-t { border-color: #374151 !important; }

/* Nav link active - keep as is, looks good in dark */
