/* === CSS Variables === */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d2e;
    --bg-tertiary: #242842;
    --bg-navbar: #12141f;
    --bg-input: #1e2235;
    --text-primary: #e8eaf0;
    --text-secondary: #9ba1b8;
    --text-heading: #f0f2ff;
    --accent-primary: #6c5ce7;
    --accent-secondary: #00cec9;
    --level-beginner: #00b894;
    --level-intermediate: #fdcb6e;
    --level-advanced: #e17055;
    --color-success: #00b894;
    --color-success-bg: rgba(0, 184, 148, 0.15);
    --color-danger: #e17055;
    --color-danger-bg: rgba(225, 112, 85, 0.15);
    --color-info: #74b9ff;
    --color-info-bg: rgba(116, 185, 255, 0.15);
    --color-achievement: #fdcb6e;
    --color-achievement-bg: rgba(253, 203, 110, 0.15);
    --font-heading: 'Segoe UI', 'SF Pro Display', 'Ubuntu', 'Cantarell', sans-serif;
    --font-body: 'Segoe UI', 'SF Pro Text', 'Ubuntu', 'Cantarell', sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', 'Ubuntu Mono', monospace;
}

/* === Animations === */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInRow {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes ripple {
    to { transform: scale(4); opacity: 0; }
}
@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 5px rgba(108, 92, 231, 0.3); }
    50% { box-shadow: 0 0 20px rgba(108, 92, 231, 0.6); }
}
@keyframes correctPulse {
    0% { background-color: var(--color-success-bg); }
    50% { background-color: rgba(0, 184, 148, 0.3); }
    100% { background-color: var(--color-success-bg); }
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}
@keyframes sparkle {
    0%, 100% { opacity: 0; transform: scale(0) rotate(0deg); }
    50% { opacity: 1; transform: scale(1) rotate(180deg); }
}
@keyframes floatParticle {
    0%, 100% { transform: translateY(0) translateX(0); opacity: 0.3; }
    25% { transform: translateY(-30px) translateX(10px); opacity: 0.6; }
    50% { transform: translateY(-60px) translateX(-10px); opacity: 0.3; }
    75% { transform: translateY(-30px) translateX(20px); opacity: 0.5; }
}
@keyframes unlockBounce {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.1); }
    70% { transform: scale(0.95); }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes celebratePop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes progressFill {
    from { width: 0; }
}

/* === Base === */
* { box-sizing: border-box; }
body {
    font-family: var(--font-body);
    margin: 0;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}
h1 {
    font-family: var(--font-heading);
    color: var(--text-heading);
    text-align: center;
    animation: fadeInUp 0.5s ease-out;
}
h2 {
    font-family: var(--font-heading);
    color: var(--text-heading);
    border-bottom: 3px solid var(--accent-primary);
    padding-bottom: 10px;
    margin-top: 40px;
}
h3 {
    font-family: var(--font-heading);
    color: var(--text-secondary);
    margin-top: 30px;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px 30px;
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.4s ease-out;
}

/* === Particles Background === */
.particles {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}
.particle {
    position: absolute;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--accent-primary);
    opacity: 0.3;
    animation: floatParticle 8s infinite ease-in-out;
}
.particle:nth-child(1) { left: 10%; top: 20%; animation-delay: 0s; animation-duration: 7s; }
.particle:nth-child(2) { left: 25%; top: 60%; animation-delay: 1s; animation-duration: 9s; background: var(--accent-secondary); }
.particle:nth-child(3) { left: 50%; top: 30%; animation-delay: 2s; animation-duration: 6s; }
.particle:nth-child(4) { left: 70%; top: 70%; animation-delay: 3s; animation-duration: 10s; background: var(--accent-secondary); }
.particle:nth-child(5) { left: 85%; top: 15%; animation-delay: 4s; animation-duration: 8s; }
.particle:nth-child(6) { left: 40%; top: 80%; animation-delay: 5s; animation-duration: 7s; background: var(--accent-secondary); }
.particle:nth-child(7) { left: 60%; top: 45%; animation-delay: 6s; animation-duration: 11s; }
.particle:nth-child(8) { left: 15%; top: 90%; animation-delay: 7s; animation-duration: 9s; background: var(--accent-secondary); }

/* === Navbar === */
.navbar {
    background: var(--bg-navbar);
    padding: 12px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 10;
    border-bottom: 1px solid rgba(108, 92, 231, 0.2);
}
.nav-brand a {
    color: var(--text-heading);
    text-decoration: none;
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 0.5px;
}
.nav-links { display: flex; align-items: center; gap: 15px; }
.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.25s;
    font-size: 14px;
}
.nav-link:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav-link.active { background: var(--accent-primary); color: white; }
.nav-user { color: var(--accent-secondary); font-weight: bold; font-size: 14px; }
.nav-logout { color: var(--color-danger); }
.nav-logout:hover { background: var(--color-danger); color: white; }

/* === Alerts === */
.alert {
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: fadeInUp 0.3s ease-out;
    border: 1px solid transparent;
}
.alert-success { background: var(--color-success-bg); color: var(--color-success); border-color: rgba(0, 184, 148, 0.3); }
.alert-danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: rgba(225, 112, 85, 0.3); }
.alert-info { background: var(--color-info-bg); color: var(--color-info); border-color: rgba(116, 185, 255, 0.3); }
.alert-achievement { background: var(--color-achievement-bg); color: var(--color-achievement); border-color: rgba(253, 203, 110, 0.3); }
.alert-close { cursor: pointer; font-size: 20px; opacity: 0.7; transition: opacity 0.2s; }
.alert-close:hover { opacity: 1; }

/* === Tables === */
table {
    border-collapse: collapse;
    width: 100%;
    margin: 15px 0;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
}
th, td { border: 1px solid rgba(255, 255, 255, 0.06); padding: 10px; text-align: left; }
th { background-color: var(--accent-primary); color: white; font-family: var(--font-heading); }
tr { animation: fadeInRow 0.3s ease-out both; }
tr:nth-child(even) { background-color: var(--bg-tertiary); }
tr:hover { background-color: rgba(108, 92, 231, 0.1); }
td strong { font-family: var(--font-mono); color: var(--accent-secondary); }

/* === Levels === */
.beginner { background-color: var(--level-beginner) !important; color: white; }
.intermediate { background-color: var(--level-intermediate) !important; color: #1a1d2e; }
.advanced { background-color: var(--level-advanced) !important; color: white; }

.note {
    background-color: var(--bg-secondary);
    padding: 15px;
    border-left: 4px solid var(--accent-primary);
    margin: 20px 0;
    border-radius: 4px;
    color: var(--text-secondary);
}

/* === Forms === */
.add-word-section {
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    margin: 30px 0;
    border: 1px solid rgba(108, 92, 231, 0.15);
    animation: fadeInUp 0.5s ease-out;
}
.form-group { margin-bottom: 20px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
label { display: block; margin-bottom: 5px; font-weight: bold; color: var(--text-secondary); font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; }
input, select, textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-body);
    transition: border-color 0.3s, box-shadow 0.3s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    animation: glowPulse 2s infinite;
}
input::placeholder, textarea::placeholder { color: var(--text-secondary); opacity: 0.5; }
textarea { resize: vertical; min-height: 80px; }
select option { background: var(--bg-input); color: var(--text-primary); }

/* === Buttons === */
button {
    background-color: var(--accent-primary);
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-family: var(--font-heading);
    cursor: pointer;
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
}
button:hover { background-color: #5a4bd1; transform: translateY(-1px); box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4); }
button:active { transform: translateY(0); }
.btn-success { background-color: var(--color-success); }
.btn-success:hover { background-color: #00a381; box-shadow: 0 4px 15px rgba(0, 184, 148, 0.4); }
.btn-danger { background-color: var(--color-danger); padding: 5px 10px; font-size: 12px; }
.btn-danger:hover { background-color: #c0392b; box-shadow: 0 4px 15px rgba(225, 112, 85, 0.4); }
.btn-small { padding: 8px 15px; font-size: 14px; }

.btn-link {
    display: inline-block;
    background: var(--accent-primary);
    color: white;
    padding: 12px 30px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 16px;
    font-family: var(--font-heading);
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
}
.btn-link:hover { background: #5a4bd1; transform: translateY(-1px); box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4); }

/* Ripple effect */
.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

/* === Stats === */
.stats {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    margin: 20px 0;
    font-size: 15px;
    border: 1px solid rgba(108, 92, 231, 0.15);
    animation: fadeInUp 0.4s ease-out 0.1s both;
}

/* === Filters === */
.filter-buttons { margin: 15px 0; text-align: center; }
.filter-btn {
    background-color: var(--bg-tertiary);
    margin: 3px;
    padding: 8px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 20px;
    font-size: 13px;
    display: inline-block;
    transition: all 0.25s;
    border: 1px solid transparent;
}
.filter-btn:hover { background-color: rgba(108, 92, 231, 0.2); color: var(--text-primary); border-color: var(--accent-primary); }
.filter-btn.active { background-color: var(--accent-primary); color: white; }

/* === Categories === */
.category-section {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    border: 2px dashed rgba(108, 92, 231, 0.3);
}
.category-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 15px; }
.category-tag {
    background: var(--accent-primary);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s;
}
.category-tag:hover { transform: translateY(-1px); }
.category-tag .remove-category,
.category-tag button.remove-category {
    cursor: pointer;
    font-weight: bold;
    background: none;
    border: none;
    color: white;
    padding: 0 2px;
    font-size: 16px;
}
.category-tag .remove-category:hover,
.category-tag button.remove-category:hover { color: var(--color-danger); }
.add-category-row { display: flex; gap: 10px; margin-top: 15px; align-items: center; }
.add-category-row input { flex: 1; }

/* === Auth === */
.auth-container {
    max-width: 400px;
    margin: 80px auto;
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    text-align: center;
    border: 1px solid rgba(108, 92, 231, 0.15);
    animation: fadeInUp 0.5s ease-out;
}
.auth-container .auth-hero { margin-bottom: 20px; }
.auth-form { text-align: left; }
.auth-link { margin-top: 20px; color: var(--text-secondary); }
.auth-link a { color: var(--accent-secondary); text-decoration: none; transition: color 0.2s; }
.auth-link a:hover { color: var(--accent-primary); }

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    animation: fadeInUp 0.6s ease-out;
}
.empty-state h3 { color: var(--text-heading); margin-top: 20px; }
.empty-state p { color: var(--text-secondary); }

/* === Quiz === */
.quiz-container { max-width: 700px; margin: 0 auto; }
.quiz-progress {
    display: flex;
    justify-content: space-between;
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 14px;
    border: 1px solid rgba(108, 92, 231, 0.15);
}
.quiz-streak { color: var(--color-achievement); font-weight: bold; }

/* Quiz Progress Bar */
.quiz-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    margin-bottom: 20px;
    overflow: hidden;
}
.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 3px;
    transition: width 0.4s ease-out;
    animation: progressFill 0.6s ease-out;
}

.quiz-card {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    text-align: center;
    border: 1px solid rgba(108, 92, 231, 0.15);
    animation: fadeInUp 0.4s ease-out;
}
.quiz-prompt-label { font-size: 14px; color: var(--text-secondary); margin-bottom: 5px; }
.quiz-prompt { font-size: 32px; font-weight: bold; color: var(--text-heading); margin-bottom: 30px; font-family: var(--font-mono); }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quiz-option-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 15px;
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.25s;
}
.quiz-option-btn:hover { background: var(--accent-primary); color: white; border-color: var(--accent-primary); transform: translateY(-2px); }

.quiz-result-card {
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    text-align: center;
    margin-bottom: 30px;
    border: 1px solid rgba(108, 92, 231, 0.15);
    animation: celebratePop 0.5s ease-out;
}
.quiz-score { font-size: 48px; font-weight: bold; margin: 20px 0; font-family: var(--font-heading); }
.score-great { color: var(--color-success); }
.score-ok { color: var(--level-intermediate); }
.score-bad { color: var(--color-danger); }

.row-correct { background-color: var(--color-success-bg) !important; }
.row-wrong { background-color: var(--color-danger-bg) !important; }

.quiz-achievements { margin-top: 20px; }
.achievement-toast {
    background: var(--color-achievement-bg);
    border: 2px solid rgba(253, 203, 110, 0.4);
    padding: 10px 20px;
    border-radius: 10px;
    margin: 8px 0;
    font-weight: bold;
    color: var(--color-achievement);
    animation: unlockBounce 0.5s ease-out both;
}

/* Quiz celebration SVG */
.quiz-celebration { animation: celebratePop 0.6s ease-out 0.2s both; margin: 10px auto; }

/* === Achievements Page === */
.achievement-counter { text-align: center; font-size: 18px; color: var(--text-secondary); }
.achievements-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 15px; margin-top: 20px; }
.achievement-card {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.25s;
    border: 1px solid rgba(108, 92, 231, 0.1);
}
.achievement-card:hover { transform: translateY(-3px); }
.achievement-card.locked { opacity: 0.4; filter: grayscale(0.8); }
.achievement-card.unlocked { border-left: 4px solid var(--color-achievement); }
.achievement-icon { font-size: 36px; }
.achievement-name { font-weight: bold; color: var(--text-heading); }
.achievement-desc { font-size: 13px; color: var(--text-secondary); }
.achievement-date { font-size: 12px; color: var(--text-secondary); margin-top: 4px; opacity: 0.7; }

/* Sparkle wrapper for achievements */
.sparkle-wrap {
    position: relative;
}
.sparkle-wrap::before,
.sparkle-wrap::after {
    content: '';
    position: absolute;
    width: 8px; height: 8px;
    background: var(--color-achievement);
    border-radius: 50%;
    animation: sparkle 2s infinite;
}
.sparkle-wrap::before { top: -4px; right: 10px; animation-delay: 0s; }
.sparkle-wrap::after { bottom: -4px; left: 15px; animation-delay: 1s; }

/* === New Words Table === */
.new-words-table { border-left: 4px solid var(--color-success); }

/* === Scrollbar === */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-primary); }

/* === Selection === */
::selection { background: rgba(108, 92, 231, 0.4); color: white; }
