/* ============================================================
   SALEEM — REDESIGNED DESIGN SYSTEM
   Pure dark-mode utility app for refugees in Egypt
   ============================================================ */

:root {
    /* ── Core Dark Palette (refined, not pure black) ── */
    --bg-dark: #111827;
    --surface-dark: #1F2937;
    --surface-elevated: #374151;
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-border-strong: rgba(255, 255, 255, 0.18);
    --text-light: #F9FAFB;
    --text-muted: #9CA3AF;
    --text-dim: #6B7280;

    /* ── Brand ── */
    --nile-blue: #0F4C81;
    --nile-dark: #0A3358;
    --warm-sand: #E8AB63;
    --emerald: #10B981;
    --coral: #EF4444;

    /* ── Section Accent Colors ── */
    --accent-translator: #E8AB63;
    --accent-assistant: #818CF8;
    --accent-culture: #F472B6;
    --accent-legal: #FBBF24;
    --accent-services: #34D399;
    --accent-community: #60A5FA;
    --accent-learning: #A78BFA;
    --accent-awareness: #FB923C;
    --accent-profile: #94A3B8;

    /* ── Spacing & Radius ── */
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* ── Typography ── */
    --font-primary: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --fs-section-title: 22px;
    --fs-card-title: 17px;
    --fs-body: 14px;
    --fs-label: 12px;
    --fs-overline: 11px;
    --fw-bold: 700;
    --fw-semibold: 600;
    --fw-medium: 500;
    --fw-regular: 400;

    /* ── Transitions ── */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ============================================================
   DUOLINGO SNAKE PATH & GAMIFICATION STYLES
   ============================================================ */
.track-switch-container {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    background: rgba(15, 23, 42, 0.6);
    padding: 8px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}

.track-btn {
    flex: 1;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.track-btn.active {
    background: var(--warm-sand);
    color: var(--nile-dark);
    box-shadow: 0 4px 14px rgba(232, 171, 99, 0.3);
}

.duolingo-snake-wrapper {
    position: relative;
    max-width: 650px;
    margin: 0 auto;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

.duolingo-snake-node {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1E293B, #0F172A);
    border: 4px solid var(--glass-border-strong);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    z-index: 2;
}

.duolingo-snake-node:hover {
    transform: scale(1.12);
    box-shadow: 0 12px 28px rgba(232, 171, 99, 0.4);
}

.duolingo-snake-node.completed {
    background: linear-gradient(135deg, #10B981, #059669);
    border-color: #34D399;
    color: white;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
}

.duolingo-snake-node.active {
    background: linear-gradient(135deg, #E8AB63, #D97706);
    border-color: #FBBF24;
    color: var(--nile-dark);
    animation: pulseGlow 2s infinite;
}

.duolingo-snake-node.locked {
    opacity: 0.5;
    cursor: not-allowed;
    border-style: dashed;
}

.duolingo-snake-node i {
    font-size: 24px;
}

.duolingo-snake-node .node-label {
    position: absolute;
    bottom: -28px;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 600;
    color: var(--warm-sand);
    background: rgba(15, 23, 42, 0.9);
    padding: 3px 10px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.leaderboard-table th, .leaderboard-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

.leaderboard-table tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: bold;
    font-size: 12px;
}

.rank-1 { background: #F59E0B; color: #78350F; }
.rank-2 { background: #94A3B8; color: #0F172A; }
.rank-3 { background: #B45309; color: #FFFBEB; }

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(232, 171, 99, 0.7); }
    50% { box-shadow: 0 0 0 16px rgba(232, 171, 99, 0); }
}

html, body {
    font-family: var(--font-primary);
    background-color: var(--bg-dark);
    color: var(--text-light);
    height: 100vh;
    height: 100dvh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    overflow-y: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Fix dropdown option contrast for dark mode */
select option {
    background-color: var(--surface-dark) !important;
    color: #FFFFFF !important;
    padding: 12px !important;
    font-size: var(--fs-body) !important;
}
#ui-lang-switcher option {
    background-color: var(--bg-dark) !important;
    color: var(--text-light) !important;
    padding: 10px !important;
}

/* ============================================================
   LAYOUT — Desktop: Sidebar + Main / Mobile: Main + Bottom Nav
   ============================================================ */
.app-layout {
    display: flex;
    height: 100vh;
    height: 100dvh;
}

/* ── Desktop Sidebar ── */
.sidebar {
    width: 260px;
    background: var(--surface-dark);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    flex-shrink: 0;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
    padding: 0 4px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    background: var(--warm-sand);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--nile-dark);
    flex-shrink: 0;
}

.saleem-brand-mark {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: inherit;
}

.brand-info h1 {
    font-size: 18px;
    font-weight: var(--fw-bold);
    letter-spacing: -0.3px;
}

.brand-info span {
    font-size: var(--fs-overline);
    color: var(--warm-sand);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: var(--fs-body);
    font-weight: var(--fw-medium);
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: left;
    white-space: nowrap;
    width: 100%;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
}

/* Section-specific accent colors on nav items */
.nav-item[data-tab="tab-translator"] i { color: var(--accent-translator); }
.nav-item[data-tab="tab-assistant"] i { color: var(--accent-assistant); }
.nav-item[data-tab="tab-culture"] i { color: var(--accent-culture); }
.nav-item[data-tab="tab-legal"] i { color: var(--accent-legal); }
.nav-item[data-tab="tab-services"] i { color: var(--accent-services); }
.nav-item[data-tab="tab-community"] i { color: var(--accent-community); }
.nav-item[data-tab="tab-learning"] i { color: var(--accent-learning); }
.nav-item[data-tab="tab-awareness"] i { color: var(--accent-awareness); }
.nav-item[data-tab="tab-profile"] i { color: var(--accent-profile); }

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

.nav-item.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-light);
    font-weight: var(--fw-semibold);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    margin-top: 12px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--warm-sand);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--nile-dark);
    font-size: 16px;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-size: 13px;
    font-weight: var(--fw-semibold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status {
    font-size: var(--fs-overline);
    color: var(--emerald);
}

/* ============================================================
   MOBILE BOTTOM NAVIGATION
   ============================================================ */
.bottom-nav {
    display: none; /* shown via media query */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--surface-dark);
    border-top: 1px solid var(--glass-border);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.bottom-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
    position: relative;
    -webkit-tap-highlight-color: transparent;
    min-width: 56px;
}

.bottom-nav-btn i {
    font-size: 20px;
    transition: transform var(--transition-fast);
}

.bottom-nav-btn span {
    font-size: 10px;
    font-weight: var(--fw-medium);
    letter-spacing: 0.2px;
    line-height: 1;
}

.bottom-nav-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 28px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    transition: transform var(--transition-smooth);
}

.bottom-nav-btn.active {
    color: var(--text-light);
}

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

.bottom-nav-btn.active i {
    transform: scale(1.1);
}

/* Bottom nav accent colors */
.bottom-nav-btn[data-tab="tab-translator"] { --btn-accent: var(--accent-translator); }
.bottom-nav-btn[data-tab="tab-assistant"] { --btn-accent: var(--accent-assistant); }
.bottom-nav-btn[data-tab="tab-services"] { --btn-accent: var(--accent-services); }
.bottom-nav-btn[data-tab="tab-legal"] { --btn-accent: var(--accent-legal); }
.bottom-nav-btn[data-tab="more"] { --btn-accent: var(--text-muted); }

.bottom-nav-btn.active {
    color: var(--btn-accent, var(--warm-sand));
}
.bottom-nav-btn.active::before {
    background: var(--btn-accent, var(--warm-sand));
}

/* ============================================================
   MORE DRAWER (slide-up overlay for secondary nav)
   ============================================================ */
.more-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1100;
    opacity: 0;
    transition: opacity var(--transition-smooth);
}

.more-backdrop.open {
    display: block;
    opacity: 1;
}

.more-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface-dark);
    border-top-left-radius: var(--radius-xl);
    border-top-right-radius: var(--radius-xl);
    z-index: 1200;
    transform: translateY(100%);
    transition: transform var(--transition-smooth);
    padding: 8px 16px 24px 16px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    max-height: 60vh;
    overflow-y: auto;
}

.more-drawer.open {
    transform: translateY(0);
}

.more-drawer-handle {
    width: 36px;
    height: 4px;
    background: var(--text-dim);
    border-radius: var(--radius-full);
    margin: 8px auto 16px auto;
}

.more-drawer-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 15px;
    font-weight: var(--fw-medium);
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.more-drawer-item:hover,
.more-drawer-item:active {
    background: rgba(255, 255, 255, 0.06);
}

.more-drawer-item i {
    width: 24px;
    font-size: 18px;
    text-align: center;
}

.more-drawer-item[data-tab="tab-culture"] i { color: var(--accent-culture); }
.more-drawer-item[data-tab="tab-community"] i { color: var(--accent-community); }
.more-drawer-item[data-tab="tab-learning"] i { color: var(--accent-learning); }
.more-drawer-item[data-tab="tab-awareness"] i { color: var(--accent-awareness); }
.more-drawer-item[data-tab="tab-profile"] i { color: var(--accent-profile); }

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
    overflow: hidden;
    min-width: 0;
}

.top-header {
    height: 64px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--glass-border);
    gap: 16px;
    flex-shrink: 0;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-dark);
    padding: 9px 16px;
    border-radius: var(--radius-full);
    flex: 1;
    max-width: 400px;
    border: 1px solid var(--glass-border);
    transition: border-color var(--transition-fast);
}

.search-bar:focus-within {
    border-color: var(--warm-sand);
}

.search-bar input {
    background: transparent;
    border: none;
    color: var(--text-light);
    outline: none;
    width: 100%;
    font-size: 13px;
}

.search-bar input::placeholder {
    color: var(--text-dim);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 14px;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: var(--fw-semibold);
    font-size: var(--fs-body);
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    line-height: 1.2;
}

.btn-primary {
    background: var(--warm-sand);
    color: var(--nile-dark);
}

.btn-primary:hover {
    background: #d49852;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(232, 171, 99, 0.25);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--glass-border-strong);
    color: var(--text-light);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.25);
}

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

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

/* ============================================================
   CONTENT VIEWPORT & TAB PANES
   ============================================================ */
.content-container {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.tab-pane {
    display: none;
    animation: fadeInTab 300ms ease;
}

.tab-pane.active {
    display: block;
}

@keyframes fadeInTab {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   CARDS — Refined hierarchy
   ============================================================ */
.card {
    background: var(--surface-dark);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    transition: border-color var(--transition-fast);
}

/* ── Header Card — section identity card with accent left border ── */
.header-card {
    border-left: 4px solid var(--warm-sand);
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--surface-dark) 0%, rgba(31, 41, 55, 0.6) 100%);
}

.header-card h2 {
    font-size: var(--fs-section-title);
    font-weight: var(--fw-bold);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.3px;
    line-height: 1.3;
}

.header-card p {
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.5;
}

/* Section-specific header card accents */
#tab-translator .header-card { border-left-color: var(--accent-translator); }
#tab-translator .header-card .text-gold { color: var(--accent-translator); }

#tab-assistant .header-card { border-left-color: var(--accent-assistant); }
#tab-assistant .header-card .text-gold { color: var(--accent-assistant); }

#tab-culture .header-card { border-left-color: var(--accent-culture); }
#tab-culture .header-card .text-gold { color: var(--accent-culture); }

#tab-legal .header-card { border-left-color: var(--accent-legal); }
#tab-legal .header-card .text-gold { color: var(--accent-legal); }

#tab-services .header-card { border-left-color: var(--accent-services); }
#tab-services .header-card .text-gold { color: var(--accent-services); }

#tab-community .header-card { border-left-color: var(--accent-community); }
#tab-community .header-card .text-gold { color: var(--accent-community); }

#tab-learning .header-card { border-left-color: var(--accent-learning); }
#tab-learning .header-card .text-gold { color: var(--accent-learning); }

#tab-awareness .header-card { border-left-color: var(--accent-awareness); }
#tab-awareness .header-card .text-gold { color: var(--accent-awareness); }

#tab-profile .header-card { border-left-color: var(--accent-profile); }
#tab-profile .header-card .text-gold { color: var(--accent-profile); }

/* ── Action Cards — elevated with subtle glow for CTAs ── */
.card.action-card {
    border-color: var(--glass-border-strong);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.card.action-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

/* ── Card titles ── */
.card h3 {
    font-size: var(--fs-card-title);
    font-weight: var(--fw-semibold);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.4;
}

.card p {
    font-size: var(--fs-body);
    color: var(--text-muted);
    line-height: 1.6;
}

/* ── Tag Pills — ghost/outline style ── */
.card-badge, .tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: var(--fs-overline);
    font-weight: var(--fw-semibold);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: transparent;
    border: 1px solid;
    line-height: 1.4;
}

/* Default tag colors */
.card-badge {
    border-color: rgba(244, 114, 182, 0.4);
    color: #F472B6;
}

.tag {
    border-color: rgba(52, 211, 153, 0.4);
    color: var(--emerald);
}

.tag-ngo {
    border-color: rgba(96, 165, 250, 0.4);
    color: var(--accent-community);
}

.tag-health {
    border-color: rgba(251, 191, 36, 0.4);
    color: var(--accent-legal);
}

/* ── Guide / Course Cards ── */
.guide-card, .course-card {
    transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.guide-card:hover, .course-card:hover {
    border-color: rgba(255, 255, 255, 0.18);
    transform: translateY(-2px);
}

.guide-card .card-badge {
    margin-bottom: 12px;
}

.course-card .tag {
    margin-bottom: 12px;
}

/* ── Service Cards ── */
.service-card .service-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.service-card .phone {
    font-size: 13px;
    color: var(--emerald);
    margin-top: 6px;
    display: inline-block;
}

/* ============================================================
   SUB-TABS — Segmented control / chip-style
   ============================================================ */
.sub-tabs {
    display: flex;
    gap: 8px;
    padding: 4px;
    background: var(--bg-dark);
    border-radius: var(--radius-full);
    border: 1px solid var(--glass-border);
    margin-bottom: 20px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sub-tabs::-webkit-scrollbar {
    display: none;
}

.sub-tab-btn {
    padding: 8px 18px;
    border-radius: var(--radius-full);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: var(--fw-medium);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.sub-tab-btn:hover {
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.05);
}

.sub-tab-btn.active {
    background: var(--warm-sand);
    color: var(--nile-dark);
    font-weight: var(--fw-semibold);
    border-color: transparent;
}

/* ============================================================
   TRANSLATOR MODULE
   ============================================================ */
.translator-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.lang-selector {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 14px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.lang-selector select {
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    color: var(--text-light);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    outline: none;
    font-size: 12px;
    flex: 1;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

.swap-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    color: var(--warm-sand);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.swap-btn:hover {
    background: rgba(232, 171, 99, 0.15);
}

.translate-box textarea {
    width: 100%;
    height: 130px;
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 14px;
    color: var(--text-light);
    resize: none;
    outline: none;
    margin-bottom: 14px;
    font-family: var(--font-primary);
    font-size: var(--fs-body);
    transition: border-color var(--transition-fast);
}

.translate-box textarea:focus {
    border-color: var(--accent-translator);
}

.translate-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.translate-actions .btn {
    flex: 1;
    min-width: 0;
    justify-content: center;
    padding: 10px 8px;
    font-size: 12px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

/* Waveform animation */
.waveform-container {
    height: 30px;
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
    margin-bottom: 14px;
    opacity: 0;
    transition: opacity var(--transition-smooth);
}

.waveform-container.active {
    opacity: 1;
}

.bar {
    width: 4px;
    height: 100%;
    background: var(--accent-translator);
    border-radius: var(--radius-full);
    animation: wave 1s infinite ease-in-out;
}

.bar:nth-child(2) { animation-delay: 0.1s; }
.bar:nth-child(3) { animation-delay: 0.2s; }
.bar:nth-child(4) { animation-delay: 0.3s; }

@keyframes wave {
    0%, 100% { height: 6px; }
    50% { height: 28px; }
}

/* Slang dictionary */
.slang-dictionary-widget h4 {
    font-size: 15px;
    font-weight: var(--fw-semibold);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.slang-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.slang-item {
    padding: 10px 14px;
    background: var(--bg-dark);
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
}

.slang-word {
    font-size: 14px;
    font-weight: var(--fw-semibold);
    color: var(--warm-sand);
    margin-bottom: 3px;
}

.slang-meaning {
    font-size: 13px;
    color: var(--text-muted);
}

/* ============================================================
   CHAT / AI ASSISTANT
   ============================================================ */
.chat-container {
    height: calc(100vh - 220px);
    display: flex;
    flex-direction: column;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-right: 8px;
    scroll-behavior: smooth;
}

.chat-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
}

.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-assistant);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.chat-message.user .msg-avatar {
    background: var(--warm-sand);
    color: var(--nile-dark);
}

.msg-content {
    background: var(--bg-dark);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    font-size: var(--fs-body);
    line-height: 1.6;
}

.chat-message.user .msg-content {
    background: rgba(232, 171, 99, 0.1);
    border-color: rgba(232, 171, 99, 0.2);
}

.quick-questions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 0;
}

.chip-btn {
    padding: 7px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    color: var(--text-light);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    font-family: var(--font-primary);
}

.chip-btn:hover {
    background: rgba(129, 140, 248, 0.15);
    border-color: rgba(129, 140, 248, 0.3);
}

.chat-input-bar {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.chat-input-bar input {
    flex: 1;
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: var(--text-light);
    outline: none;
    font-size: var(--fs-body);
    font-family: var(--font-primary);
    transition: border-color var(--transition-fast);
}

.chat-input-bar input:focus {
    border-color: var(--accent-assistant);
}

/* ============================================================
   LEGAL — Checklist & Hotlines
   ============================================================ */
.checklist {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-dark);
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    font-size: var(--fs-body);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.check-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.check-item input[type="checkbox"] {
    accent-color: var(--accent-legal);
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.hotline-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hotline-list li {
    padding: 10px 14px;
    background: var(--bg-dark);
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    font-size: var(--fs-body);
    line-height: 1.5;
}

.hotline-list li strong {
    color: var(--accent-legal);
}

/* ============================================================
   COMMUNITY — Ask box
   ============================================================ */
.ask-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ask-box input, .ask-box textarea {
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    color: var(--text-light);
    font-size: var(--fs-body);
    font-family: var(--font-primary);
    outline: none;
    transition: border-color var(--transition-fast);
}

.ask-box input:focus, .ask-box textarea:focus {
    border-color: var(--accent-community);
}

.ask-box textarea {
    resize: vertical;
    min-height: 80px;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-control {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    color: white;
    margin-bottom: 12px;
    font-size: var(--fs-body);
    font-family: var(--font-primary);
    outline: none;
    transition: border-color var(--transition-fast);
}

.form-control:focus {
    border-color: var(--warm-sand);
}

/* ============================================================
   GRID UTILITIES
   ============================================================ */
/* ============================================================
   GRID UTILITIES — Fluid Auto-Fit Grids
   ============================================================ */
.grid-2 { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); 
    gap: 20px; 
}
.grid-3 { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); 
    gap: 20px; 
}

/* ============================================================
   TEXT UTILITIES
   ============================================================ */
.text-gold { color: var(--warm-sand); }

.placeholder-text {
    color: var(--text-dim);
    font-style: italic;
}

.service-location-tools {
    display: grid;
    gap: 10px;
    padding: 12px;
    margin-bottom: 16px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: rgba(15, 76, 129, 0.12);
}

.service-location-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.service-location-status {
    min-height: 18px;
    color: var(--text-muted);
    font-size: 12px;
}

.manual-area-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    align-items: end;
}

.manual-area-panel[hidden] {
    display: none;
}

.manual-area-panel label,
.service-sort-control {
    color: var(--text-muted);
    font-size: 12px;
}

.service-sort-select {
    width: min(220px, 100%);
    margin: 0;
}

.service-location-tools .btn,
.manual-area-panel .form-control,
.service-sort-select {
    min-height: 44px;
}

@media (prefers-reduced-motion: no-preference) {
    .service-location-tools,
    #institutions-directory-grid .card {
        animation: saleem-fade-in 240ms ease both;
    }
}

@keyframes saleem-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   RTL SUPPORT
   ============================================================ */
[dir="rtl"] .header-card {
    border-left: none;
    border-right: 4px solid var(--warm-sand);
}

[dir="rtl"] #tab-translator .header-card { border-right-color: var(--accent-translator); }
[dir="rtl"] #tab-assistant .header-card { border-right-color: var(--accent-assistant); }
[dir="rtl"] #tab-culture .header-card { border-right-color: var(--accent-culture); }
[dir="rtl"] #tab-legal .header-card { border-right-color: var(--accent-legal); }
[dir="rtl"] #tab-services .header-card { border-right-color: var(--accent-services); }
[dir="rtl"] #tab-community .header-card { border-right-color: var(--accent-community); }
[dir="rtl"] #tab-learning .header-card { border-right-color: var(--accent-learning); }
[dir="rtl"] #tab-awareness .header-card { border-right-color: var(--accent-awareness); }
[dir="rtl"] #tab-profile .header-card { border-right-color: var(--accent-profile); }

[dir="rtl"] .nav-item {
    text-align: right;
}

[dir="rtl"] .chat-message.user {
    flex-direction: row;
}
[dir="rtl"] .chat-message:not(.user) {
    flex-direction: row-reverse;
}

/* ============================================================
   FLUID ADAPTIVE RESPONSIVE BREAKPOINTS
   ============================================================ */

/* Mobile Phones (< 768px) */
@media (max-width: 767px) {
    .sidebar {
        display: none !important;
    }

    .desktop-only-btn {
        display: none !important;
    }

    .bottom-nav {
        display: block;
    }

    .app-layout {
        flex-direction: column;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .main-content {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .top-header .icon-btn {
        display: none !important;
    }

    .top-header {
        padding: 0 8px;
        height: 52px;
        gap: 6px;
        width: 100%;
        max-width: 100vw;
        overflow: hidden;
    }

    .search-bar {
        max-width: none;
        flex: 1;
        min-width: 0;
        padding: 6px 8px;
    }

    .search-bar input {
        font-size: 11px;
        width: 100%;
    }

    .header-actions {
        gap: 4px;
        flex-shrink: 0;
        min-width: 0;
    }

    .header-actions .btn {
        padding: 6px 8px;
        font-size: 11px;
        white-space: nowrap;
    }
        font-size: 11px;
    }

    #ui-lang-switcher {
        font-size: 11px !important;
        max-width: 110px;
    }

    .content-container {
        padding: 12px;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

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

    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .chat-container {
        height: calc(100vh - 180px);
        height: calc(100dvh - 180px);
    }

    .card {
        padding: 14px;
        border-radius: 14px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .header-card {
        padding: 16px;
    }

    .header-card h2 {
        font-size: 19px;
    }

    .service-location-actions,
    .service-location-actions .btn {
        width: 100%;
    }

    .manual-area-panel {
        grid-template-columns: 1fr;
    }

    .service-sort-select {
        width: 100%;
    }

    #institutions-directory-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }
}

/* Small Tablets & Foldables (768px – 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .sidebar {
        width: 210px;
        padding: 16px 12px;
    }

    .nav-item {
        padding: 10px 12px;
        font-size: 13px;
        gap: 10px;
    }

    .content-container {
        padding: 20px;
    }

    .grid-2 {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }

    .grid-3 {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}

/* Large Displays (> 1400px) */
@media (min-width: 1400px) {
    .content-container {
        max-width: 1350px;
        margin: 0 auto;
        width: 100%;
    }
}

/* ============================================================
   SALEEM PREMIUM PRODUCT LAYER
   The legacy markup and handlers stay intact; this layer gives every
   surface one calm, hopeful visual language across web and WebView.
   ============================================================ */
:root {
    --color-primary: #0f8f87;
    --color-primary-dark: #09645f;
    --color-primary-soft: #e2f3ef;
    --color-secondary: #123342;
    --color-background: #f4f7f5;
    --color-surface: #ffffff;
    --color-surface-elevated: #ffffff;
    --color-success: #258b64;
    --color-warning: #bc7c23;
    --color-danger: #c45751;
    --color-celebration: #e4ad45;
    --text-primary: #12313b;
    --text-secondary: #48606a;
    --text-muted: #71828a;
    --border-soft: #dce8e6;
    --shadow-soft: 0 10px 30px rgba(18, 51, 66, 0.08);
    --shadow-lift: 0 18px 42px rgba(18, 51, 66, 0.12);
    --radius-card: 18px;
    --radius-control: 12px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 32px;
    --space-8: 40px;
    --z-header: 20;
    --z-nav: 50;
    --z-modal: 100;

    --bg-dark: var(--color-background);
    --surface-dark: var(--color-surface);
    --surface-elevated: var(--color-surface-elevated);
    --glass-border: var(--border-soft);
    --glass-border-strong: #c8dcda;
    --text-light: var(--text-primary);
    --text-muted: var(--text-secondary);
    --text-dim: #8c9aa0;
    --nile-blue: var(--color-primary);
    --nile-dark: var(--color-secondary);
    --warm-sand: var(--color-celebration);
    --emerald: var(--color-success);
    --coral: var(--color-danger);
    --font-primary: 'Outfit', 'Inter', 'Noto Sans', 'Noto Sans Ethiopic', sans-serif;
}

html,
body {
    background: var(--color-background);
    color: var(--text-primary);
    min-height: 100%;
    height: 100%;
    overflow-x: hidden;
}

body {
    padding-top: env(safe-area-inset-top, 0px);
    font-size: 15px;
    line-height: 1.55;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a,
select,
input[type="checkbox"],
input[type="radio"] {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(15, 143, 135, 0.26);
    outline-offset: 2px;
}

.app-layout {
    min-height: 100dvh;
    background: var(--color-background);
}

.sidebar {
    width: 248px;
    padding: 24px 16px;
    background: var(--color-secondary);
    border: 0;
    box-shadow: 8px 0 28px rgba(18, 51, 66, 0.09);
    z-index: var(--z-nav);
}

.brand {
    padding: 2px 8px 28px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-link {
    gap: 12px !important;
}

.brand-logo {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--color-celebration);
    color: var(--color-secondary);
    box-shadow: 0 8px 18px rgba(228, 173, 69, 0.22);
}

.brand-info h1 {
    color: #fff;
    font-size: 22px;
    letter-spacing: 0;
}

.brand-info span {
    color: #9dc9c3;
    font-size: 11px;
    letter-spacing: 0;
}

.nav-menu {
    gap: 8px;
    padding: 24px 0;
}

.nav-item {
    min-height: 48px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 12px;
    color: #b4cbc9;
    font-weight: 600;
    letter-spacing: 0;
    transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

.nav-item i {
    width: 24px;
    color: #8ab8b2;
}

.nav-item:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(2px);
}

.nav-item.active {
    color: var(--color-secondary);
    background: #e4f1ee;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

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

.user-card {
    margin-top: auto;
    padding: 14px 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
}

.user-name {
    color: #fff;
    font-weight: 700;
}

.user-status {
    color: #a8c9c4;
    line-height: 1.35;
}

.avatar {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 6px 16px rgba(15, 143, 135, 0.22);
}

.main-content {
    min-width: 0;
    background: var(--color-background);
}

.top-header {
    min-height: 76px;
    height: auto;
    padding: 14px clamp(18px, 4vw, 48px);
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: 0 4px 18px rgba(18, 51, 66, 0.04);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: var(--z-header);
}

.search-bar {
    max-width: 520px;
    min-height: 44px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: #f8fbfa;
    color: var(--text-muted);
}

.search-bar:focus-within {
    border-color: rgba(15, 143, 135, 0.55);
    box-shadow: 0 0 0 4px rgba(15, 143, 135, 0.1);
}

.search-bar input,
.search-bar input::placeholder {
    color: var(--text-muted);
}

.header-actions {
    gap: 8px;
}

.header-actions > div {
    min-height: 44px;
    background: var(--color-primary-soft) !important;
    border: 1px solid #c9e4df !important;
    border-radius: 12px !important;
}

#ui-lang-switcher {
    color: var(--color-secondary) !important;
}

.icon-btn,
.header-actions .icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #f7faf9;
    border: 1px solid var(--border-soft);
}

.content-container {
    width: min(100%, 1440px);
    padding: clamp(20px, 3vw, 40px) clamp(16px, 4vw, 52px) calc(48px + env(safe-area-inset-bottom, 0px));
}

.tab-pane {
    animation: saleem-view-in 220ms ease both;
}

.card {
    background: var(--color-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-soft);
}

.card:hover {
    border-color: #c8dcda;
}

.header-card {
    padding: clamp(22px, 3vw, 34px);
    border-left: 5px solid var(--color-primary);
    background: var(--color-surface);
}

#tab-learn-translate > .header-card {
    color: #fff;
    background: var(--color-secondary);
    border-left-color: var(--color-celebration);
    box-shadow: var(--shadow-lift);
}

.header-card h2 {
    max-width: 860px;
    color: inherit;
    font-size: clamp(24px, 3vw, 36px);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: 0;
}

.header-card h2 i {
    color: var(--color-celebration) !important;
}

.header-card p {
    max-width: 720px;
    margin-top: 10px;
    color: inherit;
    opacity: 0.72;
    font-size: 15px;
}

.card h3,
.card h4 {
    color: var(--text-primary);
}

.text-gold {
    color: var(--color-celebration) !important;
}

.btn {
    min-height: 44px;
    padding: 10px 16px;
    border-radius: var(--radius-control);
    border-width: 1px;
    font-weight: 700;
    letter-spacing: 0;
    transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    color: #fff;
    background: var(--color-primary);
    border-color: var(--color-primary);
    box-shadow: 0 8px 18px rgba(15, 143, 135, 0.18);
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

.btn-outline {
    color: var(--color-primary-dark);
    background: #fff;
    border-color: #b9d5d1;
}

.btn-outline:hover {
    color: var(--color-primary-dark);
    background: var(--color-primary-soft);
    border-color: var(--color-primary);
}

.track-switch-container {
    gap: 6px;
    padding: 6px;
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    background: #eaf3f1;
}

.track-btn {
    min-height: 48px;
    padding: 10px 14px;
    color: var(--text-secondary);
    border-radius: 12px;
}

.track-btn.active {
    color: var(--color-secondary);
    background: #fff;
    box-shadow: 0 5px 14px rgba(18, 51, 66, 0.08);
}

.duolingo-snake-wrapper {
    max-width: 760px;
    padding: 28px 16px 38px;
}

.duolingo-snake-node {
    width: 76px;
    height: 76px;
    color: var(--text-secondary);
    background: #f1f7f5;
    border: 4px solid #cfe1de;
    box-shadow: 0 8px 20px rgba(18, 51, 66, 0.1);
}

.duolingo-snake-node.completed {
    background: var(--color-success);
    border-color: #77c89e;
}

.duolingo-snake-node.active {
    color: var(--color-secondary);
    background: var(--color-celebration);
    border-color: #f3cb72;
}

.duolingo-snake-node.locked {
    opacity: 0.58;
    background: #eef2f1;
}

.duolingo-snake-node .node-label {
    color: var(--color-secondary);
    background: #fff;
    border-color: var(--border-soft);
}

.leaderboard-table {
    overflow: hidden;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
}

.leaderboard-table th,
.leaderboard-table td {
    color: var(--text-secondary);
    border-bottom-color: var(--border-soft);
}

.leaderboard-table th {
    color: var(--text-primary);
    background: #f3f8f6;
    font-size: 12px;
}

.form-control,
.ask-box input,
.ask-box textarea,
.chat-input-bar input,
.translate-box textarea,
.lang-selector select,
.service-sort-select {
    color: var(--text-primary);
    background: #fbfdfc;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-control);
}

.form-control::placeholder,
.ask-box input::placeholder,
.ask-box textarea::placeholder,
.chat-input-bar input::placeholder,
.translate-box textarea::placeholder {
    color: #91a0a5;
}

.form-control:focus,
.ask-box input:focus,
.ask-box textarea:focus,
.chat-input-bar input:focus,
.translate-box textarea:focus,
.lang-selector select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(15, 143, 135, 0.1);
}

.chip-btn,
.sub-tab-btn {
    min-height: 40px;
    color: var(--text-secondary);
    background: #f3f8f6;
    border-color: var(--border-soft);
    border-radius: 999px;
    font-weight: 600;
}

.chip-btn:hover,
.chip-btn.active,
.sub-tab-btn.active {
    color: var(--color-primary-dark);
    background: var(--color-primary-soft);
    border-color: #a9d5cf;
}

.tag,
.card-badge {
    color: var(--color-primary-dark);
    background: var(--color-primary-soft);
    border-color: #b8ded8;
}

.chat-container {
    min-height: 560px;
    height: min(680px, calc(100dvh - 190px));
}

.chat-history {
    padding: 4px;
}

.msg-content {
    color: var(--text-primary);
    background: #f3f8f6;
    border-color: var(--border-soft);
}

.chat-message.user .msg-content {
    color: var(--color-secondary);
    background: var(--color-primary-soft);
    border-color: #b8ded8;
}

.msg-avatar {
    background: var(--color-primary);
}

.chat-message.user .msg-avatar {
    color: var(--color-secondary);
    background: var(--color-celebration);
}

.service-location-tools {
    padding: 16px;
    border-color: #cbe1dd;
    border-radius: 16px;
    background: #f1f8f6;
}

#institution-map {
    min-height: 260px;
    background: #dceee9 !important;
    border-color: #c6dfda !important;
}

#map-fallback-notice {
    background: #dceee9 !important;
    color: var(--color-secondary) !important;
}

#map-fallback-notice p {
    color: var(--text-secondary) !important;
}

.service-card,
#institutions-directory-grid .card,
#community-posts-list .card,
#reviews-feed-container .card {
    border-radius: 16px;
    box-shadow: 0 8px 22px rgba(18, 51, 66, 0.06);
}

.service-card .phone {
    color: var(--color-primary-dark);
}

.bottom-nav {
    display: none;
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--border-soft);
    box-shadow: 0 -8px 24px rgba(18, 51, 66, 0.08);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-inner {
    min-height: 70px;
    gap: 2px;
    padding: 6px 8px;
}

.bottom-nav-btn {
    min-height: 54px;
    color: #789098;
    border: 0;
    border-radius: 14px;
    background: transparent;
    font-weight: 600;
}

.bottom-nav-btn i {
    font-size: 17px;
}

.bottom-nav-btn.active {
    color: var(--color-primary-dark);
    background: var(--color-primary-soft);
}

.modal-overlay {
    background: rgba(18, 51, 66, 0.58) !important;
    backdrop-filter: blur(8px);
    padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px)) !important;
}

.modal-overlay > div {
    max-height: min(88dvh, 760px) !important;
    border: 1px solid #c8dcda !important;
    border-radius: 20px !important;
    background: #fff !important;
    color: var(--text-primary);
    box-shadow: var(--shadow-lift) !important;
}

.modal-overlay h2,
.modal-overlay h3,
.modal-overlay h4 {
    color: var(--text-primary);
}

#user-onboarding-modal {
    padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px)) !important;
    background: rgba(18, 51, 66, 0.72) !important;
    backdrop-filter: blur(12px) !important;
}

#user-onboarding-modal > .card {
    width: min(100%, 560px) !important;
    max-height: min(92dvh, 780px);
    overflow-y: auto;
    padding: clamp(22px, 5vw, 36px) !important;
    border: 1px solid #c8dcda !important;
    border-radius: 24px !important;
    background: #fff !important;
    color: var(--text-primary);
    box-shadow: var(--shadow-lift) !important;
}

#user-onboarding-modal h2,
#user-onboarding-modal label {
    color: var(--text-primary) !important;
}

#user-onboarding-modal p,
#user-onboarding-modal #onboard-sub {
    color: var(--text-secondary) !important;
}

#user-onboarding-modal .form-control,
#user-onboarding-modal select,
#user-onboarding-modal input {
    background: #fbfdfc !important;
    color: var(--text-primary) !important;
    border-color: var(--border-soft) !important;
}

#user-onboarding-modal .nat-btn {
    min-height: 46px;
    color: var(--text-secondary) !important;
    background: #f7faf9 !important;
    border-color: var(--border-soft) !important;
}

#user-onboarding-modal .nat-btn:hover,
#user-onboarding-modal .nat-btn[style*="border-color"] {
    color: var(--color-primary-dark) !important;
    background: var(--color-primary-soft) !important;
}

[dir="rtl"] .header-card {
    border-right-color: var(--color-primary);
}

[dir="rtl"] .nav-item:hover {
    transform: translateX(-2px);
}

[dir="rtl"] .search-bar,
[dir="rtl"] .form-control,
[dir="rtl"] textarea,
[dir="rtl"] input {
    text-align: right;
}

@keyframes saleem-view-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 767px) {
    .sidebar {
        display: none !important;
    }

    .main-content {
        width: 100%;
        min-width: 0;
    }

    .top-header {
        min-height: 64px;
        padding: 10px 12px;
        gap: 8px;
    }

    .search-bar {
        min-height: 44px;
    }

    .search-bar input {
        font-size: 13px;
    }

    .header-actions > div {
        max-width: 112px;
        padding: 5px 8px !important;
    }

    #ui-lang-switcher {
        max-width: 82px;
        font-size: 11px !important;
    }

    .header-actions .btn {
        min-height: 44px;
        padding: 8px 10px;
        font-size: 12px;
    }

    .content-container {
        padding: 16px 12px calc(86px + env(safe-area-inset-bottom, 0px));
    }

    .header-card {
        padding: 22px 18px;
    }

    .header-card h2 {
        font-size: 25px;
    }

    .track-switch-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .track-btn {
        min-height: 58px;
        padding: 9px 8px;
        font-size: 12px;
        line-height: 1.35;
    }

    .duolingo-snake-wrapper {
        gap: 34px;
    }

    .leaderboard-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .chat-container {
        min-height: calc(100dvh - 220px);
        height: calc(100dvh - 220px);
    }

    .chat-input-bar {
        padding-bottom: 2px;
    }

    .chat-input-bar input {
        min-width: 0;
    }

    .bottom-nav {
        display: block !important;
        position: fixed;
        inset: auto 0 0;
        z-index: var(--z-nav);
    }

    .bottom-nav-inner {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }

    .bottom-nav-btn {
        font-size: 11px;
        padding: 5px 2px;
        gap: 3px;
    }

    .bottom-nav-btn span {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #institutions-directory-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    #user-onboarding-modal > .card {
        max-height: calc(100dvh - 24px);
        padding: 22px 16px !important;
    }

    #user-onboarding-modal #country-select-section > div {
        grid-template-columns: 1fr !important;
    }

    .modal-overlay > div {
        max-height: calc(100dvh - 24px) !important;
    }
}

@media (min-width: 768px) {
    .main-content {
        min-width: 0;
    }
}

/* ============================================================
   SALEEM MISSION IDENTITY REFINEMENT
   Warm belonging, clear progress, trusted services, readable learning.
   ============================================================ */
:root {
    --color-primary: #0f766e;
    --color-primary-dark: #0b5f5a;
    --color-primary-soft: #e4f3ef;
    --color-secondary: #163b4a;
    --color-background: #fbf7ef;
    --color-surface: #fffdf9;
    --color-surface-elevated: #ffffff;
    --color-success: #257a5d;
    --color-warning: #8a5a16;
    --color-danger: #a94442;
    --color-celebration: #b7791f;
    --color-culture: #c5683a;
    --color-ai: #2d6f9f;
    --color-services: #257a5d;
    --text-primary: #17333e;
    --text-secondary: #3f5962;
    --text-muted: #5c7077;
    --text-dim: #6f7f84;
    --border-soft: #d8e5df;
    --shadow-soft: 0 10px 30px rgba(22, 59, 74, 0.08);
    --shadow-lift: 0 18px 42px rgba(22, 59, 74, 0.13);
    --fs-section-title: 26px;
    --fs-card-title: 20px;
    --fs-body: 16px;
    --fs-label: 14px;
    --fs-overline: 13px;
    --radius-card: 16px;
    --radius-control: 12px;
    --bg-dark: var(--color-background);
    --surface-dark: var(--color-surface);
    --surface-elevated: var(--color-surface-elevated);
    --glass-border: var(--border-soft);
    --glass-border-strong: #bfd4cc;
    --text-light: var(--text-primary);
    --nile-blue: var(--color-primary);
    --nile-dark: var(--color-secondary);
    --warm-sand: var(--color-celebration);
    --emerald: var(--color-success);
    --coral: var(--color-danger);
}

body {
    background: var(--color-background);
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.62;
}

.main-content {
    background: var(--color-background);
}

.top-header {
    background: rgba(255, 253, 249, 0.96);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: 0 4px 18px rgba(22, 59, 74, 0.05);
}

.content-container {
    background: var(--color-background);
}

.content-container h2,
.content-container h3,
.content-container h4,
.content-container th,
.content-container label {
    color: var(--text-primary) !important;
}

.content-container h2 {
    font-size: clamp(23px, 2.2vw, 30px);
    line-height: 1.25;
}

.content-container h3 {
    font-size: clamp(19px, 1.8vw, 23px);
    line-height: 1.3;
}

.content-container p,
.content-container li,
.content-container td {
    color: var(--text-secondary);
    font-size: 16px;
}

.content-container .card {
    background: var(--color-surface) !important;
    border: 1px solid var(--border-soft) !important;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-soft);
}

.content-container .header-card {
    background: linear-gradient(135deg, #fffdf9 0%, #eef8f4 100%) !important;
    border-top: 4px solid var(--color-primary) !important;
}

#tab-saleem-ai .header-card {
    border-top-color: var(--color-ai) !important;
    background: linear-gradient(135deg, #fffdf9 0%, #edf5fa 100%) !important;
}

#tab-community-hub .header-card {
    border-top-color: var(--color-culture) !important;
}

#tab-profile-dashboard .header-card {
    border-top-color: var(--color-services) !important;
}

.text-gold,
.content-container .text-gold {
    color: #8a5a16 !important;
}

.sidebar .text-gold,
.sidebar .brand-logo {
    color: #f5c76b !important;
}

.btn,
button.btn,
.chip-btn,
.track-btn {
    min-height: 46px;
    font-size: 16px;
    line-height: 1.25;
    font-weight: 700;
}

.btn-primary,
button.btn-primary {
    background: var(--color-primary) !important;
    border-color: var(--color-primary) !important;
    color: #ffffff !important;
    box-shadow: 0 6px 14px rgba(15, 118, 110, 0.18);
}

.btn-primary:hover,
.btn-primary:focus-visible {
    background: var(--color-primary-dark) !important;
    border-color: var(--color-primary-dark) !important;
}

.btn-outline,
button.btn-outline {
    background: #ffffff !important;
    border: 2px solid var(--color-primary) !important;
    color: var(--color-primary-dark) !important;
}

.btn-outline:hover,
.btn-outline:focus-visible {
    background: var(--color-primary-soft) !important;
    border-color: var(--color-primary-dark) !important;
}

.btn-danger,
button.btn-danger {
    background: #f8e7e4 !important;
    border-color: var(--color-danger) !important;
    color: #7f2d2a !important;
}

.track-switch-container {
    background: #f0f6f3;
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-soft);
}

.track-btn {
    color: var(--text-secondary);
    background: transparent;
    padding: 14px 18px;
}

.track-btn.active {
    background: var(--color-primary) !important;
    color: #ffffff !important;
    box-shadow: 0 6px 16px rgba(15, 118, 110, 0.2);
}

.duolingo-snake-node {
    background: #eef4f1;
    border-color: #b9d2c8;
    color: var(--text-secondary);
    box-shadow: 0 8px 20px rgba(22, 59, 74, 0.12);
}

.duolingo-snake-node.completed {
    background: var(--color-success);
    border-color: #1b6249;
    color: #ffffff;
    box-shadow: 0 8px 20px rgba(37, 122, 93, 0.22);
}

.duolingo-snake-node.active {
    background: var(--color-primary);
    border-color: var(--color-primary-dark);
    color: #ffffff;
    box-shadow: 0 8px 22px rgba(15, 118, 110, 0.24);
}

.duolingo-snake-node.locked {
    background: #edf0ee;
    border-color: #b7c2bf;
    color: #6c7a7c;
    opacity: 0.9;
}

.duolingo-snake-node .node-label {
    bottom: -34px;
    color: var(--text-primary);
    background: #fffdf9;
    border-color: var(--border-soft);
    font-size: 14px;
    line-height: 1.3;
    padding: 4px 10px;
}

.card p,
.card .text-muted,
.card [style*="color: var(--text-muted)"],
.card [style*="color: var(--text-dim)"] {
    color: var(--text-secondary) !important;
}

.card [style*="color: #fff"],
.card [style*="color:#fff"],
.card [style*="color: white"] {
    color: var(--text-primary) !important;
}

.tag,
.card-badge {
    font-size: 14px;
    line-height: 1.3;
    color: var(--color-primary-dark) !important;
    background: var(--color-primary-soft);
    border-color: #9bc9bf !important;
}

.search-bar,
.form-control,
.content-container select,
.content-container textarea,
.content-container input {
    background: #ffffff !important;
    border-color: var(--border-soft) !important;
    color: var(--text-primary) !important;
    font-size: 16px;
}

.form-control::placeholder,
input::placeholder,
textarea::placeholder {
    color: #63757a !important;
    opacity: 1;
}

.chat-container,
.chat-history,
.chat-input-bar {
    background: #f4faf7 !important;
    border-color: var(--border-soft) !important;
}

.chat-message .msg-content {
    font-size: 16px;
    line-height: 1.62;
}

#dialect-modal-content,
#culture-modal-content {
    font-size: 16px;
    line-height: 1.65;
}

#dialect-modal-content [style*="rgba(15, 23, 42"],
#culture-modal-content [style*="rgba(15, 23, 42"] {
    background: #edf6f2 !important;
    border-color: var(--color-primary) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 10px 24px rgba(15, 118, 110, 0.14) !important;
}

#dialect-modal-content [style*="rgba(232, 171, 99"],
#culture-modal-content [style*="rgba(232, 171, 99"] {
    background: #fff4df !important;
    border-left-color: var(--color-celebration) !important;
}

#dialect-modal-content [style*="height: 8px"],
#culture-modal-content [style*="height: 8px"] {
    background: #dbe9e4 !important;
}

#dialect-modal-content [style*="color: var(--warm-sand)"],
#culture-modal-content [style*="color: var(--warm-sand)"] {
    color: #8a5a16 !important;
}

#dialect-modal-content h2 {
    font-size: clamp(30px, 8vw, 40px) !important;
    line-height: 1.3 !important;
    color: var(--color-secondary) !important;
}

#dialect-modal-content h3,
#culture-modal-content h3 {
    font-size: clamp(20px, 5vw, 24px) !important;
    line-height: 1.45 !important;
    color: var(--text-primary) !important;
}

#dialect-modal-content p,
#culture-modal-content p {
    font-size: 17px !important;
    line-height: 1.7 !important;
    color: var(--text-secondary) !important;
}

#dialect-modal-content strong,
#culture-modal-content strong {
    font-size: 20px !important;
    line-height: 1.55 !important;
    color: var(--color-primary-dark) !important;
}

#dialect-modal-content .btn,
#culture-modal-content .btn {
    min-height: 50px;
    font-size: 17px !important;
    line-height: 1.35;
    white-space: normal;
}

#dialect-modal-content .tag,
#culture-modal-content .tag {
    font-size: 14px;
    white-space: normal;
}

.modal-overlay > div,
#user-onboarding-modal > .card {
    background: var(--color-surface) !important;
    border-color: var(--border-soft) !important;
    color: var(--text-primary) !important;
}

.modal-overlay h2,
.modal-overlay h3,
.modal-overlay h4,
.modal-overlay label,
.modal-overlay p {
    color: var(--text-primary) !important;
}

.modal-overlay p {
    color: var(--text-secondary) !important;
    font-size: 16px !important;
}

.bottom-nav {
    background: rgba(255, 253, 249, 0.98) !important;
    border-top: 1px solid var(--border-soft) !important;
    box-shadow: 0 -6px 20px rgba(22, 59, 74, 0.08);
}

.bottom-nav-btn {
    color: var(--text-secondary) !important;
    min-height: 58px;
    font-size: 14px !important;
}

.bottom-nav-btn.active {
    color: var(--color-primary-dark) !important;
    background: var(--color-primary-soft) !important;
}

.empty-state {
    background: #fffaf1;
    border: 1px solid #ead9b9;
    border-radius: 14px;
    padding: 24px 18px;
}

.empty-state h4 {
    font-size: 19px;
}

.empty-state p {
    font-size: 16px;
}

[dir="rtl"] body,
[dir="rtl"] button,
[dir="rtl"] input,
[dir="rtl"] textarea,
[dir="rtl"] select {
    font-family: 'Noto Sans Arabic', 'Noto Sans', 'Outfit', sans-serif;
}

@media (max-width: 767px) {
    .content-container {
        padding: 18px 14px calc(92px + env(safe-area-inset-bottom, 0px));
    }

    .content-container h2 {
        font-size: 24px;
    }

    .content-container h3 {
        font-size: 20px;
    }

    .content-container p,
    .content-container li,
    .content-container td {
        font-size: 16px;
    }

    .header-card {
        padding: 22px 18px !important;
    }

    .track-switch-container {
        gap: 8px;
        padding: 6px;
    }

    .track-btn {
        min-height: 66px;
        padding: 11px 8px;
        font-size: 15px;
    }

    .btn,
    button.btn,
    .chip-btn {
        min-height: 48px;
        font-size: 16px;
    }

    .bottom-nav-btn span {
        white-space: normal;
        line-height: 1.15;
        overflow: visible;
        text-overflow: clip;
    }

    .duolingo-snake-node .node-label {
        font-size: 13px;
        max-width: 180px;
        white-space: normal;
        text-align: center;
    }
}

@media (max-width: 430px) {
    .top-header {
        min-height: auto;
        flex-wrap: wrap;
        align-items: stretch;
        padding: 10px 12px 12px;
    }

    .top-header .search-bar {
        flex: 1 1 100%;
        width: 100%;
        max-width: none;
        min-height: 46px;
    }

    .top-header .header-actions {
        width: 100%;
        justify-content: space-between;
        gap: 8px;
    }

    .track-switch-container {
        grid-template-columns: 1fr;
    }

    .track-btn {
        min-height: 54px;
    }

    .header-actions .btn {
        font-size: 14px;
    }

    #ui-lang-switcher {
        max-width: 96px;
        font-size: 13px !important;
    }
}

