:root {
    --primary: #2563eb;
    --primary-light: #eff6ff;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --error: #f43f5e;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
}

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: white;
    border-right: 1px solid var(--border);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 40px;
}

.nav-tabs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.tab-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
}

.sidebar-footer {
    margin-top: auto;
}

.btn-ghost {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
}

/* Content Area */
.content-area {
    margin-left: 260px;
    flex: 1;
    padding: 40px;
    max-width: 1200px;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.main-header h1 { font-size: 2.5rem; letter-spacing: -1px; margin-bottom: 4px; }
.main-header p { color: var(--text-muted); font-size: 1.1rem; }

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

/* Stats Grid */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.stat-card p { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 8px; font-weight: 600; }
.stat-card h2 { font-size: 1.8rem; margin-bottom: 12px; }
.stat-card span { font-size: 0.8rem; color: var(--text-muted); }

.progress-mini {
    width: 100%;
    height: 6px;
    background: #f1f5f9;
    border-radius: 10px;
    overflow: hidden;
}

.progress-mini .bar {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.6s ease;
}

/* Toolbar */
.toolbar {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.search-bar {
    flex: 1;
    position: relative;
}

.search-bar i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    padding: 14px 14px 14px 44px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    outline: none;
    font-size: 1rem;
}

select#category-filter {
    padding: 14px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: white;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
}

/* Study Grid */
.study-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.word-card {
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.word-card:hover { transform: translateY(-4px); border-color: var(--primary); }
.word-card.mastered { border-left: 6px solid var(--success); }

.card-header { display: flex; justify-content: space-between; margin-bottom: 16px; }
.badge-cat { font-size: 0.7rem; font-weight: 700; color: var(--primary); text-transform: uppercase; background: var(--primary-light); padding: 4px 10px; border-radius: 6px; }
.badge-type { font-size: 0.75rem; color: var(--text-muted); font-style: italic; }

.word-eng { font-size: 1.8rem; font-weight: 800; margin-bottom: 4px; }
.word-ipa { color: var(--primary); font-weight: 500; font-size: 0.95rem; margin-bottom: 12px; }
.word-vie { font-size: 1.2rem; font-weight: 700; color: #334155; margin-bottom: 16px; }

.example-box {
    background: #f8fafc;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 3px solid var(--border);
}

.ex-eng { font-size: 0.9rem; font-style: italic; margin-bottom: 4px; color: var(--text-main); }
.ex-vie { font-size: 0.85rem; color: var(--text-muted); }

.card-footer {
    display: flex;
    gap: 10px;
}

.btn-sm-audio, .btn-sm-master {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    background: white;
    transition: all 0.2s;
}

.btn-sm-audio:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.btn-sm-master.active { background: var(--success); color: white; border-color: var(--success); }

/* Main Display & Learning Modes */
.main-display {
    background: white;
    border-radius: 20px;
    padding: 60px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    max-width: 800px;
    margin: 0 auto;
}

.flash-container, .listen-container, .write-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Flashcard 3D */
.flashcard-3d {
    width: 400px;
    height: 250px;
    perspective: 1000px;
    cursor: pointer;
    margin-bottom: 40px;
}

.flashcard-3d .front, .flashcard-3d .back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
    border-radius: 20px;
    border: 2px solid var(--primary);
    transition: transform 0.6s;
}

.flashcard-3d.flipped .front { transform: rotateY(180deg); }
.flashcard-3d.flipped .back { transform: rotateY(0deg); }
.flashcard-3d .back { transform: rotateY(-180deg); background: var(--primary-light); }

.display-word { font-size: 3rem; font-weight: 800; }
.display-trans { font-size: 2.2rem; color: var(--primary); font-weight: 700; }

/* Quiz & Write */
.quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
    max-width: 500px;
    margin-top: 30px;
}

.opt-btn {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: white;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.opt-btn:hover { border-color: var(--primary); background: var(--primary-light); }

.input-group {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 500px;
    margin-top: 20px;
}

.input-group input {
    flex: 1;
    padding: 16px;
    border-radius: 12px;
    border: 2px solid var(--border);
    font-size: 1.2rem;
    font-weight: 600;
    outline: none;
}

.input-group input:focus { border-color: var(--primary); }

.nav-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 40px;
}

.nav-controls button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: white;
    cursor: pointer;
}

/* Animations */
.shake { animation: shake 0.5s; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.hidden { display: none !important; }

@media (max-width: 1024px) {
    .sidebar { width: 80px; padding: 20px 10px; }
    .logo span, .tab-btn span, .sidebar-footer span { display: none; }
    .content-area { margin-left: 80px; padding: 20px; }
}
