/* ============================================================
   Global Styles
   ============================================================ */
:root {
    --primary: #6C63FF;
    --primary-light: #8B85FF;
    --primary-dark: #5A52E0;
    --success: #4CAF50;
    --success-light: #E8F5E9;
    --warning: #FF9800;
    --warning-light: #FFF3E0;
    --danger: #F44336;
    --danger-light: #FFEBEE;
    --info: #2196F3;
    --info-light: #E3F2FD;
    --bg: #F5F7FF;
    --card-bg: #FFFFFF;
    --text: #2D3436;
    --text-light: #636E72;
    --text-muted: #B2BEC3;
    --border: #E8ECF4;
    --shadow: 0 2px 12px rgba(108, 99, 255, 0.08);
    --shadow-lg: 0 8px 30px rgba(108, 99, 255, 0.12);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ============================================================
   Layout
   ============================================================ */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.container-sm {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px;
}

/* ============================================================
   Header / Navbar
   ============================================================ */
.navbar {
    background: var(--card-bg);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-brand span {
    font-size: 1.5rem;
}

.navbar-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.navbar-actions a {
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 6px 12px;
    border-radius: var(--radius-xs);
    transition: var(--transition);
}

.navbar-actions a:hover {
    color: var(--primary);
    background: rgba(108, 99, 255, 0.08);
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
}

.card-subtitle {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 12px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-family: inherit;
    line-height: 1.4;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 15px rgba(108, 99, 255, 0.3);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #43A047;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: #F57C00;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #D32F2F;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

.btn-ghost {
    background: rgba(108, 99, 255, 0.08);
    color: var(--primary);
}

.btn-ghost:hover {
    background: rgba(108, 99, 255, 0.15);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1.1rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================
   Forms
   ============================================================ */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
    background: var(--card-bg);
    color: var(--text);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23636E72' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ============================================================
   Landing Page
   ============================================================ */
.landing {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
}

.landing::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 50%);
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(30px, -30px) rotate(5deg); }
    66% { transform: translate(-20px, 20px) rotate(-3deg); }
}

.landing-content {
    position: relative;
    z-index: 1;
    text-align: center;
    color: white;
}

.landing-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: bounce 2s ease-in-out infinite;
}

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

.landing h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.landing p {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 40px;
}

.landing-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.landing-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 30px 40px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: var(--radius);
    color: white;
    text-decoration: none;
    transition: var(--transition);
    min-width: 180px;
}

.landing-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.landing-btn-icon {
    font-size: 2.5rem;
}

.landing-btn-text {
    font-size: 1.1rem;
    font-weight: 600;
}

.landing-btn-desc {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* ============================================================
   Login Page
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--text-light);
    margin-bottom: 30px;
    font-size: 0.9rem;
}

.error-msg {
    background: var(--danger-light);
    color: var(--danger);
    padding: 10px 16px;
    border-radius: var(--radius-xs);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

/* ============================================================
   Dashboard / Stats
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* ============================================================
   Word List
   ============================================================ */
.word-list {
    list-style: none;
}

.word-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.word-item:last-child {
    border-bottom: none;
}

.word-item:hover {
    background: rgba(108, 99, 255, 0.03);
}

.word-info {
    flex: 1;
}

.word-text {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

.word-meaning {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 2px;
}

.word-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.word-actions {
    display: flex;
    gap: 8px;
}

/* ============================================================
   Child Selection
   ============================================================ */
.child-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.child-card {
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.child-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    transform: translateY(-3px);
}

.child-card.selected {
    border-color: var(--primary);
    background: rgba(108, 99, 255, 0.05);
}

.child-avatar {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.child-name {
    font-weight: 600;
    font-size: 1rem;
}

/* ============================================================
   Learning Mode
   ============================================================ */
.learn-container {
    max-width: 560px;
    margin: 0 auto;
    padding: 20px;
}

.progress-bar-container {
    background: var(--border);
    border-radius: 20px;
    height: 12px;
    margin-bottom: 24px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 20px;
    transition: width 0.5s ease;
}

.progress-text {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 8px;
}

.learn-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 40px 30px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.learn-meaning {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 30px;
    line-height: 1.4;
}

.learn-input {
    width: 100%;
    padding: 16px 20px;
    border: 3px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1.3rem;
    text-align: center;
    font-family: inherit;
    transition: var(--transition);
    letter-spacing: 2px;
}

.learn-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.1);
}

.learn-input.correct {
    border-color: var(--success);
    background: var(--success-light);
}

.learn-input.wrong {
    border-color: var(--danger);
    background: var(--danger-light);
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.hint-display {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--warning);
    margin: 16px 0;
    font-family: monospace;
}

.learn-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: center;
    flex-wrap: wrap;
}

.feedback {
    margin-top: 20px;
    padding: 16px;
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    font-weight: 600;
    display: none;
}

.feedback.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

.feedback.success {
    background: var(--success-light);
    color: var(--success);
}

.feedback.error {
    background: var(--danger-light);
    color: var(--danger);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Encouragement
   ============================================================ */
.encourage-text {
    font-size: 1.2rem;
    color: var(--success);
    font-weight: 600;
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 1rem;
    margin-bottom: 8px;
}

.empty-state-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ============================================================
   Badge
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning);
}

.badge-info {
    background: var(--info-light);
    color: var(--info);
}

.badge-muted {
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-light);
}

/* ============================================================
   Tabs
   ============================================================ */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 20px;
}

.tab {
    flex: 1;
    padding: 10px 16px;
    text-align: center;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light);
    transition: var(--transition);
    text-decoration: none;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    background: var(--card-bg);
    color: var(--primary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* ============================================================
   Toast Notification
   ============================================================ */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    border-radius: 6px;
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.toast.show {
    opacity: 1;
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

.toast-warning {
    background: var(--warning);
}

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

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 30px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.3s ease;
}

.draggable-modal {
    max-width: 700px;
    cursor: default;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ============================================================
   Filter Bar
   ============================================================ */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-bar .form-input {
    width: auto;
    min-width: 160px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 600px) {
    .container {
        padding: 12px;
    }

    .navbar {
        padding: 12px 16px;
    }

    .landing h1 {
        font-size: 1.8rem;
    }

    .landing-buttons {
        flex-direction: column;
        align-items: center;
    }

    .landing-btn {
        width: 100%;
        max-width: 280px;
    }

    .card {
        padding: 18px;
    }

    .login-card {
        padding: 30px 20px;
    }

    .learn-card {
        padding: 30px 20px;
    }

    .learn-meaning {
        font-size: 1.2rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .word-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .word-actions {
        align-self: flex-end;
    }

    .child-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal {
        padding: 24px 18px;
    }
}

/* ============================================================
   Utilities
   ============================================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.hidden { display: none; }

/* ============================================================
   Syllable Chips
   ============================================================ */
.syllable-chip {
    display: inline-block;
    padding: 4px 12px;
    margin: 2px 4px;
    background: var(--primary-light);
    color: white;
    border-radius: var(--radius-xs);
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.5px;
}
