/* JadeSteps - Premium Light Theme */
/* Glassmorphism, transparency, refined aesthetics */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #00a86b;
    --primary-light: #2ecc71;
    --primary-dark: #008f5e;
    --secondary: #5dade2;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;

    /* Light glass colors */
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(0, 0, 0, 0.08);
    --glass-highlight: rgba(0, 0, 0, 0.12);

    /* Text */
    --text-primary: #1a1a2e;
    --text-secondary: rgba(26, 26, 46, 0.7);
    --text-muted: rgba(26, 26, 46, 0.45);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.15);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 40%, #dee2e6 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Subtle background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(0, 168, 107, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(93, 173, 226, 0.06) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(46, 204, 113, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

.chinese-text, .char-display, .large-char {
    font-family: 'Noto Sans SC', serif;
}

/* Glass utility */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
}

/* Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border-bottom: 1px solid var(--glass-border);
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.logo-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 2px 4px rgba(0, 168, 107, 0.3));
}

.logo h1 {
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.main-nav {
    display: flex;
    gap: 0.25rem;
    padding: 4px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.03);
}

.nav-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-btn:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.06);
}

.nav-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 168, 107, 0.3);
}

/* Main Content */
main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem;
}

.view {
    display: none;
    animation: fadeIn var(--transition-normal);
}

.view.active {
    display: block;
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.75rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.25rem;
    transition: all var(--transition-normal);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--glass-highlight);
}

.card h2 {
    font-size: 1.3rem;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
    font-weight: 600;
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
}

.stats-row {
    display: flex;
    justify-content: space-around;
    gap: 1rem;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.02);
    flex: 1;
}

.stat-number {
    display: block;
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.25rem;
}

/* Level Progress */
.level-bars .level-bar {
    margin-bottom: 1rem;
}

.level-bar-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
}

.bar-track {
    height: 10px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 6px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -100%;
    width: 60%;
    height: 200%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.15) 40%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0.15) 60%,
        transparent 100%
    );
    transform: rotate(25deg);
    transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:hover::before {
    left: 150%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    box-shadow: 0 4px 16px rgba(0, 168, 107, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 168, 107, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #3498db, var(--secondary));
    color: white;
    box-shadow: 0 4px 16px rgba(52, 152, 219, 0.25);
}

.btn-success {
    background: linear-gradient(135deg, #27ae60, var(--success));
    color: white;
    box-shadow: 0 4px 16px rgba(46, 204, 113, 0.25);
}

.btn-warning {
    background: linear-gradient(135deg, #e67e22, var(--warning));
    color: white;
    box-shadow: 0 4px 16px rgba(243, 156, 18, 0.25);
}

.btn-info {
    background: linear-gradient(135deg, #2980b9, #3498db);
    color: white;
    box-shadow: 0 4px 16px rgba(41, 128, 185, 0.25);
}

.btn-small {
    padding: 0.45rem 1rem;
    font-size: 0.85rem;
    border-radius: 999px;
}

.audio-btn {
    background: linear-gradient(135deg, #6c757d, #adb5bd);
    color: white;
    margin-top: 1rem;
    box-shadow: 0 4px 16px rgba(108, 117, 125, 0.25);
    min-width: 100px;
}

/* Forms */
.form-control {
    padding: 0.75rem 1rem;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    font-size: 0.95rem;
    width: 100%;
    max-width: 320px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-primary);
    backdrop-filter: blur(10px);
    transition: all var(--transition-fast);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 3px rgba(0, 168, 107, 0.15);
}

/* Flashcards */
.flashcard-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    align-items: center;
    flex-wrap: wrap;
}

.progress-bar-container {
    position: relative;
    height: 8px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 6px;
    margin-bottom: 2rem;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #27ae60);
    border-radius: 6px;
    transition: width 0.4s ease;
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.4);
}

#fc-counter, #quiz-counter {
    position: absolute;
    right: 0;
    top: -1.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.flashcard-area {
    max-width: 640px;
    margin: 0 auto;
}

/* Fixed flashcard flip mechanism */
.flashcard {
    perspective: 1200px;
    min-height: 380px;
    cursor: pointer;
    margin-bottom: 2rem;
    position: relative;
}

.flashcard-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.float-right {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    margin-top: 0;
}

.flashcard-front {
    background: linear-gradient(135deg, rgba(255,255,255,0.85), rgba(255,255,255,0.6));
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--glass-border);
}

.flashcard-back {
    background: linear-gradient(135deg, rgba(245,255,250,0.9), rgba(232,255,245,0.7));
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(0, 168, 107, 0.2);
    transform: rotateY(180deg);
}

.flashcard.flipped .flashcard-front {
    transform: rotateY(-180deg);
}

.flashcard.flipped .flashcard-back {
    transform: rotateY(0);
}

.char-display {
    font-size: 4.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: none;
}

.char-display.small {
    font-size: 2.8rem;
}

.pinyin {
    font-size: 1.4rem;
    color: var(--secondary);
    margin: 0.75rem 0;
    font-weight: 500;
}

.pos-label {
    font-size: 0.85rem;
    font-style: italic;
    color: var(--text-muted);
    text-align: center;
    margin: 0.25rem 0;
}

.meaning {
    font-size: 1.15rem;
    text-align: center;
    color: var(--text-primary);
}

.examples-container {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    width: 100%;
    max-width: 640px;
}

.example-item {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
    text-align: center;
    padding: 1rem;
    background: rgba(255,255,255,0.7);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    position: relative;
}

.example-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.3rem;
}

.example-row .audio-btn {
    margin-top: 0;
}

.example-item .chinese {
    font-size: 1.05rem;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.example-item .translation {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
}

.example-pinyin {
    font-size: 0.9rem;
    color: var(--secondary);
    margin: 0.3rem 0;
}

/* Tone color coding */
.pinyin-syllable {
    font-weight: 600;
}

.tone-1 { color: #e74c3c; }
.tone-2 { color: #27ae60; }
.tone-3 { color: #2980b9; }
.tone-4 { color: #8e44ad; }
.tone-0 { color: #95a5a6; }

.flashcard-buttons {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: auto;
    padding: 2rem 1rem 2.5rem 1rem;
}

/* Writing Practice */
.writing-container {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
}

.word-selector {
    padding: 1rem;
}

.writing-area {
    background: var(--glass-bg);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.large-char {
    font-size: 7rem;
    color: rgba(0, 0, 0, 0.12);
    margin-bottom: 0.5rem;
}

#writing-canvas {
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    cursor: crosshair;
    touch-action: none;
}

.stroke-info {
    margin-top: 1.25rem;
    text-align: center;
}

/* Grammar */
.grammar-grid {
    display: grid;
    gap: 1.25rem;
}

.grammar-item {
    background: var(--glass-bg);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.75rem;
    box-shadow: var(--shadow-md);
}

.grammar-item h3 {
    color: var(--primary);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.grammar-example {
    background: rgba(255, 255, 255, 0.7);
    padding: 1.25rem;
    border-radius: 10px;
    margin-top: 1rem;
    border: 1px solid var(--glass-border);
}

/* Reading */
.reading-area {
    background: var(--glass-bg);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: var(--shadow-md);
    margin-top: 1.5rem;
}

#reading-text {
    font-size: 1.5rem;
    line-height: 2.2;
}

/* Quiz */
.quiz-setup {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.question-card {
    background: var(--glass-bg);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: var(--shadow-md);
    max-width: 640px;
    margin: 0 auto;
}

.options-grid {
    display: grid;
    gap: 0.85rem;
    margin-top: 1.75rem;
}

.option-btn {
    padding: 1.1rem;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 1rem;
    text-align: left;
    transition: all var(--transition-fast);
    color: var(--text-primary);
}

.option-btn:hover {
    border-color: var(--primary-light);
    background: rgba(0, 168, 107, 0.08);
    transform: translateX(4px);
}

.option-btn.correct {
    border-color: var(--success);
    background: rgba(46, 204, 113, 0.15);
}

.option-btn.incorrect {
    border-color: var(--danger);
    background: rgba(0, 168, 107, 0.15);
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.action-btn {
    padding: 1.1rem;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 1rem;
    text-align: left;
    transition: all var(--transition-fast);
    color: var(--text-primary);
}

.action-btn:hover {
    background: linear-gradient(135deg, rgba(0,168,107,0.1), rgba(46,204,113,0.05));
    border-color: var(--primary-light);
    transform: translateX(4px);
}

/* Circular audio button */
.audio-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Responsive */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
    }

    .main-nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.4rem;
    }

    .nav-btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.9rem;
    }

    .writing-container {
        grid-template-columns: 1fr;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    main {
        padding: 1rem;
    }

    .char-display {
        font-size: 3.5rem;
    }

    /* Rating buttons fit within card on mobile */
    .flashcard-buttons {
        gap: 0.4rem;
    }

    .rating-btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
}