/* --- CORE THEME & CSS VARIABLES --- */
:root {
    --brand-color: #B91C1C;
    --brand-hover: #991B1B;
    --brand-gradient: linear-gradient(135deg, var(--brand-color), #DC2626);
    --bg-dark: #090D16;
    --bg-card: rgba(18, 24, 38, 0.75);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --danger-color: #EF4444;
    --success-color: #10B981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    padding-bottom: 80px; /* For mobile bottom nav */
}

/* Background Glowing Orbs */
.bg-glow-1 {
    position: fixed;
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.15) 0%, rgba(0, 0, 0, 0) 70%);
    z-index: -2;
    filter: blur(60px);
    pointer-events: none;
}

.bg-glow-2 {
    position: fixed;
    bottom: -10%;
    right: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, rgba(0, 0, 0, 0) 70%);
    z-index: -2;
    filter: blur(60px);
    pointer-events: none;
}

/* --- GLASSMORPHISM PANELS --- */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-navbar {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.glass-pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    padding: 6px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.glass-input, .glass-select {
    width: 100%;
    padding: 14px 18px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.glass-input:focus, .glass-select:focus {
    border-color: var(--brand-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

/* --- BUTTONS --- */
.btn-primary {
    background: var(--brand-gradient);
    color: white;
    border: none;
    border-radius: 14px;
    padding: 14px 24px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(59, 130, 246, 0.45);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 12px 20px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-tool {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-tool:hover {
    background: var(--brand-color);
    border-color: var(--brand-color);
}

.btn-icon-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #FCA5A5;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* --- SCREENS --- */
.screen {
    width: 100%;
    min-height: 100vh;
}

.screen.hidden, .tab-content.hidden, .modal.hidden, .hidden {
    display: none !important;
}

/* --- LOGIN SCREEN --- */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-height: 100vh;
}

.login-card {
    width: 100%;
    max-width: 440px;
    padding: 40px 36px;
    text-align: center;
}

.logo-container {
    margin-bottom: 16px;
}

.logo-emoji {
    font-size: 56px;
    display: inline-block;
}

.logo-emoji img {
    background: transparent;
    padding: 0;
    border: none !important;
    outline: none !important;
    border-radius: 24px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
    max-width: 220px;
    height: auto !important;
    display: inline-block;
}

.brand-emoji img {
    background: transparent;
    padding: 0;
    border-radius: 6px;
    height: 32px !important;
    width: auto;
}

.login-header h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(to right, #FFFFFF, #94A3B8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

.input-group {
    text-align: left;
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
}

.input-wrapper input {
    width: 100%;
    padding: 14px 14px 14px 44px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: all 0.2s;
}

.input-wrapper input:focus {
    border-color: var(--brand-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.error-banner, .success-banner {
    padding: 12px;
    border-radius: 12px;
    font-size: 14px;
    margin-bottom: 20px;
    font-weight: 500;
}

.error-banner {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #FCA5A5;
}

.success-banner {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6EE7B7;
}

.login-card .btn-primary {
    width: 100%;
    margin-top: 10px;
}

.login-footer {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
    font-size: 12px;
    color: var(--text-secondary);
}

/* --- MAIN LAYOUT --- */
.main-layout {
    display: flex;
    min-height: calc(100vh - 70px);
}

/* Desktop Sidebar */
.sidebar {
    width: 260px;
    margin: 20px 0 20px 20px;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--brand-gradient);
    color: white;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.25);
}

.nav-icon {
    font-size: 20px;
}

.content-area {
    flex: 1;
    padding: 20px 24px;
    overflow-y: auto;
}

/* --- DASHBOARD TAB --- */
.dashboard-header {
    margin-bottom: 24px;
}

.dashboard-header h2, .vocab-header h2, .branding-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 28px;
    font-weight: 700;
}

.section-desc {
    color: var(--text-secondary);
    font-size: 15px;
    margin-top: 4px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
}

.stat-details h3 {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-number {
    font-family: 'Outfit', sans-serif;
    font-size: 32px;
    font-weight: 700;
    margin-top: 4px;
    color: var(--text-primary);
}

.dashboard-banner {
    padding: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
    border-left: 4px solid var(--brand-color);
}

.banner-content h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.banner-content p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    max-width: 600px;
}

.banner-icon {
    font-size: 48px;
}

/* --- PDF TAB --- */
.pdf-toolbar {
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-badge, .zoom-badge {
    background: rgba(255, 255, 255, 0.08);
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.pdf-viewer-container {
    min-height: 500px;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: auto;
    background: rgba(9, 13, 22, 0.6);
    margin-bottom: 16px;
}

.pdf-canvas-wrapper img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.pdf-hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.quick-translate-bar {
    padding: 16px;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.translate-result-box {
    width: 100%;
    margin-top: 12px;
    padding: 14px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
}

/* --- VOCABULARY TAB --- */
.vocab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.flashcard-arena {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 36px;
}

.flashcard {
    width: 100%;
    max-width: 500px;
    min-height: 240px;
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    position: relative;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(24, 32, 47, 0.9));
    border: 2px solid rgba(59, 130, 246, 0.3);
}

.flashcard:hover {
    transform: translateY(-4px) scale(1.02);
    border-color: var(--brand-color);
}

.card-lang {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--brand-color);
    margin-bottom: 12px;
}

.flashcard h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 16px;
}

.flip-hint {
    font-size: 12px;
    color: var(--text-secondary);
    position: absolute;
    bottom: 16px;
}

.card-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
}

.card-count-badge {
    font-weight: 700;
    font-size: 16px;
}

.vocab-table-wrapper {
    overflow-x: auto;
    padding: 20px;
}

.vocab-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.vocab-table th {
    padding: 14px;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
}

.vocab-table td {
    padding: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 15px;
}

/* --- AI TUTOR TAB --- */
.ai-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    padding: 24px;
}

.ai-header {
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.ai-title-box {
    display: flex;
    align-items: center;
    gap: 16px;
}

.ai-avatar {
    font-size: 36px;
    width: 54px;
    height: 54px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-status {
    font-size: 13px;
    color: var(--success-color);
    margin-top: 2px;
}

.ai-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-right: 10px;
    margin-bottom: 20px;
}

.msg {
    max-width: 80%;
    padding: 16px 20px;
    border-radius: 18px;
    line-height: 1.5;
}

.msg-ai {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--glass-border);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.msg-user {
    background: var(--brand-gradient);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.msg-sender {
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
    opacity: 0.8;
}

.ai-input-bar {
    display: flex;
    gap: 12px;
}

/* --- BRANDING TAB --- */
.branding-card {
    padding: 32px;
    max-width: 800px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.color-picker-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
}

.color-picker-wrapper input[type="color"] {
    width: 50px;
    height: 48px;
    border: none;
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
}

/* --- MODAL --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    width: 100%;
    max-width: 440px;
    padding: 32px;
}

.modal-content h3 {
    margin-bottom: 20px;
    font-family: 'Outfit', sans-serif;
}

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

/* --- RESPONSIVE MOBILE / TABLET DESIGN (PWA) --- */
@media (max-width: 900px) {
    body {
        padding-bottom: 80px; /* Space for bottom nav */
    }

    .main-layout {
        flex-direction: column;
    }

    /* Transform Sidebar to Bottom Navigation Bar for Tablets & Phones! */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 72px;
        margin: 0;
        padding: 8px 12px;
        border-radius: 24px 24px 0 0;
        border-top: 1px solid var(--glass-border);
        border-bottom: none;
        z-index: 500;
        background: rgba(15, 23, 42, 0.92);
        backdrop-filter: blur(28px);
    }

    .nav-links {
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        height: 100%;
    }

    .nav-item {
        flex-direction: column;
        gap: 4px;
        padding: 6px 12px;
        font-size: 11px;
        border-radius: 12px;
        text-align: center;
    }

    .nav-icon {
        font-size: 22px;
    }

    .content-area {
        padding: 16px;
        margin-bottom: 60px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .dashboard-banner {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .nav-text {
        font-size: 10px;
    }

    .top-navbar {
        padding: 10px 16px;
    }

    .brand-title {
        font-size: 15px;
    }

    .user-name {
        display: none; /* Hide username on tiny screens to save space */
    }
}
