/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #f8fafc;
    color: #1e293b;
    line-height: 1.6;
    min-height: 100vh;
}

#app {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
}

/* ===== HEADER ===== */
.header {
    text-align: center;
    margin-bottom: 32px;
}

.header .logo {
    font-size: 48px;
    margin-bottom: 8px;
}

.header h1 {
    font-size: 32px;
    font-weight: 800;
    color: #1e293b;
}

.header p {
    color: #64748b;
    margin-top: 8px;
    font-size: 16px;
}

/* ===== CARDS ===== */
.card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.card h2 {
    color: #1e293b;
    margin-bottom: 16px;
    font-size: 18px;
}

.card h3 {
    margin: 0 0 16px 0;
    color: #1e293b;
    font-size: 16px;
}

/* ===== LANGUAGE SELECTOR ===== */
.lang-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.lang-btn {
    padding: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 15px;
    font-weight: 600;
    color: #334155;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.lang-btn:hover {
    border-color: #1d4ed8;
    background: #eff6ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(29,78,216,0.15);
}

.lang-btn .flag {
    font-size: 32px;
}

/* ===== TOP BAR ===== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.lang-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#current-lang {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
}

.level-badge {
    padding: 4px 12px;
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.stats {
    display: flex;
    gap: 16px;
    align-items: center;
}

.stat {
    font-size: 14px;
    color: #64748b;
}

/* ===== PROGRESS ===== */
.progress-card {
    padding: 16px 20px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.progress-label {
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
}

.progress-value {
    font-size: 13px;
    color: #1d4ed8;
    font-weight: 600;
}

.progress-track {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

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

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.tab-btn {
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    background: #e2e8f0;
    color: #64748b;
    transition: all 0.2s;
    font-size: 14px;
}

.tab-btn.active {
    background: #1d4ed8;
    color: white;
}

.tab-btn:hover:not(.active) {
    background: #cbd5e1;
}

/* ===== PANELS ===== */
.panel {
    display: none;
}

.panel.active {
    display: block;
}

/* ===== SCENARIOS ===== */
.scenario-grid {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.scenario-btn {
    padding: 10px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #334155;
    transition: all 0.2s;
}

.scenario-btn:hover,
.scenario-btn.active {
    border-color: #1d4ed8;
    background: #eff6ff;
    color: #1d4ed8;
}

/* ===== CHAT ===== */
.chat-card {
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    margin-bottom: 12px;
    font-size: 15px;
    line-height: 1.5;
}

.message-bot {
    background: #f1f5f9;
    color: #1e293b;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message-bot .bot-text {
    font-weight: 600;
    margin-bottom: 4px;
}

.message-bot .translation {
    font-size: 13px;
    color: #64748b;
}

.message-user {
    background: #1d4ed8;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

.response-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-btn {
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    text-align: left;
    font-size: 15px;
    color: #334155;
    transition: all 0.2s;
    font-weight: 500;
    font-family: inherit;
}

.option-btn:hover {
    border-color: #1d4ed8;
    background: #eff6ff;
}

.option-btn .opt-text {
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

.option-btn .opt-trans {
    font-size: 13px;
    color: #64748b;
}

/* ===== FLASHCARDS ===== */
.flashcard-container {
    perspective: 1000px;
    max-width: 400px;
    margin: 0 auto;
}

.flashcard {
    width: 100%;
    height: 240px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.6s, background 0.3s;
    position: relative;
    color: white;
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(102,126,234,0.3);
    user-select: none;
}

.flashcard:hover {
    transform: scale(1.02);
}

.flashcard .card-word {
    font-size: 32px;
}

.flashcard .card-translation {
    font-size: 22px;
}

.flashcard .card-example {
    font-size: 14px;
    margin-top: 12px;
    opacity: 0.9;
}

.flashcard-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

.btn-hard {
    padding: 10px 24px;
    background: #fee2e2;
    color: #dc2626;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-hard:hover {
    background: #fecaca;
}

.btn-easy {
    padding: 10px 24px;
    background: #dcfce7;
    color: #16a34a;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-easy:hover {
    background: #bbf7d0;
}

.card-counter {
    text-align: center;
    margin-top: 16px;
    color: #64748b;
    font-size: 14px;
}

/* ===== GRAMMAR ===== */
.grammar-question {
    font-size: 18px;
    color: #1e293b;
    margin-bottom: 20px;
    padding: 16px;
    background: #f1f5f9;
    border-radius: 12px;
}

.grammar-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.grammar-feedback {
    margin-top: 16px;
    padding: 12px;
    border-radius: 10px;
    display: none;
    font-weight: 600;
}

.grammar-feedback.correct {
    background: #dcfce7;
    color: #16a34a;
    display: block;
}

.grammar-feedback.incorrect {
    background: #fee2e2;
    color: #dc2626;
    display: block;
}

/* ===== LISTENING ===== */
.audio-player {
    text-align: center;
    padding: 40px;
}

.play-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #1d4ed8;
    color: white;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(29,78,216,0.3);
    margin-bottom: 20px;
    transition: all 0.2s;
}

.play-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(29,78,216,0.4);
}

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

.audio-player p {
    color: #64748b;
    margin: 0;
}

.listening-question {
    font-size: 16px;
    color: #1e293b;
    margin: 20px 0;
    text-align: center;
    font-weight: 500;
}

.listening-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.listening-feedback {
    margin-top: 16px;
    padding: 12px;
    border-radius: 10px;
    display: none;
    font-weight: 600;
}

.listening-feedback.correct {
    background: #dcfce7;
    color: #16a34a;
    display: block;
}

.listening-feedback.incorrect {
    background: #fee2e2;
    color: #dc2626;
    display: block;
}

/* ===== BUTTONS ===== */
.btn-primary {
    padding: 14px 32px;
    background: #1d4ed8;
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    width: 100%;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #1e40af;
    transform: translateY(-1px);
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 24px;
    padding: 40px;
    max-width: 400px;
    text-align: center;
    animation: popIn 0.3s ease;
    width: 100%;
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-emoji {
    font-size: 64px;
    margin-bottom: 16px;
}

.modal-content h2 {
    color: #1e293b;
    margin: 0 0 8px 0;
    font-size: 24px;
}

.modal-content p {
    color: #64748b;
    margin-bottom: 24px;
}

.modal-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 24px;
}

.modal-stat {
    text-align: center;
}

.modal-stat-value {
    font-size: 28px;
    font-weight: 800;
    color: #1d4ed8;
}

.modal-stat-label {
    font-size: 12px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    #app {
        padding: 16px;
    }

    .header h1 {
        font-size: 24px;
    }

    .top-bar {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .tabs {
        gap: 6px;
    }

    .tab-btn {
        padding: 8px 14px;
        font-size: 13px;
    }

    .flashcard {
        height: 200px;
        font-size: 22px;
    }

    .message-bubble {
        max-width: 90%;
        font-size: 14px;
    }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}


/* ===== AI COMPANION ===== */
.companion-message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
  background: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
  border-radius: 16px;
  border-left: 4px solid #3b82f6;
  animation: slideIn 0.4s ease;
  transition: opacity 0.3s ease;
}

.companion-message.companion-tip {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-left-color: #f59e0b;
  margin: 12px 0;
}

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

.companion-avatar {
  font-size: 32px;
  flex-shrink: 0;
  animation: bounce 2s infinite;
}

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

.companion-bubble {
  flex: 1;
}

.companion-name {
  font-size: 13px;
  font-weight: 700;
  color: #1d4ed8;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.companion-tip .companion-name {
  color: #d97706;
}

.companion-text {
  font-size: 14px;
  color: #334155;
  line-height: 1.5;
}

/* ===== SCENARIO COMPLETION CELEBRATION ===== */
.celebration {
  animation: celebrate 0.6s ease;
}

@keyframes celebrate {
  0% { transform: scale(1); }
  25% { transform: scale(1.05); }
  50% { transform: scale(0.98); }
  75% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

/* ===== STREAK ANIMATION ===== */
@keyframes flame {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.stat:has(🔥) {
  animation: flame 1s ease infinite;
}

/* ===== XP GAIN ANIMATION ===== */
.xp-gain {
  animation: xpPop 0.5s ease;
}

@keyframes xpPop {
  0% { transform: scale(1); color: #1d4ed8; }
  50% { transform: scale(1.3); color: #fbbf24; }
  100% { transform: scale(1); color: #1d4ed8; }
}
