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

:root {
    --primary-color: #4682B4;
    --primary-light: #87CEEB;
    --primary-gradient: linear-gradient(135deg, #87CEEB 0%, #4682B4 100%);
    --text-color: #333;
    --text-light: #666;
    --white: #fff;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    --chatbot-width: 350px;
    --chatbot-height: 500px;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #87CEEB 0%, #4682B4 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
    font-size: 18px;
    line-height: 1.5;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: #4682B4;
}

.nav-logo i {
    font-size: 2rem;
}

.nav-menu {
    display: flex;
    gap: 1rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: #666;
    font-weight: 500;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.nav-btn:hover {
    background: rgba(135, 206, 235, 0.15);
    color: #4682B4;
    transform: translateY(-2px);
}

.nav-btn.active {
    background: linear-gradient(135deg, #87CEEB, #4682B4);
    color: white;
    box-shadow: 0 4px 15px rgba(135, 206, 235, 0.4);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Welcome Screen */
.welcome-screen {
    text-align: center;
    padding: 4rem 2rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.welcome-content h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, #87CEEB, #4682B4);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

.welcome-content p {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 3rem;
}

.welcome-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: linear-gradient(135deg, #B0E0E6 0%, #5F9EA0 100%);
    padding: 2rem;
    border-radius: 15px;
    color: white;
    text-align: center;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-10px);
}

.stat-card i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.stat-card h3 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.start-btn {
    background: linear-gradient(135deg, #87CEEB, #4682B4);
    color: white;
    border: none;
    padding: 1rem 3rem;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

.start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6);
}

/* Sections */
.section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.section.hidden {
    display: none;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f0f0;
}

.section-header h2 {
    font-size: 2rem;
    font-weight: 700;
    color: #333;
}




/* Flashcards */
.controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Allow wrapping of control bar when space is tight */
.section-header .controls {
    flex-wrap: wrap;
    justify-content: flex-start;
}

.control-btn {
    background: linear-gradient(135deg, #87CEEB, #4682B4);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.flashcard-container {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
}

.flashcard {
    width: 100%;
    max-width: 400px;
    height: 300px;
    perspective: 1000px;
    cursor: pointer;
    margin: 0 auto;
    transition: transform 0.6s;
}

.flashcard:hover {
    transform: translateY(-5px);
}

.card-front, .card-back {
    width: 100%;
    height: 100%;
    position: absolute;
    backface-visibility: hidden;
    background: linear-gradient(135deg, #87CEEB, #4682B4);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    word-wrap: break-word;
    hyphens: auto;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
    overflow-wrap: break-word;
}

.card-back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, #ADD8E6, #6495ED);
}

.flashcard.flipped .card-front {
    transform: rotateY(180deg);
    box-shadow: -15px 15px 35px rgba(0, 0, 0, 0.15);
}

.flashcard.flipped .card-back {
    transform: rotateY(0deg);
    box-shadow: 15px 15px 35px rgba(0, 0, 0, 0.15);
}

@keyframes cardSuccess {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.card-success-animation {
    animation: cardSuccess 0.6s ease;
}

.card-front h3, .card-back h3 {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
    word-break: break-word;
}

.card-front p, .card-back p {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    opacity: 0.9;
    line-height: 1.4;
    word-break: break-word;
    max-width: 100%;
}

.example-sentence {
    margin-top: 1rem;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    max-width: 100%;
    overflow: hidden;
}

.example-sentence h4 {
    margin-bottom: 0.5rem;
    font-size: clamp(0.8rem, 2vw, 1rem);
    word-break: break-word;
}

.example-sentence p {
    font-size: clamp(0.7rem, 1.8vw, 0.9rem);
    word-break: break-word;
    line-height: 1.3;
}

.flashcard-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 2rem 0;
}

.action-btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.flip-btn {
    background: linear-gradient(135deg, #FF9966, #FF8C52);
    color: white;
}

.known-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
}

.known-btn:hover {
    background: linear-gradient(135deg, #3d9140, #378137);
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(76, 175, 80, 0.4);
}

.unknown-btn {
    background: linear-gradient(135deg, #f44336, #da190b);
    color: white;
}

.unknown-btn:hover {
    background: linear-gradient(135deg, #e53935, #c62828);
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(244, 67, 54, 0.4);
}

.action-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: transparent;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 2rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #87CEEB, #4682B4);
    width: 0%;
    transition: width 0.3s ease;
}

/* Difficulty Filter & Badges */
.difficulty-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(135,206,235,0.15);
    padding: 0.4rem 0.8rem;
    border-radius: 12px;
    font-size: 0.75rem;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

body.dark .difficulty-filter { 
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.1);
}
.difficulty-filter label {
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #4682B4;
}
.difficulty-filter select {
    border: none;
    background: transparent;
    font-size: 0.8rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    color: #333;
}

.difficulty-badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    background: #ffffff22;
    border: 1px solid #ffffff55;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    position: absolute;
    top: 10px;
    right: 10px;
    color: #fff;
}

.card-back .difficulty-badge {
    display: none;
}

.back-meta {
    margin-top: auto;
    width: 100%;
    display: flex;
    justify-content: flex-end;
}

/* ===================== Responsive Enhancements ===================== */
@media (max-width: 1024px) {
    .main-content { padding: 1.5rem 1.25rem; }
    .welcome-content h1 { font-size: 2.4rem; }
    .question-word { font-size: 2.4rem; }
}

@media (max-width: 820px) {
    .section-header { flex-direction: column; align-items: stretch; gap: 0.75rem; }
    .section-header h2 { width: 100%; }
    .section-header .controls { width: 100%; }
    .section-header .controls > * { flex-shrink: 0; }
    .difficulty-filter { margin-left: auto; }
    .flashcard { height: 260px; }
}

@media (max-width: 600px) {
    body { padding-bottom: env(safe-area-inset-bottom); }
    .navbar { padding: 0.5rem 0; }
    .nav-menu { flex-wrap: wrap; gap: 0.5rem; }
    .nav-btn { padding: 0.55rem 0.9rem; font-size: 0.75rem; }
    .welcome-screen { padding: 2.5rem 1.25rem; }
    .flashcard { max-width: 100%; height: 240px; }
    .card-front h3, .card-back h3 { font-size: clamp(1.4rem, 7vw, 2rem); }
    .card-front p, .card-back p { font-size: clamp(0.8rem, 3.5vw, 1rem); }
    .example-sentence { font-size: 0.75rem; }
    .flashcard-actions { flex-direction: column; gap: 0.75rem; }
    .action-btn { width: 100%; justify-content: center; padding: 0.85rem 1rem; }
    .controls { gap: 0.6rem; }
    .difficulty-filter { order: 4; width: auto; }
    .difficulty-filter select { font-size: 0.7rem; }
    .quiz-options { grid-template-columns: 1fr; }
    .question-word { font-size: 2rem; padding: 1.5rem 1rem; }
}

@media (max-width: 400px) {
    .flashcard { height: 220px; }
    .question-word { font-size: 1.7rem; }
    .difficulty-badge { font-size: 0.55rem; padding: 0.15rem 0.45rem; }
    .difficulty-filter { padding: 0.35rem 0.6rem; }
}

/* ===================== Dark Mode & Theming ===================== */
:root {
    --color-text: #333;
    --color-text-muted: #666;
    --color-bg-start: #87CEEB;
    --color-bg-end: #4682B4;
    --color-surface: rgba(255,255,255,0.95);
    --color-primary: #4682B4;
    --color-primary-accent: #87CEEB;
    --color-shadow: rgba(0,0,0,0.12);
    --color-border: #f0f0f0;
    --gradient-card-front: linear-gradient(135deg, #87CEEB, #4682B4);
    --gradient-card-back: linear-gradient(135deg, #ADD8E6, #6495ED);
}

body.dark {
    --color-text: #e5eef7;
    --color-text-muted: #9db2c5;
    --color-bg-start: #0d1a26;
    --color-bg-end: #162a3f;
    --color-surface: rgba(20,35,50,0.95);
    --color-primary: #5fb3ff;
    --color-primary-accent: #2563eb;
    --color-shadow: rgba(0,0,0,0.55);
    --color-border: #2a3f52;
    --gradient-card-front: linear-gradient(135deg, #2563eb, #1e3a8a);
    --gradient-card-back: linear-gradient(135deg, #1d4ed8, #0f3d91);
}

body {
    background: linear-gradient(135deg, var(--color-bg-start) 0%, var(--color-bg-end) 100%);
    color: var(--color-text);
}

body.dark .nav-btn { color: var(--color-text-muted); }
body.dark .nav-btn.active { background: linear-gradient(135deg, var(--color-primary-accent), var(--color-primary)); }
body.dark .navbar,
body.dark .section,
body.dark .welcome-screen { background: var(--color-surface); box-shadow: 0 4px 24px var(--color-shadow); }
body.dark .section-header h2 { color: var(--color-text); }
body.dark .quiz-stats { color: var(--color-primary); }
body.dark .question-word { background: var(--gradient-card-back); color: #fff; }
body.dark .flashcard .card-front { background: var(--gradient-card-front); }
body.dark .flashcard .card-back { background: var(--gradient-card-back); }
body.dark .progress-fill { background: linear-gradient(135deg, var(--color-primary-accent), var(--color-primary)); }
body.dark .difficulty-filter label { color: var(--color-primary); }
body.dark select, body.dark option { background: var(--color-surface); color: var(--color-text); }

/* Enhanced dark mode styles for quiz and progress sections */
body.dark .option-btn { 
    background: #1a2c3f; 
    color: #e5eef7; 
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
body.dark .option-btn:hover { background: #233850; }
body.dark .option-btn.correct { background: #265c2d; }
body.dark .option-btn.incorrect { background: #6b2025; }
body.dark circle[fill="none"][stroke="#e0e0e0"] { stroke: #1a2c3f; }
body.dark circle#overall-progress[stroke="#4CAF50"] { stroke: #3b8a40; }
body.dark .progress-card { 
    background: #1a2c3f; 
    color: var(--color-text);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
body.dark .stat-display { color: var(--color-primary); }
body.dark .activity-list { background: #1a2c3f; }
body.dark .activity-item { border-color: #2a3f52; }
body.dark .recent-activity h3 { 
    color: #e5eef7; 
    font-weight: 600;
    margin-bottom: 1rem;
}
body.dark .setting-card { 
    background: #1a2c3f; 
    color: var(--color-text);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
body.dark .setting-card h3 {
    color: #ffffff;
    font-weight: 600;
}
body.dark .setting-item { border-color: #2a3f52; }
body.dark .setting-item label { 
    color: #c5d5e6; 
    font-weight: 500;
}
body.dark input[type="checkbox"] { accent-color: var(--color-primary); }
body.dark input[type="text"],
body.dark input[type="password"] { 
    background: rgba(255,255,255,0.05); 
    border: 1px solid #2a3f52;
    color: var(--color-text);
}

/* Links in dark mode */
body.dark a {
    color: #77bdff;
    text-decoration: underline;
    font-weight: 500;
    transition: all 0.3s ease;
}

body.dark a:hover {
    color: #a1d2ff;
    text-decoration: none;
}

/* Improved difficulty badge across themes */
.difficulty-badge {
    background: radial-gradient(circle at top left, rgba(255,255,255,0.4), rgba(255,255,255,0.15));
    border: 1px solid rgba(255,255,255,0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    font-weight: 600;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.difficulty-badge.top-only {
    display: inline-flex;
    top: 10px;
    right: 10px;
    position: absolute;
}
body.dark .difficulty-badge { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.25); }

/* Theme toggle button icon adjustments */
#theme-toggle i { pointer-events: none; }
body.dark #theme-toggle .theme-text { color: var(--color-text-muted); }


/* Quiz */
.quiz-stats {
    display: flex;
    gap: 2rem;
    font-weight: 600;
    color: #4682B4;
}

.quiz-container {
    text-align: center;
}

.quiz-question {
    margin-bottom: 2rem;
}

.question-word {
    font-size: 3rem;
    font-weight: 700;
    color: #4682B4;
    margin: 2rem 0;
    padding: 2rem;
    background: linear-gradient(135deg, #ADD8E6, #6495ED);
    color: white;
    border-radius: 15px;
    display: inline-block;
}

.quiz-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin: 2rem 0;
}

.option-btn {
    padding: 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: 500;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.option-btn:hover {
    border-color: #4682B4;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(70, 130, 180, 0.2);
}

.option-btn.correct {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border-color: #4CAF50;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.option-btn.incorrect {
    background: linear-gradient(135deg, #f44336, #da190b);
    color: white;
    border-color: #f44336;
    box-shadow: 0 4px 15px rgba(244, 67, 54, 0.3);
}

.quiz-feedback {
    margin-top: 2rem;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

body.dark .quiz-feedback {
    background: rgba(26, 44, 63, 0.95);
    color: var(--color-text);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.feedback-content {
    margin-bottom: 1rem;
}

.feedback-content i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feedback-content i.fa-check {
    color: #4CAF50;
}

.feedback-content i.fa-times {
    color: #f44336;
}

.next-btn {
    background: linear-gradient(135deg, #87CEEB, #4682B4);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

body.dark .next-btn {
    background: linear-gradient(135deg, #2563eb, #1e3a8a);
}

.next-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

/* Progress */
.progress-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.progress-card {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.progress-card:hover {
    transform: translateY(-5px);
}

.progress-card h3 {
    margin-bottom: 1rem;
    color: #333;
    font-weight: 600;
    font-size: 1.2rem;
}

body.dark .progress-card h3 {
    color: #e5eef7;
    font-weight: 600;
}

.progress-circle {
    position: relative;
    display: inline-block;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: 700;
    color: #4682B4;
    text-shadow: 0 1px 1px rgba(255,255,255,0.2);
}

body.dark .progress-text {
    color: #77bdff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.stat-display {
    font-size: 2rem;
    font-weight: 700;
    color: #4682B4;
    text-shadow: 0 1px 1px rgba(255,255,255,0.2);
}

body.dark .stat-display {
    color: #77bdff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.activity-list {
    background: white;
    border-radius: 15px;
    padding: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

body.dark .activity-list {
    background: #1a2c3f;
}

body.dark .activity-item {
    color: #c5d5e6;
}

/* Settings */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.setting-card {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.setting-card h3 {
    margin-bottom: 1.5rem;
    color: #333;
    font-weight: 600;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.setting-item label {
    font-weight: 500;
    color: #444;
}

.setting-item select,
.setting-item input[type="checkbox"] {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

body.dark .setting-item select {
    background-color: #263b50;
    border: 1px solid #36516d;
    color: #e5eef7;
}

.setting-btn {
    width: 100%;
    padding: 1rem;
    margin-bottom: 1rem;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #87CEEB, #4682B4);
    color: white;
}

body.dark .setting-btn {
    background: linear-gradient(135deg, #2563eb, #1e3a8a);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.setting-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.setting-btn.danger {
    background: linear-gradient(135deg, #f44336, #da190b);
}

body.dark .setting-btn.danger {
    background: linear-gradient(135deg, #e53935, #c62828);
}

.setting-btn.danger:hover {
    box-shadow: 0 5px 15px rgba(244, 67, 54, 0.3);
}

/* API Key Integration Styles */
.api-key-container {
    flex-direction: column;
    align-items: stretch;
}

.api-key-input-group {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
    align-items: stretch;
    flex-wrap: wrap;
}

.api-key-input-group input {
    flex: 1;
    min-width: 200px;
    padding: 0.875rem 1rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.api-key-input-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(70, 130, 180, 0.1), 0 2px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.icon-button:focus,
.primary-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(70, 130, 180, 0.2), 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.dark .api-key-input-group input {
    background-color: #263b50;
    border-color: #36516d;
    color: #e5eef7;
}

.icon-button {
    padding: 0.875rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 48px;
    font-size: 1.1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.icon-button:hover {
    background: #f8f9fa;
    border-color: var(--color-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

body.dark .icon-button {
    background: #263b50;
    border-color: #36516d;
    color: #e5eef7;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

body.dark .icon-button:hover {
    background: #324964;
    border-color: var(--color-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.primary-button {
    padding: 0.875rem 1.25rem;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--color-primary-accent), var(--color-primary));
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 48px;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    box-shadow: 0 2px 6px rgba(70, 130, 180, 0.2);
    white-space: nowrap;
}

.primary-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(70, 130, 180, 0.4);
    background: linear-gradient(135deg, #5ba3d4, #3a7bc8);
}

.primary-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(70, 130, 180, 0.2);
}

.validation-message {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: clamp(0.85rem, 2.2vw, 0.95rem);
    line-height: 1.4;
    font-weight: 500;
}

.validation-message.success {
    background: rgba(76, 175, 80, 0.1);
    color: #4caf50;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.validation-message.error {
    background: rgba(244, 67, 54, 0.1);
    color: #f44336;
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.api-key-info {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding: 1.25rem;
    background: rgba(70, 130, 180, 0.08);
    border-radius: 12px;
    font-size: clamp(0.85rem, 2.2vw, 0.95rem);
    border: 1px solid rgba(70, 130, 180, 0.15);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.api-key-info i {
    color: var(--color-primary);
    margin-top: 0.1rem;
}

.highlight-link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
}

.highlight-link:hover {
    text-decoration: underline;
}

/* Enhanced Responsive Design */
/* Small devices (landscape phones, 576px and up) */
@media (max-width: 576px) {
    .main-content {
        padding: 1rem;
    }
    
    .nav-container {
        padding: 0.5rem 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .nav-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
    
    .welcome-content h1 {
        font-size: 1.8rem;
    }
    
    .welcome-content p {
        font-size: 1rem;
    }
    
    .flashcard {
        max-width: 300px;
        height: 250px;
    }
    
    .question-word {
        font-size: 2rem;
        padding: 1rem;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .main-content {
        padding: 1.5rem;
    }
    
    .welcome-content h1 {
        font-size: 2.2rem;
    }
    
    .welcome-stats {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1.5rem;
    }
    
    .flashcard {
        width: 100%;
        max-width: 350px;
        height: 280px;
        margin: 0 auto;
    }
    
    .card-front, .card-back {
        padding: 1rem;
    }
    
    .card-front h3, .card-back h3 {
        font-size: clamp(1.5rem, 5vw, 2rem);
        margin-bottom: 0.8rem;
    }
    
    .card-front p, .card-back p {
        font-size: clamp(0.8rem, 3vw, 1rem);
    }
    
    .example-sentence {
        padding: 0.6rem;
        margin-top: 0.8rem;
    }
    
    .quiz-options {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }
    
    .quiz-option {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    .progress-grid {
        grid-template-columns: 1fr;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .setting-card {
        padding: 1.5rem;
        border-radius: 12px;
    }
    
    .setting-card h3 {
        font-size: clamp(1.1rem, 4vw, 1.3rem);
        margin-bottom: 1rem;
    }
    
    .setting-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 0.75rem 0;
    }
    
    .setting-item label {
        font-size: clamp(0.9rem, 3.5vw, 1rem);
        font-weight: 500;
    }
    
    .setting-item select {
        width: 100%;
        padding: 0.75rem;
        font-size: clamp(0.9rem, 3.5vw, 1rem);
        border-radius: 8px;
        min-height: 44px;
    }
    
    .api-key-input-group {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
        align-items: stretch;
    }
    
    .api-key-input-group input {
        width: 100%;
        min-height: 52px;
        font-size: 1rem;
        padding: 1rem;
        border-radius: 12px;
    }
    
    .primary-button,
    .icon-button {
        min-height: 52px;
        font-size: 1rem;
        border-radius: 12px;
    }
    
    .primary-button {
        padding: 1rem 1.5rem;
        justify-content: center;
    }
    
    .icon-button {
        min-width: 52px;
        align-self: flex-end;
        touch-action: manipulation;
    }
    
    /* Improve touch targets for mobile */
    .api-key-input-group input,
    .primary-button,
    .icon-button {
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(70, 130, 180, 0.1);
    }
    
    /* Better visual feedback on touch */
    .primary-button:active,
    .icon-button:active {
        transform: scale(0.98);
        transition-duration: 0.1s;
    }
    
    .api-key-info {
        font-size: clamp(0.8rem, 3vw, 0.9rem);
        padding: 1rem;
        border-radius: 10px;
    }
}

/* Tablet and large phone optimization */
@media (min-width: 481px) and (max-width: 768px) {
    .api-key-input-group {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .api-key-input-group input {
        flex: 1;
        min-width: 250px;
        min-height: 50px;
    }
    
    .icon-button,
    .primary-button {
        min-height: 50px;
        flex-shrink: 0;
    }
    
    .primary-button {
        min-width: 120px;
    }
    
    .flashcard-actions {
        flex-direction: column;
        align-items: center;
        gap: 0.8rem;
    }
    
    .action-btn {
        width: 100%;
        max-width: 250px;
        padding: 0.8rem 1.5rem;
    }
    
    .controls {
        justify-content: center;
        margin-bottom: 1rem;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .flashcard {
        max-width: 450px;
        height: 320px;
    }
    
    .quiz-options {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section {
    animation: fadeIn 0.5s ease;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.flashcard:hover {
    animation: pulse 0.3s ease;
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #87CEEB, #4682B4);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5F9EA0, #2F4F4F);
}

/* Dark mode scrollbar */
body.dark ::-webkit-scrollbar-track {
    background: #1a2c3f;
}

body.dark ::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #2563eb, #1e3a8a);
}

body.dark ::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #1d4ed8, #0f3d91);
}

/* API Key Prompt */
.api-key-prompt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.prompt-content {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

body.dark .prompt-content {
    background: #1a2c3f;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.prompt-content h3 {
    color: #4682B4;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

body.dark .prompt-content h3 {
    color: #5fb3ff;
}

.prompt-content p {
    margin-bottom: 1.5rem;
    color: #666;
}

body.dark .prompt-content p {
    color: #9db2c5;
}

.prompt-content input {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    margin-bottom: 1.5rem;
    transition: border-color 0.3s ease;
}

.prompt-content input:focus {
    outline: none;
    border-color: #4682B4;
}

.prompt-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.btn-primary, .btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #87CEEB, #4682B4);
    color: white;
}

.btn-secondary {
    background: #f0f0f0;
    color: #666;
}

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

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

.api-help {
    font-size: 0.9rem;
    color: #999;
}

body.dark .api-help {
    color: #8a9baf;
}

.api-help a {
    color: #4682B4;
    text-decoration: none;
}

.api-help a:hover {
    text-decoration: underline;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

body.dark .loading-content {
    background: #1a2c3f;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4682B4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.loading-content p {
    color: #666;
    font-size: 1.1rem;
    margin: 0;
}

body.dark .loading-content p {
    color: #9db2c5;
}

/* Dark mode spinner */
body.dark .spinner {
    border: 4px solid #1a2c3f;
    border-top: 4px solid #5fb3ff;
}
