/* ==========================================================================
   LangLearn — Mobile-first responsive styles
   ========================================================================== */

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    color: #1e293b;
    background: #f8fafc;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
main { flex: 1; }

/* Links */
a { color: #3b82f6; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Container */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }

/* ── Navigation ───────────────────────────────────────────────────── */
.navbar {
    background: #1e3a5f;
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.navbar .nav-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    max-width: 1100px;
    margin: 0 auto;
}
.navbar .logo {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: white;
}
.navbar .logo span { color: #f59e0b; }
.navbar .hamburger {
    display: block;
    background: none;
    border: none;
    color: white;
    font-size: 1.6rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}
.navbar .nav-links {
    display: none;
    flex-direction: column;
    background: #162d4a;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    padding: 0.5rem 0;
}
.navbar .nav-links.open { display: flex; }
.navbar .nav-links a,
.navbar .nav-links span {
    color: #e2e8f0;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.navbar .nav-links a:hover { background: rgba(255,255,255,0.08); text-decoration: none; }
.navbar .nav-links .user-email {
    color: #94a3b8;
    font-size: 0.8rem;
    padding: 0.5rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
@media (min-width: 768px) {
    .navbar .hamburger { display: none; }
    .navbar .nav-links {
        display: flex !important;
        flex-direction: row;
        position: static;
        background: transparent;
        align-items: center;
        gap: 0.25rem;
        padding: 0;
    }
    .navbar .nav-links a,
    .navbar .nav-links span {
        border: none;
        padding: 0.4rem 0.75rem;
        border-radius: 6px;
    }
    .navbar .nav-links a:hover { background: rgba(255,255,255,0.12); }
}

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 0.65rem 1.4rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
    min-height: 44px;
}
.btn-primary { background: #3b82f6; color: white; }
.btn-primary:hover { background: #2563eb; text-decoration: none; }
.btn-secondary { background: #e2e8f0; color: #475569; }
.btn-secondary:hover { background: #cbd5e1; text-decoration: none; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; min-height: 32px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Cards ─────────────────────────────────────────────────────────── */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    padding: 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid #e2e8f0;
}
.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
@media (min-width: 640px) { .card-grid.cols-2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .card-grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .card-grid.cols-4 { grid-template-columns: repeat(4, 1fr); } }

/* ── Badges ────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-news { background: #dbeafe; color: #1e40af; }
.badge-tech { background: #e0e7ff; color: #3730a3; }
.badge-science { background: #dcfce7; color: #166534; }
.badge-sport { background: #fef3c7; color: #92400e; }
.badge-book { background: #f3e8ff; color: #6b21a8; }
.badge-chat { background: #dbeafe; color: #1e40af; }

/* ── Flash Messages ────────────────────────────────────────────────── */
.flash { padding: 0.75rem 1rem; border-radius: 8px; margin: 0.75rem 1rem; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Landing ───────────────────────────────────────────────────────── */
.hero {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: white;
    text-align: center;
    padding: 3rem 1.2rem;
}
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); margin-bottom: 0.75rem; }
.hero p { font-size: clamp(1rem, 3vw, 1.2rem); opacity: 0.9; max-width: 600px; margin: 0 auto 1.5rem; }
.feature-card {
    text-align: center;
    padding: 1.5rem;
}
.feature-card .icon { font-size: 2.2rem; margin-bottom: 0.5rem; }
.feature-card h3 { font-size: 1.1rem; margin-bottom: 0.4rem; }
.feature-card p { color: #64748b; font-size: 0.9rem; }
.steps { background: #f1f5f9; padding: 2rem 1rem; margin: 2rem 0; }
.steps ol { max-width: 600px; margin: 0 auto; }
.steps li { padding: 0.5rem 0; font-size: 1rem; }
.cta-section { text-align: center; padding: 2rem 1rem; }

/* ── Dashboard ─────────────────────────────────────────────────────── */
.usage-bar {
    height: 10px;
    border-radius: 5px;
    background: #e2e8f0;
    margin: 0.5rem 0;
    overflow: hidden;
}
.usage-bar .fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.3s;
}
.usage-bar .fill.good { background: #22c55e; }
.usage-bar .fill.warn { background: #f59e0b; }
.usage-bar .fill.danger { background: #ef4444; }
.stat-card { text-align: center; padding: 1rem; background: white; border-radius: 10px; border: 1px solid #e2e8f0; }

/* ── Chat ──────────────────────────────────────────────────────────── */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    max-width: 700px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
}
.chat-header {
    background: #1e3a5f;
    color: white;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.chat-bubble {
    max-width: 80%;
    padding: 0.6rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
}
.chat-bubble.user {
    align-self: flex-end;
    background: #3b82f6;
    color: white;
    border-bottom-right-radius: 4px;
}
.chat-bubble.ai {
    align-self: flex-start;
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 4px;
}
.chat-input {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid #e2e8f0;
    background: #fafafa;
}
.chat-input input {
    flex: 1;
    padding: 0.65rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    min-height: 44px;
}
.chat-input button {
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.recording-indicator {
    color: #ef4444;
    animation: pulse 1s infinite;
    font-weight: bold;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.topic-suggestion {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #1e40af;
}

/* ── Reader (News / Books) ─────────────────────────────────────────── */
.reader-container {
    max-width: 750px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
}
.reader-tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
}
.reader-tabs button {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: #f8fafc;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.15s;
    min-height: 44px;
}
.reader-tabs button.active {
    background: white;
    border-bottom: 2px solid #3b82f6;
    color: #1e3a5f;
    font-weight: 600;
}
.reader-content { padding: 1.5rem; }
.reader-content .en-text { font-size: 1.05rem; line-height: 1.8; margin-bottom: 1rem; }
.reader-content .it-text {
    font-size: 1rem;
    line-height: 1.7;
    color: #64748b;
    margin-bottom: 1.5rem;
    padding-left: 1rem;
    border-left: 3px solid #e2e8f0;
}
.word {
    cursor: pointer;
    border-bottom: 1px dotted #94a3b8;
    transition: background 0.15s;
}
.word:hover { background: #fef3c7; }
.translation-popup {
    position: fixed;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    padding: 1rem;
    z-index: 200;
    min-width: 180px;
    max-width: 280px;
    font-size: 0.9rem;
}
.translation-popup .word-en { font-weight: 600; color: #1e3a5f; margin-bottom: 0.3rem; }
.translation-popup .word-it { color: #64748b; margin-bottom: 0.75rem; }
.reader-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    background: #fafafa;
}
.chapter-indicator { font-size: 0.85rem; color: #64748b; }

/* ── Audio Player ──────────────────────────────────────────────────── */
audio { width: 100%; margin: 0.5rem 0; border-radius: 8px; }

/* ── Admin Tabs ────────────────────────────────────────────────────── */
.admin-tabs { display: flex; border-bottom: 2px solid #e2e8f0; margin-bottom: 1.5rem; overflow-x: auto; }
.admin-tabs button {
    padding: 0.6rem 1.2rem;
    border: none;
    background: transparent;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
    min-height: 44px;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.admin-tabs button.active { border-bottom-color: #3b82f6; color: #3b82f6; font-weight: 600; }
.admin-tab-content { display: none; }
.admin-tab-content.active { display: block; }

/* ── Tables ────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid #e2e8f0; font-size: 0.9rem; }
th { background: #f8fafc; font-weight: 600; color: #475569; }

/* ── Spinner ───────────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer ────────────────────────────────────────────────────────── */
footer {
    background: #1e3a5f;
    color: #94a3b8;
    text-align: center;
    padding: 1.25rem;
    font-size: 0.85rem;
    margin-top: auto;
}

/* ── Utilities ─────────────────────────────────────────────────────── */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.p-2 { padding: 1rem; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.text-sm { font-size: 0.85rem; }
.text-muted { color: #64748b; }
.font-bold { font-weight: 700; }

/* ── Form elements ─────────────────────────────────────────────────── */
input, textarea, select {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    min-height: 44px;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
label { display: block; margin-bottom: 0.3rem; font-weight: 500; font-size: 0.9rem; }
.form-group { margin-bottom: 1rem; }
.form-card {
    max-width: 440px;
    margin: 2rem auto;
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* ── Empty State ───────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
}
.empty-state .icon { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-state p { font-size: 1rem; }

/* ── Vocabulary cards (mobile) ─────────────────────────────────────── */
.vocab-card { display: none; }
@media (max-width: 699px) {
    .vocab-table { display: none; }
    .vocab-card {
        display: block;
        background: white;
        border-radius: 10px;
        padding: 1rem;
        margin-bottom: 0.75rem;
        border: 1px solid #e2e8f0;
    }
}

/* ── Section ───────────────────────────────────────────────────────── */
.section { padding: 2rem 1rem; }
.section h2 { font-size: 1.3rem; margin-bottom: 1rem; }
.page-header { padding: 1.5rem 1rem; background: white; border-bottom: 1px solid #e2e8f0; }
.page-header h1 { font-size: 1.4rem; }
