/* ========================================
   SPANISH LEARNING - MATERIAL DESIGN BLUE
   Simple & Beautiful Android-Style UI
   ======================================== */

/* ===== Google Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ===== CSS Variables ===== */
:root {
    /* Blue Theme */
    --primary: #2196F3;
    --primary-dark: #1976D2;
    --primary-light: #64B5F6;
    --primary-bg: rgba(33, 150, 243, 0.1);
    --primary-ripple: rgba(33, 150, 243, 0.3);

    /* Accent */
    --accent: #FF4081;
    --accent-dark: #F50057;

    /* Success/Error */
    --success: #4CAF50;
    --error: #F44336;
    --warning: #FF9800;

    /* Dark Theme Backgrounds */
    --bg-primary: #0D1117;
    --bg-secondary: #161B22;
    --bg-card: #21262D;
    --bg-card-hover: #30363D;
    --bg-input: #0D1117;

    /* Text */
    --text-primary: #F0F6FC;
    --text-secondary: #8B949E;
    --text-muted: #6E7681;
    --text-on-primary: #FFFFFF;

    /* Borders */
    --border-color: #30363D;
    --border-light: #484F58;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.5);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-fab: 0 6px 10px rgba(33, 150, 243, 0.4);

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Transitions */
    --transition: 0.2s ease;
    --transition-slow: 0.3s ease;

    /* Spacing */
    --nav-height: 60px;
    --bottom-nav-height: 64px;
}

/* ===== Reset ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, textarea, select {
    font-family: inherit;
    font-size: 1rem;
}

/* ===== App Container ===== */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: var(--bottom-nav-height);
}

/* ===== Top Header ===== */
.app-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--nav-height);
}

.header-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 16px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 800;
    color: white;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.icon-btn:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    padding: 16px;
}

/* ===== Bottom Navigation (Android Style) ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    height: var(--bottom-nav-height);
    display: flex;
    justify-content: center;
    z-index: 100;
}

.bottom-nav-inner {
    max-width: 600px;
    width: 100%;
    display: flex;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 0;
    color: var(--text-muted);
    transition: all var(--transition);
    position: relative;
}

.nav-item .nav-icon {
    font-size: 1.5rem;
    transition: transform var(--transition);
}

.nav-item .nav-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active .nav-icon {
    transform: scale(1.1);
}

.nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 48px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 4px 4px;
    transition: transform var(--transition);
}

.nav-item.active::before {
    transform: translateX(-50%) scaleX(1);
}

/* ===== Cards (Material Style) ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-card);
    transition: all var(--transition);
}

.card-clickable {
    cursor: pointer;
}

.card-clickable:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-clickable:active {
    transform: translateY(0);
}

/* ===== Word Card ===== */
.word-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    margin-bottom: 12px;
}

.word-card .play-btn {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
    transition: all var(--transition);
}

.word-card .play-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.word-card .play-btn:active {
    transform: scale(0.95);
}

.word-card .word-content {
    flex: 1;
    min-width: 0;
}

.word-card .spanish {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.word-card .arabic {
    font-size: 1.1rem;
    color: var(--primary-light);
    direction: rtl;
}

.word-card .sentence {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 8px;
    font-style: italic;
}

.word-card .delete-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-secondary);
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.word-card .delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.word-card .delete-btn:active {
    transform: scale(0.9);
}

/* ===== Buttons (Material Style) ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
}

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

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

.btn-block {
    width: 100%;
}

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

/* ===== Floating Action Button (FAB) ===== */
.fab {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: white;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-fab);
    transition: all var(--transition);
    z-index: 50;
}

.fab:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.fab:active {
    transform: scale(0.95);
}

/* ===== Form Inputs (Material Style) ===== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

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

.form-input[dir="rtl"] {
    text-align: right;
}

.form-input.large {
    font-size: 1.25rem;
    padding: 16px 20px;
}

/* ===== Record Button (Big & Beautiful) ===== */
.record-section {
    text-align: center;
    padding: 24px 0;
}

.record-btn {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    background: var(--error);
    color: white;
    font-size: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
    transition: all var(--transition);
}

.record-btn:hover {
    transform: scale(1.05);
}

.record-btn:active {
    transform: scale(0.95);
}

.record-btn.recording {
    animation: pulse-record 1s ease infinite;
    background: var(--error);
}

@keyframes pulse-record {
    0%, 100% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.5); }
    50% { box-shadow: 0 0 0 15px rgba(244, 67, 54, 0); }
}

.record-label {
    display: block;
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ===== Audio Player ===== */
.audio-player {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

.audio-player .play-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.audio-player .waveform {
    flex: 1;
    height: 32px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.audio-player .duration {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== Flashcard ===== */
.flashcard-container {
    perspective: 1000px;
    margin: 24px 0;
}

.flashcard {
    width: 100%;
    height: 280px;
    position: relative;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.5s ease;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
}

.flashcard-front {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.flashcard-back {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    transform: rotateY(180deg);
}

.flashcard-word {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 16px;
}

.flashcard-hint {
    font-size: 1rem;
    opacity: 0.8;
}

.flashcard-tap {
    position: absolute;
    bottom: 20px;
    font-size: 0.85rem;
    opacity: 0.6;
}

/* ===== Flashcard Actions ===== */
.flashcard-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.flashcard-actions .btn {
    flex: 1;
    padding: 14px;
}

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

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

/* ===== Page Header ===== */
.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* ===== Section ===== */
.section {
    margin-bottom: 32px;
}

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

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.section-link {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 24px;
}

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

.empty-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-text {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ===== Loading ===== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Welcome Banner ===== */
.welcome-banner {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    text-align: center;
}

.welcome-banner span {
    color: white;
    font-size: 1.25rem;
    font-weight: 600;
}

/* ===== Search Box ===== */
.search-box {
    position: relative;
    margin-bottom: 20px;
}

.search-box input {
    width: 100%;
    padding: 14px 16px 14px 48px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 1rem;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-box .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.25rem;
    color: var(--text-muted);
}

/* ===== Category Chips ===== */
.chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.chip {
    padding: 8px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.chip:hover {
    background: var(--bg-card-hover);
}

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

/* ===== Stats Card ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

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

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

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

/* ===== Quiz Option ===== */
.quiz-option {
    padding: 16px 20px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    font-size: 1.1rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}

.quiz-option:hover {
    border-color: var(--primary);
    background: var(--bg-card-hover);
}

.quiz-option.selected {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.quiz-option.correct {
    border-color: var(--success);
    background: rgba(76, 175, 80, 0.15);
}

.quiz-option.incorrect {
    border-color: var(--error);
    background: rgba(244, 67, 54, 0.15);
}

/* ===== Progress Bar ===== */
.progress-bar {
    height: 8px;
    background: var(--bg-input);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

/* ===== Modal / Bottom Sheet ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--text-muted);
}

.modal-body {
    padding: 20px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 80px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    padding: 12px 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-weight: 500;
    z-index: 300;
    animation: toastIn 0.3s ease;
}

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

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

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ===== Utility Classes ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.hidden { display: none; }

/* ===== Blazor Error ===== */
#blazor-error-ui {
    background: var(--error);
    color: white;
    padding: 16px;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 1000;
    display: none;
}

/* ===== RTL Support for Arabic ===== */
.rtl {
    direction: rtl;
    text-align: right;
}
