/* =====================================================
   ENGLISH HUB - Main CSS
   ===================================================== */

/* CSS Custom Properties */
:root {
    --primary: #7AE582;
    --primary-dark: #54CC6D;
    --primary-light: #A8F0B0;
    --primary-bg: #F0FDF4;
    --secondary: #16a34a;
    --accent: #3b82f6;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 24px;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    
    --transition: 150ms ease;
    --transition-slow: 300ms ease;
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; line-height: 1.6; }

/* Typography */
h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.2; color: #111827; }
h1 { font-size: clamp(2rem, 5vw, 3rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2.25rem); }
h3 { font-size: clamp(1.25rem, 3vw, 1.5rem); }
p { color: #4b5563; }

/* Links */
a { color: var(--primary-dark); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-lg);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    color: #111827;
    box-shadow: var(--shadow-md);
}
.btn-primary:hover:not(:disabled) {
    background: linear-gradient(90deg, var(--primary-dark), var(--primary));
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
}
.btn-secondary:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
}

.btn-ghost {
    background: transparent;
    color: #6b7280;
}
.btn-ghost:hover:not(:disabled) {
    background: #f3f4f6;
    color: #374151;
}

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-sm { padding: 0.375rem 0.875rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.875rem 1.75rem; font-size: 1rem; }
.btn-xl { padding: 1rem 2rem; font-size: 1.125rem; }

/* Form Elements */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.375rem;
}
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    font-family: inherit;
    border: 1px solid #d1d5db;
    border-radius: var(--radius-md);
    background: white;
    color: #111827;
    transition: all var(--transition);
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}
.form-input::placeholder { color: #9ca3af; }
.form-input.error { border-color: var(--danger); }
.form-error { color: var(--danger); font-size: 0.75rem; margin-top: 0.25rem; }

/* Cards */
.card {
    background: white;
    border-radius: var(--radius-xl);
    border: 1px solid #e5e7eb;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-glass {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(229,231,235,0.8);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 9999px;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f3f4f6; color: #374151; }

/* Progress Bar */
.progress {
    height: 8px;
    background: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border-radius: 9999px;
    transition: width 0.5s ease;
}

/* Animations */
@keyframes slide-in {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes fade-in-up {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-slide-in { animation: slide-in 0.3s ease; }
.animate-fade-in { animation: fade-in 0.3s ease; }
.animate-fade-in-up { animation: fade-in-up 0.4s ease; }
.animate-pulse { animation: pulse 2s infinite; }
.animate-spin { animation: spin 1s linear infinite; }

/* Layout Utilities */
.container { max-width: 80rem; margin: 0 auto; padding: 0 1rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-primary { color: var(--primary-dark); }
.text-success { color: #16a34a; }
.text-error { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: #6b7280; }

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

.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-2xl { border-radius: var(--radius-2xl); }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }

.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }

.w-full { width: 100%; }
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.max-w-xl { max-width: 36rem; }
.max-w-2xl { max-width: 42rem; }

/* Grid */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

@media (min-width: 640px) {
    .sm\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .sm\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 768px) {
    .md\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .md\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .md\:grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
    .md\:flex { display: flex; }
    .md\:hidden { display: none; }
}
@media (min-width: 1024px) {
    .lg\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .lg\:grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
}

/* Flash Messages */
#flash-container { pointer-events: none; }
#flash-container .flash-message { pointer-events: auto; }

/* Loading Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 50;
    animation: fade-in 0.2s ease;
}
.modal {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 32rem;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: fade-in-up 0.3s ease;
}
.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th,
.table td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid #e5e7eb; }
.table th { font-weight: 600; color: #374151; background: #f9fafb; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.table tbody tr:hover { background: #f9fafb; }

/* Tabs */
.tabs { display: flex; border-bottom: 1px solid #e5e7eb; gap: 0.25rem; }
.tab-btn {
    padding: 0.75rem 1.25rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all var(--transition);
}
.tab-btn:hover { color: #374151; }
.tab-btn.active { color: var(--primary-dark); border-bottom-color: var(--primary); }

/* Tooltips */
.tooltip { position: relative; }
.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
    z-index: 10;
}
.tooltip:hover::after { opacity: 1; visibility: visible; }

/* Audio Player Custom */
audio { width: 100%; margin-top: 0.5rem; }

/* Flashcard Flip */
.flashcard {
    perspective: 1000px;
    cursor: pointer;
}
.flashcard-inner {
    position: relative;
    width: 100%;
    height: 280px;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-front, .flashcard-back {
    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: 2rem;
    background: white;
    border: 1px solid #e5e7eb;
    box-shadow: var(--shadow-md);
}
.flashcard-back { transform: rotateY(180deg); background: var(--primary-bg); border-color: var(--primary-light); }

/* Practice Mode */
.practice-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition);
    background: white;
}
.practice-option:hover { border-color: var(--primary); background: var(--primary-bg); }
.practice-option input { accent-color: var(--primary); }
.practice-option.correct { border-color: var(--secondary); background: #dcfce7; }
.practice-option.incorrect { border-color: var(--danger); background: #fee2e2; }

/* Voice Tutor */
.voice-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all var(--transition);
}
.voice-indicator.listening {
    background: #dbeafe;
    color: #1e40af;
}
.voice-indicator.speaking {
    background: #fef3c7;
    color: #92400e;
}
.voice-indicator.processing {
    background: #f3f4f6;
    color: #6b7280;
}
.voice-indicator.idle {
    background: #dcfce7;
    color: #166534;
}
.voice-wave {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 20px;
}
.voice-wave span {
    width: 4px;
    background: currentColor;
    border-radius: 2px;
    animation: wave 1s ease-in-out infinite;
}
.voice-wave span:nth-child(2) { animation-delay: 0.1s; }
.voice-wave span:nth-child(3) { animation-delay: 0.2s; }
.voice-wave span:nth-child(4) { animation-delay: 0.3s; }
.voice-wave span:nth-child(5) { animation-delay: 0.4s; }
@keyframes wave {
    0%, 100% { height: 4px; }
    50% { height: 20px; }
}

/* Transcript */
.transcript {
    max-height: 300px;
    overflow-y: auto;
    padding: 1rem;
    background: #f9fafb;
    border-radius: var(--radius-lg);
    border: 1px solid #e5e7eb;
}
.transcript-entry {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    background: white;
    box-shadow: var(--shadow-sm);
}
.transcript-entry.user { background: var(--primary-bg); border-left: 3px solid var(--primary); }
.transcript-entry.ai { background: #fef3c7; border-left: 3px solid var(--warning); }
.transcript-label { font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; color: #6b7280; margin-bottom: 0.25rem; }
.transcript-text { font-size: 0.875rem; line-height: 1.5; }

/* Dashboard Stats */
.stat-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    transition: all var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}
.stat-icon.green { background: var(--primary-bg); color: var(--primary-dark); }
.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.purple { background: #f3e8ff; color: #9333ea; }
.stat-icon.orange { background: #ffedd5; color: #ea580c; }

/* Level Cards */
.level-card {
    display: block;
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-xl);
    background: white;
    transition: all var(--transition);
    text-decoration: none;
    color: inherit;
}
.level-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.level-card.completed { border-color: var(--secondary); background: #f0fdf4; }
.level-card.in-progress { border-color: var(--warning); background: #fffbeb; }

/* Responsive */
@media (max-width: 639px) {
    .container { padding: 0 0.75rem; }
    .btn { padding: 0.5rem 1rem; }
    .card { border-radius: var(--radius-lg); }
    .modal { margin: 1rem; max-height: calc(100vh - 2rem); }
}

/* Print */
@media print {
    nav, footer, .btn, .flash-message { display: none !important; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}