/* ==============================================
   CROSUM-MED — GLOBAL STYLESHEET v8
   Dark Mode · Responsive · Professional
   ============================================== */

/* Multi-script font coverage (Devanagari, Tamil, Bengali, Telugu, Gujarati,
   Kannada, Malayalam, Gurmukhi, Oriya, Arabic). Loaded once via global.css
   so all 10 pages inherit i18n font support without per-page <link> tags. */
@import url("https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;500;600;700&family=Noto+Sans+Devanagari:wght@400;500;600;700&family=Noto+Sans+Bengali:wght@400;500;600;700&family=Noto+Sans+Tamil:wght@400;500;600;700&family=Noto+Sans+Telugu:wght@400;500;600;700&family=Noto+Sans+Gujarati:wght@400;500;600;700&family=Noto+Sans+Kannada:wght@400;500;600;700&family=Noto+Sans+Malayalam:wght@400;500;600;700&family=Noto+Sans+Gurmukhi:wght@400;500;600;700&family=Noto+Sans+Oriya:wght@400;500;600;700&family=Noto+Sans+Arabic:wght@400;500;600;700&display=swap");

/* ===== GLOBAL RESET =====
   Floor-level defaults: box-sizing everywhere, clamp layout/media to viewport,
   and let form controls inherit page typography. Page-specific rules keep
   their natural specificity on top of this. */
*, *::before, *::after { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
img, video, svg { max-width: 100%; height: auto; }
input, textarea, select, button { font: inherit; }

/* ===== CSS CUSTOM PROPERTIES ===== */

:root {
    /* Phase 5.1 — refined slate-based light palette (WCAG AA verified) */
    --bg-primary: #F8FAFC;       /* slate-50 — warm off-white page bg */
    --bg-secondary: #FFFFFF;     /* pure white cards */
    --bg-tertiary: #F1F5F9;      /* slate-100 — subtle alt rows */
    --bg-card: #FFFFFF;
    --bg-card-hover: #F8FAFC;
    --bg-accent: #EFF6FF;        /* blue-50 — soft brand tint */
    --bg-accent-deep: #DBEAFE;   /* blue-100 */
    --bg-infobox: #F8FAFC;

    --text-primary: #1E293B;     /* slate-800 — primary body */
    --text-secondary: #475569;   /* slate-600 — secondary */
    --text-muted: #64748B;       /* slate-500 — muted (4.5:1 on white = AA) */
    --text-on-accent: #0B5394;

    --border-color: #CBD5E1;     /* slate-300 */
    --border-light: #E2E8F0;     /* slate-200 — gentle divider */
    --border-input: #CBD5E1;

    --brand-primary: #0B5394;    /* unchanged — brand blue */
    --brand-dark: #073763;
    --brand-light: #1565C0;
    --brand-surface: #EFF6FF;
    --brand-surface-hover: #DBEAFE;

    --header-bg: linear-gradient(135deg, #0B5394 0%, #0a4a85 50%, #073763 100%);
    --header-border: rgba(255,255,255,0.08);
    --header-shadow: 0 2px 20px rgba(11,83,148,0.18);

    --sidebar-bg: #FFFFFF;
    --sidebar-overlay: rgba(0,0,0,0.4);
    --sidebar-divider: #e8eff8;
    --sidebar-hover: #F4FAFF;

    /* Refined elevation — subtle, non-dramatic */
    --shadow-sm: 0 1px 2px rgba(15,23,42,0.06);
    --shadow-md: 0 2px 8px rgba(15,23,42,0.08);
    --shadow-lg: 0 8px 24px rgba(15,23,42,0.12);
    --shadow-card: 0 1px 3px rgba(15,23,42,0.06);
    --shadow-card-hover: 0 4px 16px rgba(15,23,42,0.10);

    --warning-bg: #FFFBEB;
    --warning-border: #F59E0B;
    --warning-text: #92400E;
    --success-bg: #F0FDF4;
    --success-border: #16A34A;
    --success-text: #15803D;
    --danger-bg: #FEF2F2;
    --danger-border: #DC2626;
    --danger-text: #B91C1C;
    --info-bg: #EFF6FF;
    --info-border: #3B82F6;
    --info-text: #1D4ED8;

    --table-stripe: #F8FBFF;
    --table-hover: #E8F3FF;
    --table-header-bg: #0B5394;
    --table-header-text: #fff;
    --table-border: #ddd;

    --gold: #f4c430;
    --star-empty: #ccc;

    --search-bg: #FFFFFF;
    --search-border: #c8d2e0;
    --search-text: #1a1a2e;
    --search-placeholder: #999;
    --search-type-bg: #E3F2FD;
    --search-type-text: #0B5394;

    --footer-bg: #0a1f3a;
    --footer-text: #b0c4de;
    --footer-heading: #e4eaf1;
    --footer-link: #90caf9;
    --footer-link-hover: #ffffff;
    --footer-border: rgba(255,255,255,0.08);

    --highlight-bg: #ffe082;

    /* Phase 5.4 — targeted theme transition (used on key elements, NOT on *) */
    --transition-theme: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    --transition-shadow: box-shadow 0.2s ease;
    --transition-transform: transform 0.2s ease;

    /* Focus ring */
    --focus-ring: 0 0 0 2px var(--brand-primary);

    /* Spacing scale */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

/* ===== DARK THEME — deep navy + purple-blue accent ===== */
[data-theme="dark"] {
    --bg-primary: #0f1117;       /* deep dark navy page bg */
    --bg-secondary: #1a1d27;     /* charcoal-navy cards */
    --bg-tertiary: #262a3a;      /* alt rows */
    --bg-card: #1a1d27;
    --bg-card-hover: #242838;
    --bg-accent: #1e2235;
    --bg-accent-deep: #2a2f45;
    --bg-infobox: #1a1d27;

    --text-primary: #e8eaf0;     /* soft off-white */
    --text-secondary: #b0b4c8;   /* muted lavender-grey */
    --text-muted: #8b8fa8;       /* grey-blue muted */
    --text-on-accent: #7c85e0;

    --border-color: rgba(255,255,255,0.07);
    --border-light: rgba(255,255,255,0.05);
    --border-input: rgba(255,255,255,0.12);

    --brand-primary: #7c85e0;    /* purple-blue accent */
    --brand-dark: #6b7fd4;
    --brand-light: #a5aded;
    --brand-surface: #1e2240;
    --brand-surface-hover: #2a3060;

    --header-bg: linear-gradient(135deg, #0f1117 0%, #151826 50%, #0f1117 100%);
    --header-border: rgba(124,133,224,0.12);
    --header-shadow: 0 2px 20px rgba(0,0,0,0.4);

    --sidebar-bg: #151826;
    --sidebar-overlay: rgba(0,0,0,0.6);
    --sidebar-divider: #262a3a;
    --sidebar-hover: #1e2235;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.35);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.45);
    --shadow-card: 0 1px 4px rgba(0,0,0,0.3);
    --shadow-card-hover: 0 4px 16px rgba(0,0,0,0.4);

    --warning-bg: #2a1f0a;
    --warning-border: #F59E0B;
    --warning-text: #FCD34D;
    --success-bg: #0a2416;
    --success-border: #16A34A;
    --success-text: #4ADE80;
    --danger-bg: #2a0a0a;
    --danger-border: #DC2626;
    --danger-text: #F87171;
    --info-bg: #151833;
    --info-border: #7c85e0;
    --info-text: #a5aded;

    --table-stripe: #151826;
    --table-hover: #1e2235;
    --table-header-bg: #1e2235;
    --table-header-text: #e8eaf0;
    --table-border: rgba(255,255,255,0.07);

    --gold: #fdd835;
    --star-empty: #3d3f50;

    --search-bg: #1a1d27;
    --search-border: rgba(255,255,255,0.1);
    --search-text: #e8eaf0;
    --search-placeholder: #6b6f85;
    --search-type-bg: #1e2235;
    --search-type-text: #a5aded;

    --footer-bg: #0b0e14;
    --footer-text: #6b6f85;
    --footer-heading: #b0b4c8;
    --footer-link: #9ba3dc;
    --footer-link-hover: #e8eaf0;
    --footer-border: rgba(124,133,224,0.1);

    --highlight-bg: #3d3520;

    color-scheme: dark;
}

/* ===== GLOBAL RESETS ===== */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    font-family: 'Noto Sans', 'Noto Sans Devanagari', 'Noto Sans Bengali', 'Noto Sans Tamil', 'Noto Sans Telugu', 'Noto Sans Gujarati', 'Noto Sans Kannada', 'Noto Sans Malayalam', 'Noto Sans Gurmukhi', 'Noto Sans Oriya', 'Noto Sans Arabic', 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--text-primary);
    transition: var(--transition-theme);
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: var(--brand-surface-hover);
    color: var(--text-primary);
}

.page-content {
    background:
        radial-gradient(circle at top left, rgba(11,83,148,0.06), transparent 34rem),
        var(--bg-primary);
}

[data-theme="dark"] .page-content {
    background:
        radial-gradient(circle at top left, rgba(124,133,224,0.10), transparent 32rem),
        var(--bg-primary);
}

.card,
.feature-card,
.legal-card,
.sub-card,
.detail-card,
.reviews-section,
.comments-section {
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}

.card:hover,
.feature-card:hover,
.sub-card:hover {
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-card-hover);
}

.view-btn,
.btn,
.btn-primary,
.btn-secondary {
    min-height: 40px;
    align-items: center;
    justify-content: center;
}

body.sidebar-open {
    overflow: hidden;
    padding-right: 0 !important;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

html {
    scroll-behavior: smooth;
}

img {
    max-width: 100%;
    height: auto;
}

a {
    color: var(--brand-primary);
    transition: color 0.2s ease;
}

a:hover {
    color: var(--brand-dark);
}

.page-content {
    flex: 1;
    padding-top: 0;
}


/* ===========================================================
   HEADER
   =========================================================== */

.header {
    background: var(--header-bg);
    color: #fff;
    padding: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: var(--header-shadow);
    border-bottom: 1px solid var(--header-border);
    transition: var(--transition-theme);
}

.header-top {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 14px 28px;
    box-sizing: border-box;
    position: relative;
}

/* Logo */
.header .logo {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex-shrink: 0;
}

.logo-name {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: #fff;
    line-height: 1.15;
}

.logo-tagline {
    font-size: 12.5px;
    color: rgba(200,225,255,0.65);
    font-weight: 400;
    letter-spacing: 0.3px;
}

/* Header Right Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.country-selector {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.country-btn,
.sidebar-country-btn {
    min-height: 40px;
    border: 1px solid var(--brand-surface-hover);
    background: var(--brand-surface);
    color: var(--brand-primary);
    border-radius: 8px;
    padding: 0 12px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    box-shadow: none;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.country-btn {
    display: inline-grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 8px;
    min-width: 148px;
    max-width: 190px;
    text-align: left;
}

.country-btn-flag {
    font-size: 18px;
    line-height: 1;
}

.country-btn-text {
    display: grid;
    min-width: 0;
    line-height: 1.05;
}

.country-btn-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--brand-primary);
    font-size: 12px;
    font-weight: 750;
}

.country-btn-currency {
    color: var(--brand-primary);
    font-size: 11px;
    font-weight: 750;
    margin-top: 2px;
}

.country-btn:hover,
.sidebar-country-btn:hover {
    background: var(--brand-surface-hover);
    border-color: var(--brand-primary);
    transform: translateY(-1px);
}

.country-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    width: 340px;
    max-height: min(420px, 70vh);
    overflow-y: auto;
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1003;
    padding: 6px;
}

.country-dropdown.open {
    display: block;
    animation: dropdownFade 0.18s ease;
}

.country-option {
    width: 100%;
    min-height: 44px;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    display: grid;
    grid-template-columns: 32px 1fr;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 7px;
    cursor: pointer;
    text-align: left;
    font: inherit;
}

.country-option:hover,
.country-option:focus-visible {
    background: var(--brand-surface);
    color: var(--brand-primary);
    outline: none;
}

.country-option-copy {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.country-option-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 650;
}

.country-option-currency {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
}

@media (max-width: 760px) {
    .country-btn {
        min-width: 52px;
        max-width: 52px;
        grid-template-columns: 1fr;
        justify-items: center;
        padding: 0 10px;
    }
    .country-btn-text {
        display: none;
    }
}

/* Theme toggle UI removed — theme is now controlled via Settings (profile.html). */


/* ===========================================================
   MENU / SIDEBAR TRIGGER BUTTON
   =========================================================== */

.menu-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    padding: 0;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    flex-shrink: 0;
    margin-left: 0;
    box-shadow: none;
}

.menu-btn:hover {
    background: rgba(255,255,255,0.18);
    border-color: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

.menu-btn i {
    color: #fff;
    font-size: 18px;
}


/* ===========================================================
   SEARCH BAR (Header)
   =========================================================== */

.search-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: stretch;
    width: 560px;
    max-width: 100%;
    background: var(--search-bg);
    border: 1px solid var(--search-border);
    border-radius: 10px;
    transition: all 0.25s ease;
}

.search-container:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(11,83,148,0.12);
}

[data-theme="dark"] .search-container:focus-within {
    box-shadow: 0 0 0 3px rgba(77,163,232,0.15);
}

/* Type Selector */
.search-type-selector {
    position: relative;
    border-right: 1px solid var(--border-input);
}

#searchTypeBtn {
    background: var(--search-type-bg);
    border: none;
    padding: 0 16px;
    font-size: 13.5px;
    cursor: pointer;
    height: 44px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--search-type-text);
    font-weight: 600;
    transition: background 0.2s ease;
    white-space: nowrap;
    border-radius: 9px 0 0 9px;
}

#searchTypeBtn:hover {
    background: var(--brand-surface-hover);
}

/* Dropdown */
.search-type-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 200px;
    display: none;
    z-index: 3000;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: fadeSlide 0.2s ease forwards;
}

.search-type-dropdown div {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: background 0.15s ease;
}

.search-type-dropdown div:hover,
.search-type-dropdown div.active {
    background: var(--bg-accent);
    color: var(--brand-primary);
}

/* Search Input */
.search-container input[type="text"] {
    border: none;
    outline: none;
    flex: 1;
    padding: 0 16px;
    font-size: 14.5px;
    background: transparent;
    color: var(--search-text);
    min-width: 0;
    height: 44px;
}

.search-container input[type="text"]::placeholder {
    color: var(--search-placeholder);
}

/* Submit */
.search-submit {
    background: var(--brand-primary);
    border: none;
    width: 50px;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 9px 9px 0;
}

.search-submit i { font-size: 15px; }
.search-submit:hover { background: var(--brand-dark); }


/* ===========================================================
   SEARCH SUGGESTIONS / AUTOCOMPLETE
   =========================================================== */

#searchSuggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    max-height: 240px;
    overflow-y: auto;
    z-index: 2000;
    display: none;
    color: var(--text-primary);
}

.suggestion-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14.5px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    background: var(--bg-card);
    transition: background 0.15s;
    text-align: left;
}

.suggestion-item:last-child { border-bottom: none; }

.suggestion-item:hover,
.suggestion-item.active {
    background: var(--bg-accent);
    color: var(--brand-primary);
}

.highlight {
    background-color: var(--highlight-bg);
    font-weight: bold;
    border-radius: 2px;
    padding: 0 1px;
}


/* ===========================================================
   SIDEBAR OVERLAY
   =========================================================== */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--sidebar-overlay);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.35s ease;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}


/* ===========================================================
   SIDEBAR
   =========================================================== */

#sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100%;
    background: var(--sidebar-bg);
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1100;
    box-shadow: -4px 0 30px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

#sidebar.open { transform: translateX(0); }

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--sidebar-divider);
    flex-shrink: 0;
}

.sidebar-header-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-close {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.sidebar-close:hover {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}

/* Sidebar Body */
.sidebar-body {
    flex: 1;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Auth Guest */
.sidebar-auth-guest {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--sidebar-divider);
    margin-bottom: 12px;
}

.sidebar-auth-guest .auth-heading {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

.btn-signin {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    background: var(--brand-primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-signin:hover {
    background: var(--brand-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(11,83,148,0.25);
}

.btn-register {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    background: transparent;
    color: var(--brand-primary);
    border: 1.5px solid var(--brand-primary);
    border-radius: 10px;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-register:hover {
    background: var(--brand-surface);
    transform: translateY(-1px);
}

/* Auth User (Logged In) */
.sidebar-auth-user {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--sidebar-divider);
    margin-bottom: 12px;
}

.profile-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--brand-surface);
    border: 3px solid var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: var(--brand-primary);
    font-weight: 700;
    text-transform: uppercase;
}

.profile-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
}

.profile-username {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

/* Sidebar Nav Links */
.sidebar-divider-line {
    height: 1px;
    background: var(--sidebar-divider);
    margin: 8px 0;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 14.5px;
    font-weight: 500;
    transition: all 0.18s ease;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.sidebar-nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--brand-primary);
}

.sidebar-nav-link i {
    width: 20px;
    text-align: center;
    font-size: 16px;
    color: var(--text-muted);
    transition: color 0.18s ease;
}

.sidebar-nav-link:hover i {
    color: var(--brand-primary);
}

.sidebar-country-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    margin-top: 6px;
    border-radius: 10px;
    background: var(--bg-tertiary);
}

.sidebar-country-label {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    color: var(--text-primary);
    font-size: 14.5px;
    font-weight: 650;
}

.sidebar-country-label i {
    width: 20px;
    text-align: center;
    color: var(--text-muted);
}

.sidebar-country-btn {
    min-height: 36px;
    flex: 0 0 auto;
    box-shadow: none;
}

.sidebar-country-dropdown {
    left: 14px;
    right: 14px;
    top: calc(100% + 4px);
    width: auto;
}

.sidebar-nav-link.disabled-link {
    opacity: 0.55;
    cursor: default;
}

.sidebar-nav-link .coming-soon-badge {
    margin-left: auto;
    font-size: 10px;
    background: var(--bg-accent);
    color: var(--text-muted);
    padding: 2px 7px;
    border-radius: 8px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Sidebar theme row removed — theme now lives in Settings (profile.html?tab=settings) */

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 22px;
    border-top: 1px solid var(--sidebar-divider);
    flex-shrink: 0;
    display: flex;
    justify-content: center;
}

.btn-signout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px 18px;
    background: transparent;
    color: var(--danger-text);
    border: 1.5px solid var(--danger-text);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-signout:hover {
    background: var(--danger-bg);
    transform: translateY(-1px);
}


/* ===========================================================
   FOOTER
   =========================================================== */

.footer {
    background: var(--footer-bg);
    color: var(--footer-text);
    padding: 0;
    margin-top: auto;
    transition: var(--transition-theme);
}

.footer-main {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1.2fr;
    gap: 40px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 28px 30px;
}

.footer-brand .footer-logo {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 10px;
}

.footer-brand p {
    font-size: 14px;
    line-height: 1.7;
    color: var(--footer-text);
    margin: 0;
}

.footer-col h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--footer-heading);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin: 0 0 14px;
}

.footer-col a {
    display: block;
    font-size: 14px;
    color: var(--footer-link);
    text-decoration: none;
    padding: 4px 0;
    transition: color 0.2s ease;
}

.footer-col a:hover {
    color: var(--footer-link-hover);
}

.footer-col p {
    font-size: 14px;
    line-height: 1.7;
    color: var(--footer-text);
    margin: 0 0 6px;
}

.footer-col .footer-social {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.footer-col .footer-social a {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--footer-link);
    font-size: 16px;
    transition: all 0.2s ease;
    padding: 0;
}

.footer-col .footer-social a:hover {
    background: var(--brand-primary);
    color: #fff;
}

.footer-bottom {
    border-top: 1px solid var(--footer-border);
    text-align: center;
    padding: 16px 28px;
    font-size: 13px;
    color: var(--footer-text);
}

@media (max-width: 1024px) {
    .footer-main {
        grid-template-columns: 1fr 1fr;
        gap: 30px;
    }
}

@media (max-width: 640px) {
    .footer-main {
        grid-template-columns: 1fr;
        gap: 24px;
        padding: 30px 20px 20px;
        text-align: center;
    }
    .footer-col .footer-social { justify-content: center; }
    .footer-col a { min-height: 44px; padding: 10px 0; }
}


/* ===========================================================
   HOME PAGE
   =========================================================== */

.home {
    max-width: 1100px;
    margin: 30px auto;
    padding: 0 16px;
}

.hero {
    background: var(--bg-card);
    padding: 36px 30px;
    text-align: center;
    border-radius: 12px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
    transition: var(--transition-theme);
}

.hero h1 {
    color: var(--brand-primary);
    font-size: 40px;
    margin: 0 0 6px;
    font-weight: 800;
}

.hero h1::after {
    content: "";
    display: block;
    width: 80px;
    height: 3px;
    background: var(--brand-primary);
    margin: 14px auto 20px;
    border-radius: 3px;
}

.hero p {
    font-size: 16px;
    line-height: 1.8;
    max-width: 860px;
    margin: 10px auto;
    color: var(--text-secondary);
}

.feature {
    display: flex;
    align-items: center;
    gap: 30px;
    background: var(--bg-card);
    padding: 28px 32px;
    margin-top: 28px;
    border-radius: 12px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
    transition: var(--transition-theme);
}

.feature:hover {
    box-shadow: var(--shadow-md);
}

.feature img {
    width: 240px;
    height: 160px;
    flex-shrink: 0;
    border-radius: 8px;
    object-fit: cover;
}

.feature.reverse {
    flex-direction: row-reverse;
}

.feature h2 {
    color: var(--brand-primary);
    font-size: 22px;
    margin: 0 0 4px;
    font-weight: 700;
}

.feature h2::after {
    content: "";
    display: block;
    width: 100%;
    height: 2px;
    background: var(--brand-primary);
    margin: 10px 0 14px;
    opacity: 0.3;
}

.feature p {
    font-size: 15px;
    line-height: 1.7;
    margin: 6px 0 0;
    color: var(--text-secondary);
}

.feature div {
    flex: 1;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 32px 0 10px;
}

.card {
    background: var(--bg-accent);
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: var(--transition-theme);
}

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

.card h3 {
    color: var(--brand-primary);
    margin: 0 0 8px;
    font-size: 17px;
}

.card p {
    color: var(--text-secondary);
    font-size: 14.5px;
    margin: 0;
}

@media (max-width: 768px) {
    .hero h1 { font-size: 28px; }
    .hero p { font-size: 15px; }

    .feature {
        flex-direction: column;
        text-align: center;
        padding: 22px 20px;
    }

    .feature.reverse {
        flex-direction: column;
    }

    .feature img {
        width: 100%;
        max-width: 320px;
        height: auto;
    }

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


/* ===========================================================
   DID YOU MEAN BAR
   =========================================================== */

#didYouMeanBox {
    display: none;
    width: 100%;
    background: var(--bg-accent);
    padding: 10px 0;
    transition: var(--transition-theme);
}

#didYouMeanBox > div {
    max-width: 1100px;
    margin: 0 auto;
    text-align: center;
    font-size: 15px;
    color: var(--text-primary);
}

#didYouMeanBox a {
    color: var(--brand-primary);
    font-weight: bold;
}


/* ===========================================================
   PAGINATION
   =========================================================== */

#pagination,
#articlePagination,
#newsPagination {
    margin-top: 25px;
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

#pagination button,
#articlePagination button,
#newsPagination button {
    padding: 7px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    border: 1px solid var(--brand-primary);
    background: var(--bg-card);
    color: var(--brand-primary);
    transition: all 0.2s ease;
}

#pagination button.nav-btn,
#articlePagination button.nav-btn,
#newsPagination button.nav-btn {
    background: var(--brand-primary);
    color: #fff;
    border: 1px solid var(--brand-primary);
}

#pagination button:not(:disabled):hover,
#articlePagination button:not(:disabled):hover,
#newsPagination button:not(:disabled):hover {
    background: var(--brand-dark);
    color: #fff;
}

#pagination button.active,
#articlePagination button.active,
#newsPagination button.active {
    background: var(--brand-primary);
    color: #fff;
}

#pagination button:disabled,
#articlePagination button:disabled,
#newsPagination button:disabled {
    background: var(--bg-card);
    color: var(--text-muted);
    border-color: var(--border-color);
    cursor: not-allowed;
    opacity: 0.5;
}

#pageNumberInput {
    outline: none;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: var(--transition-theme);
}

#pageNumberInput:focus {
    border: 2px solid var(--brand-primary);
}

#paginationError,
#articlePagError,
#newsPagError {
    text-align: center;
    font-weight: bold;
    margin-top: 10px;
    display: none;
    color: var(--danger-text);
}

/* pagination dots */
#pagination span,
#articlePagination span,
#newsPagination span {
    color: var(--brand-primary);
}


/* ===========================================================
   BOOKMARK
   =========================================================== */

.bookmark-column {
    width: 60px;
    text-align: center;
}

.bookmark-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 20px;
    transition: 0.2s ease;
    color: var(--text-muted);
}

.bookmark-btn i {
    color: var(--text-muted);
    transition: color 0.2s;
}

.bookmark-btn.active i {
    color: var(--brand-primary);
}

.bookmark-btn:hover i {
    color: var(--brand-primary);
}


/* ===========================================================
   RATING UI
   =========================================================== */

.rating-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 100px;
}

.stars-row {
    display: flex;
    gap: 3px;
    justify-content: center;
}

.star-filled {
    color: var(--gold);
    font-size: 15px;
}

.star-empty {
    color: var(--star-empty);
    font-size: 15px;
}

.rating-score {
    margin-top: 4px;
    font-weight: bold;
    color: var(--brand-primary);
    font-size: 13px;
}


/* ===========================================================
   DROPDOWN ANIMATION
   =========================================================== */

@keyframes fadeSlide {
    from { opacity: 0; transform: translateY(-5px); }
    to   { opacity: 1; transform: translateY(0); }
}


/* ===========================================================
   MOBILE HEADER
   =========================================================== */

@media (max-width: 768px) {
    .header {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .header-top {
        padding: 12px 16px;
        flex-wrap: wrap;
        align-items: center;
    }

    /* Make logo flex:1 so it fills row 1 with header-actions */
    .header .logo {
        flex: 1;
        min-width: 0;
    }

    .logo-name { font-size: 20px; }
    .logo-tagline { font-size: 12px; }

    /* Search bar drops to its own full-width second row */
    .search-container {
        position: static !important;
        left: auto !important;
        transform: none !important;
        order: 10;
        flex-basis: 100%;
        width: 100%;
        max-width: 100%;
        margin: 8px 0 4px;
        box-sizing: border-box;
    }

    .header-actions { gap: 8px; flex-shrink: 0; }

    .menu-btn {
        width: 44px;
        height: 44px;
    }

    #sidebar {
        width: 290px;
        right: 0;
    }
}

@media (max-width: 640px) {
    #searchTypeBtn {
        padding: 0 10px;
        font-size: 12px;
    }
}


/* ===========================================================
   GENERIC RELATED-MEDICINES LINKS (used in product page)
   =========================================================== */

#relatedMedicines li { margin: 8px 0; }
#relatedMedicines a {
    text-decoration: none;
    color: var(--brand-primary);
    font-weight: bold;
}
#relatedMedicines a:hover { text-decoration: underline; }


/* ===========================================================
   MEDICAL DISCLAIMER BOX
   =========================================================== */

.disclaimer-box {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--danger-text);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.disclaimer-box i {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--danger-border);
}


/* ===========================================================
   PHASE 4 ADDITIONS — Header Modes, Login, etc.
   =========================================================== */

/* ===== HEADER MODES ===== */

/* Minimal mode: hide search bar (for login, legal pages) */
.header[data-mode="minimal"] .header-search-wrap {
    display: none !important;
}

/* Expanded mode: for landing page — handled per-page with inline styles */
.header[data-mode="expanded"] {
    position: relative;
}


/* ===== SIDEBAR GATED LINKS ===== */

.sidebar-nav-link.disabled-link {
    opacity: 0.55;
    cursor: default;
}

.sidebar-nav-link .coming-soon-badge {
    margin-left: auto;
    font-size: 10px;
    background: var(--bg-accent);
    color: var(--text-muted);
    padding: 2px 7px;
    border-radius: 8px;
    font-weight: 600;
    letter-spacing: 0.3px;
}


/* ===== HERO H1 UNDERLINE FIX ===== */

.hero h1::after {
    width: 100%;
    max-width: 100%;
}


/* ===== CARD CAROUSEL (for landing page) ===== */

.carousel-section {
    margin: 30px 0;
}

.carousel-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--brand-primary);
    margin: 0 0 16px;
    padding: 0 8px;
}

.carousel-section {
    padding: 0 48px;
    position: relative;
}
.carousel-wrap {
    position: relative;
    overflow: visible;
}

.carousel-track {
    display: flex;
    gap: 16px;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: grab;
    user-select: none;
    padding: 4px 0;
}

.carousel-track:active {
    cursor: grabbing;
}

.carousel-card {
    flex: 0 0 calc(20% - 13px);
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
}

.carousel-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.carousel-card-img {
    height: 140px;
    width: 100%;
    background: var(--bg-accent);
    position: relative;
    overflow: hidden;
}

.carousel-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.carousel-card-img .carousel-wiki-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 42px;
    color: var(--text-muted);
    opacity: 0.5;
}

.carousel-card-body {
    padding: 18px 16px;
    flex: 1;
}

.carousel-card-body h4 {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.carousel-card-body p {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.carousel-card-footer {
    padding: 8px 14px;
    background: var(--bg-tertiary);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Additive class hooks for the rewritten product/article/news carousel
   templates — work alongside the existing .carousel-card/-img/-body/-footer
   layout rules above. */
.card-icon-placeholder {
    display: block;
    margin: auto;
    font-size: 42px;
    color: var(--text-muted);
    opacity: 0.5;
    line-height: 140px;
    text-align: center;
}

.card-name-image-fallback {
    width: 100%;
    height: 100%;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    color: #ffffff;
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.35;
    overflow-wrap: anywhere;
    text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}

.card-name-image-fallback i {
    color: rgba(255,255,255,0.9);
    font-size: 38px;
    line-height: 1;
    opacity: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.32);
}

.card-name-image-fallback span {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.35;
    margin: 0 0 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-category {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

.card-excerpt {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.45;
    margin: 6px 0 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: var(--brand-primary);
    background: var(--bg-accent);
    padding: 3px 10px;
    border-radius: 12px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.carousel-btn:hover {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}

.carousel-btn.left { left: -48px; }
.carousel-btn.right { right: -48px; }

@media (max-width: 1024px) {
    .carousel-card { flex: 0 0 calc(33.33% - 11px); }
    .carousel-section { padding: 0 36px; }
    .carousel-btn.left { left: -36px; }
    .carousel-btn.right { right: -36px; }
}

@media (max-width: 640px) {
    .carousel-card { flex: 0 0 calc(50% - 8px); }
    .carousel-section { padding: 0 34px; }
    .carousel-btn {
        display: flex;
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
        font-size: 14px;
        background: var(--bg-card);
        box-shadow: 0 4px 14px rgba(15,23,42,0.16);
    }
    .carousel-btn.left { left: -30px; }
    .carousel-btn.right { right: -30px; }
}

@media (max-width: 640px) {
    .carousel-card { flex: 0 0 calc(100% - 4px); }
}


/* ===== ARTICLE/NEWS CARD (search results) ===== */

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 20px 22px;
    margin-bottom: 14px;
    transition: var(--transition-theme);
    cursor: pointer;
}

.result-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--brand-primary);
}

.result-card-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--brand-primary);
    margin: 0 0 8px;
    line-height: 1.4;
}

.result-card-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.result-card-meta span {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

.result-card-body {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.65;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.result-card-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.result-card-tag {
    font-size: 11px;
    background: var(--bg-accent);
    color: var(--brand-primary);
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 600;
}


/* ===== YEAR RANGE FILTER ===== */

.year-range-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
}

.year-range-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--brand-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.year-range-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.year-range-inputs input {
    width: 80px;
    padding: 6px 10px;
    border: 1.5px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.year-range-inputs span {
    color: var(--text-muted);
    font-size: 13px;
}

.year-quick-filters {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
}

.year-quick-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    border: none;
    background: none;
    text-align: left;
}

.year-quick-btn:hover { color: var(--brand-primary); }

.year-quick-btn input[type="radio"] {
    accent-color: var(--brand-primary);
}


/* ===== EXPANDED HEADER (landing page) ===== */

.landing-hero-search {
    background: var(--header-bg);
    padding: 60px 28px 50px;
    text-align: center;
    border-bottom: 1px solid var(--header-border);
}

.landing-search-heading {
    font-size: 36px;
    font-weight: 800;
    color: #fff;
    margin: 0 0 8px;
}

.landing-search-examples {
    font-size: 14px;
    color: rgba(200,225,255,0.6);
    margin: 0 0 24px;
}

.landing-search-bar {
    display: flex;
    align-items: stretch;
    max-width: 680px;
    margin: 0 auto;
    background: var(--search-bg);
    border: 1px solid var(--search-border);
    border-radius: 12px;
    transition: all 0.25s ease;
}

.landing-search-bar:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(11,83,148,0.15);
}

@media (max-width: 640px) {
    .landing-search-heading { font-size: 24px; }
    .landing-hero-search { padding: 40px 16px 36px; }
}


/* ===== PROFILE PAGE TABS ===== */

.profile-layout {
    display: flex;
    max-width: 1100px;
    margin: 28px auto;
    padding: 0 16px;
    gap: 24px;
    min-height: 500px;
}

.profile-sidebar {
    width: 220px;
    flex-shrink: 0;
}

.profile-tab-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 10px;
    margin-bottom: 6px;
    transition: all 0.2s;
    text-align: left;
}

.profile-tab-btn:hover { background: var(--bg-accent); }
.profile-tab-btn.active {
    background: var(--brand-primary);
    color: #fff;
}

.profile-tab-btn i { width: 18px; text-align: center; }

.profile-content {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 28px;
    box-shadow: var(--shadow-card);
}

@media (max-width: 768px) {
    .profile-layout { flex-direction: column; }
    .profile-sidebar { width: 100%; display: flex; gap: 6px; overflow-x: auto; }
    .profile-tab-btn { white-space: nowrap; margin-bottom: 0; }
}


/* ===== LEGAL PAGES (terms, privacy, subscription) ===== */

.legal-page {
    max-width: 880px;
    margin: 30px auto;
    padding: 0 20px;
}

.legal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 36px 32px;
    box-shadow: var(--shadow-card);
}

.legal-card h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--brand-primary);
    margin: 0 0 8px;
}

.legal-card h1::after {
    content: "";
    display: block;
    width: 60px;
    height: 3px;
    background: var(--brand-primary);
    margin: 12px 0 20px;
    border-radius: 2px;
}

.legal-card h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--brand-primary);
    margin: 28px 0 12px;
}

.legal-card h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 20px 0 8px;
}

.legal-card p, .legal-card li {
    font-size: 15px;
    line-height: 1.75;
    color: var(--text-secondary);
    margin: 0 0 10px;
}

.legal-card ul {
    padding-left: 22px;
    margin: 8px 0 16px;
}

.legal-card table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
}

.legal-card th {
    background: var(--table-header-bg);
    color: var(--table-header-text);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
}

.legal-card td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--table-border);
    color: var(--text-primary);
}

.legal-card .last-updated {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

@media (max-width: 640px) {
    .legal-page { padding: 0 12px; margin: 16px auto; }
    .legal-card { padding: 24px 18px; border-radius: 10px; }
    .legal-card h1 { font-size: 22px; }
    .legal-card h2 { font-size: 17px; margin: 22px 0 10px; }
    .legal-card h3 { font-size: 15px; }
    .legal-card p, .legal-card li { font-size: 14.5px; }
    .legal-card table { display: block; overflow-x: auto; white-space: nowrap; font-size: 13px; }
    .legal-card th, .legal-card td { padding: 8px 10px; }
}


/* ===== CHAT INTERFACE (Crosum AI) ===== */

.chat-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 70px);
    max-width: 800px;
    margin: 0 auto;
    padding: 0 16px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
}

.chat-msg {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    max-width: 85%;
}

.chat-msg.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.chat-msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.chat-msg.ai .chat-msg-avatar {
    background: var(--brand-surface);
    color: var(--brand-primary);
}

.chat-msg.user .chat-msg-avatar {
    background: var(--brand-primary);
    color: #fff;
}

.chat-msg-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 14px 18px;
    font-size: 14.5px;
    line-height: 1.7;
    color: var(--text-primary);
}

.chat-msg.user .chat-msg-bubble {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}

.chat-input-area {
    padding: 16px 0;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 10px;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    font-size: 14.5px;
    color: var(--text-primary);
    background: var(--bg-secondary);
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--brand-primary);
}

.chat-send-btn {
    padding: 0 20px;
    background: var(--brand-primary);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-send-btn:hover { background: var(--brand-dark); }


/* ===========================================================
   MOBILE TOUCH TARGETS & RESPONSIVE IMPROVEMENTS
   =========================================================== */

/* 44px minimum touch targets for all interactive elements on mobile */
@media (max-width: 768px) {
    .sidebar-nav-link { min-height: 44px; padding: 12px 16px; font-size: 14px; }
    .profile-tab-btn { min-height: 44px; padding: 12px 16px; font-size: 14px; }
    .bm-sub-tab { min-height: 44px; padding: 12px 16px; font-size: 14px; }
    .search-type-dropdown div { min-height: 44px; padding: 12px 14px; }
    .pagination-controls button { min-height: 44px; min-width: 44px; }
    .carousel-btn { min-width: 44px; min-height: 44px; }
}

@media (max-width: 640px) {
    .sidebar-nav-link { font-size: 13px; }
    .profile-tab-btn { font-size: 12px; padding: 10px 12px; }
    .bm-sub-tab { font-size: 12px; padding: 10px 12px; }
    .sidebar-nav-link i, .profile-tab-btn i, .bm-sub-tab i { min-width: 14px; font-size: 14px; }

    /* Infobox cells readable on small screens */
    .info-table td, .info-table th,
    .infobox td, .infobox th { font-size: 13px; min-font-size: 13px; }
}

@media (max-width: 480px) {
    .header-actions .country-selector {
        display: none;
    }
}

/* ===========================================================
   SKIP TO CONTENT LINK — ACCESSIBILITY
   =========================================================== */
.skip-link {
    position: absolute;
    top: -100%;
    left: 16px;
    z-index: 9999;
    background: var(--brand-primary);
    color: #fff;
    padding: 12px 24px;
    border-radius: 0 0 8px 8px;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    transition: top 0.2s ease;
}
.skip-link:focus {
    top: 0;
}

/* ===========================================================
   FOOTER MEDICAL DISCLAIMER
   =========================================================== */
.footer-disclaimer {
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.1));
    padding: 16px 24px;
    margin-top: 20px;
    text-align: center;
}
.footer-disclaimer p {
    font-size: 12px;
    color: var(--text-muted, #999);
    opacity: 0.75;
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ===========================================================
   BREADCRUMB NAVIGATION
   =========================================================== */
.breadcrumb { padding: 12px 20px; max-width: 1200px; margin: 0 auto; }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; padding: 0; margin: 0; font-size: 13px; }
.breadcrumb li { display: flex; align-items: center; }
.breadcrumb li + li::before { content: "/"; margin: 0 8px; color: var(--text-muted); }
.breadcrumb a { color: var(--brand-primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb [aria-current="page"] { color: var(--text-muted); }

/* ===========================================================
   SKELETON LOADING ANIMATION
   =========================================================== */
.skeleton {
    background: linear-gradient(90deg, var(--bg-secondary, #f0f0f0) 25%, var(--bg-accent, #e0e0e0) 50%, var(--bg-secondary, #f0f0f0) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}
[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, var(--bg-secondary, #2a2a2a) 25%, var(--bg-accent, #333) 50%, var(--bg-secondary, #2a2a2a) 75%);
    background-size: 200% 100%;
}
.skeleton-text { height: 14px; margin-bottom: 10px; width: 80%; }
.skeleton-title { height: 22px; width: 60%; margin-bottom: 14px; }
.skeleton-image { height: 180px; width: 100%; margin-bottom: 12px; }
.skeleton-btn { height: 36px; width: 120px; }
@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===========================================================
   RECENTLY VIEWED
   =========================================================== */
.recently-viewed-section { max-width: 1200px; margin: 24px auto; padding: 0 20px; }
.recently-viewed-section h2 { font-size: 18px; margin-bottom: 12px; color: var(--text-primary); }
.recently-viewed-list { display: flex; flex-wrap: wrap; gap: 8px; }
.recently-viewed-item {
    padding: 8px 16px; background: var(--bg-secondary); border-radius: 20px;
    font-size: 13px; color: var(--brand-primary); text-decoration: none;
    border: 1px solid var(--border-color); transition: all 0.2s;
}
.recently-viewed-item:hover { background: var(--brand-surface); }

/* ===========================================================
   DATA SOURCES SECTION
   =========================================================== */
.sources-section { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border-color); }
.sources-section h3 { font-size: 16px; margin-bottom: 8px; color: var(--text-primary); }
.sources-note { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.sources-list { list-style: none; padding: 0; }
.sources-list li { padding: 6px 0; font-size: 13px; border-bottom: 1px solid var(--border-light, rgba(0,0,0,0.05)); }
.sources-list a { color: var(--brand-primary); text-decoration: none; font-weight: 600; }
.sources-list a:hover { text-decoration: underline; }

/* ===========================================================
   COOKIE CONSENT BANNER
   =========================================================== */
.cookie-banner {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary, #fff);
    z-index: 9998;
    box-shadow: 0 -2px 16px rgba(0,0,0,0.15);
    padding: 14px 24px calc(14px + env(safe-area-inset-bottom, 0px));
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-height: min(34vh, 136px);
    overflow: hidden;
    box-sizing: border-box;
}
[data-theme="dark"] .cookie-banner { background: var(--bg-secondary, #1a1a1a); }
.cookie-banner-content {
    width: min(900px, 100%);
    max-width: 900px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
}
.cookie-banner-content p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
    min-width: 0;
    line-height: 1.45;
}
body.has-cookie-banner { padding-bottom: calc(var(--cookie-banner-h, 72px) + 8px); }
@media (max-width: 640px) {
    .cookie-banner {
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
        max-height: min(30vh, 118px);
    }
    .cookie-banner-content {
        grid-template-columns: minmax(0, 1fr) minmax(86px, 104px);
        gap: 10px;
        align-items: center;
    }
    .cookie-banner-content p {
        text-align: left;
        font-size: 11.8px;
        line-height: 1.35;
        display: -webkit-box;
        -webkit-line-clamp: 4;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .cookie-accept-btn {
        width: 100%;
        min-width: 0;
        max-width: 104px;
        min-height: 44px;
        padding: 10px 12px;
        align-self: center;
    }
}
.cookie-banner-content a { color: var(--brand-primary); }
.cookie-accept-btn {
    background: var(--brand-primary); color: #fff; border: none;
    padding: 10px 24px; border-radius: 6px; font-size: 14px; font-weight: 600;
    cursor: pointer; white-space: nowrap;
}
.cookie-accept-btn:hover { opacity: 0.9; }

/* ===========================================================
   LAST UPDATED TIMESTAMP
   =========================================================== */
.last-updated {
    font-size: 12px; color: var(--text-muted); padding: 4px 0 8px;
    display: flex; align-items: center; gap: 6px;
}

/* ===========================================================
   PRINT STYLES
   =========================================================== */
@media print {
    .header, .sidebar, .sidebar-overlay, footer, .breadcrumb,
    .med-title-actions, .skip-link, .cookie-banner,
    .recently-viewed-section, #cookieBanner { display: none !important; }
    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 12pt;
        line-height: 1.6;
    }
    main, .med-body, .med-container {
        box-shadow: none !important;
        border: none !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 16px !important;
    }
    a { color: #000; text-decoration: underline; }
    a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #666; }
    img { max-width: 100% !important; }
    .no-print { display: none !important; }
}

/* ============================================================
   SETTINGS PAGE (profile.html?tab=settings)
   ============================================================ */
.settings-card{
    background:var(--bg-card);
    border:1px solid var(--border-light);
    border-radius:14px;
    margin-bottom:18px;
    overflow:hidden;
    transition:var(--transition-theme);
}
.settings-card.lang-select-open{
    overflow:visible;
    position:relative;
    z-index:100;
}
.settings-card-header{
    padding:14px 18px;
    background:var(--bg-accent);
    border-bottom:1px solid var(--border-light);
    font-size:15px;
    font-weight:700;
    color:var(--brand-primary);
    display:flex;
    align-items:center;
    gap:10px;
}
.settings-card-header i{font-size:15px;}
.settings-card-body{padding:18px;}
.settings-desc{
    font-size:13.5px;
    color:var(--text-muted);
    margin:0 0 14px;
    line-height:1.5;
}
.settings-desc-sm{
    font-size:12.5px;
    color:var(--text-muted);
    margin-top:2px;
}

/* Theme buttons */
.settings-theme-choices{
    display:grid;
    grid-template-columns:repeat(3,1fr);
    gap:10px;
}
.settings-theme-btn{
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:6px;
    padding:16px 10px;
    background:var(--bg-secondary);
    border:2px solid var(--border-light);
    border-radius:10px;
    color:var(--text-primary);
    font-size:13px;
    font-weight:600;
    cursor:pointer;
    transition:all 0.2s;
    min-height:72px;
}
.settings-theme-btn i{font-size:20px;color:var(--text-muted);}
.settings-theme-btn:hover{border-color:var(--brand-primary);}
.settings-theme-btn[aria-pressed="true"]{
    border-color:var(--brand-primary);
    background:var(--bg-accent);
    color:var(--brand-primary);
}
.settings-theme-btn[aria-pressed="true"] i{color:var(--brand-primary);}

/* Language dropdown (searchable) */
.lang-select{
    position:relative;
    width:min(420px, 100%);
    z-index:1;
}
.lang-select-trigger{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    width:100%;
    min-height:44px;
    padding:10px 14px;
    background:var(--bg-secondary);
    border:1px solid var(--border-color);
    border-radius:12px;
    color:var(--text-primary);
    font-size:14px;
    font-weight:500;
    cursor:pointer;
    font-family:inherit;
    transition:border-color 0.15s, background 0.15s;
}
.lang-select-trigger:hover,
.lang-select-trigger:focus{
    outline:none;
    border-color:var(--brand-primary);
}
.lang-select-trigger[aria-expanded="true"]{
    border-color:var(--brand-primary);
    background:var(--bg-accent);
}
.lang-select-current{
    display:inline-flex;
    align-items:baseline;
    gap:10px;
    min-width:0;
    overflow:hidden;
    text-overflow:ellipsis;
}
.lang-select-current .lang-name{
    font-weight:600;
    color:var(--text-primary);
}
.lang-select-caret{
    font-size:12px;
    color:var(--text-muted);
    transition:transform 0.2s;
}
.lang-select-trigger[aria-expanded="true"] .lang-select-caret{
    transform:rotate(180deg);
}
.lang-select-panel{
    position:absolute;
    top:calc(100% + 6px);
    left:0;
    right:0;
    max-height:340px;
    overflow:hidden;
    display:flex;
    flex-direction:column;
    background:var(--bg-secondary);
    border:1px solid var(--border-color);
    border-radius:12px;
    box-shadow:var(--shadow-lg);
    z-index:1200;
}
.lang-select-panel[hidden]{display:none;}
.lang-select-search{
    position:sticky;
    top:0;
    display:flex;
    align-items:center;
    gap:8px;
    padding:10px 12px;
    background:var(--bg-secondary);
    border-bottom:1px solid var(--border-light);
}
.lang-select-search i{
    color:var(--text-muted);
    font-size:13px;
}
.lang-select-search-input{
    flex:1;
    min-width:0;
    height:36px;
    padding:0 4px;
    background:transparent;
    border:none;
    color:var(--text-primary);
    font-size:14px;
    font-family:inherit;
    outline:none;
}
.lang-select-search-input::placeholder{color:var(--text-muted);}
.lang-select-list{
    list-style:none;
    margin:0;
    padding:6px 0;
    overflow-y:auto;
    flex:1;
}
.lang-select-row{
    display:flex;
    align-items:center;
    gap:10px;
    min-height:44px;
    padding:8px 14px;
    cursor:pointer;
    color:var(--text-primary);
    transition:background 0.1s;
}
.lang-select-row .lang-name{
    flex:1;
    min-width:0;
    font-weight:600;
    font-size:14px;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}
.lang-select-row .lang-en-name{
    color:var(--text-muted);
    font-size:12.5px;
    font-weight:500;
}
.lang-select-row .lang-code{
    color:var(--text-muted);
    font-size:11.5px;
    font-weight:700;
    letter-spacing:0.06em;
    text-transform:uppercase;
    min-width:28px;
    text-align:right;
}
.lang-select-row[data-highlight="1"]{
    background:var(--bg-accent);
    color:var(--brand-primary);
}
.lang-select-row[data-highlight="1"] .lang-en-name,
.lang-select-row[data-highlight="1"] .lang-code{
    color:var(--brand-primary);
}
.lang-select-row[aria-selected="true"]{
    background:var(--bg-accent);
}
.lang-select-row[aria-selected="true"] .lang-name{
    color:var(--brand-primary);
    font-weight:700;
}
.lang-select-empty{
    padding:20px 14px;
    text-align:center;
    color:var(--text-muted);
    font-size:13px;
}
@media (max-width:640px){
    .lang-select{width:100%;}
    .lang-select-row .lang-en-name{display:none;}
}

/* Form rows */
.settings-row{margin-bottom:14px;}
.settings-row:last-child{margin-bottom:0;}
.settings-label{
    display:block;
    font-size:13px;
    font-weight:600;
    color:var(--text-primary);
    margin-bottom:6px;
}
.settings-input{
    width:100%;
    padding:10px 12px;
    background:var(--bg-secondary);
    border:1px solid var(--border-light);
    border-radius:8px;
    color:var(--text-primary);
    font-size:14px;
    transition:border-color 0.2s;
    font-family:inherit;
}
.settings-input:focus{
    outline:none;
    border-color:var(--brand-primary);
}
.settings-readonly{
    padding:10px 12px;
    background:var(--bg-secondary);
    border:1px solid var(--border-light);
    border-radius:8px;
    color:var(--text-muted);
    font-size:14px;
}
.settings-row-inline{
    display:flex;
    justify-content:space-between;
    align-items:center;
    padding:10px 0;
    border-bottom:1px solid var(--border-light);
}
.settings-row-inline:last-child{border-bottom:none;}
.settings-readonly-inline{color:var(--text-muted);font-size:13.5px;}

/* Actions */
.settings-actions{
    display:flex;
    flex-wrap:wrap;
    gap:10px;
    margin-top:14px;
}
.settings-btn{
    display:inline-flex;
    align-items:center;
    gap:6px;
    padding:9px 16px;
    border-radius:8px;
    font-size:13.5px;
    font-weight:600;
    cursor:pointer;
    border:1px solid transparent;
    transition:all 0.2s;
    font-family:inherit;
    min-height:40px;
}
.settings-btn[hidden]{display:none}
.settings-btn-primary{background:var(--brand-primary);color:#fff;}
.settings-btn-primary:hover{background:var(--brand-dark);}
.settings-btn-outline{
    background:transparent;
    border-color:var(--border-color);
    color:var(--text-primary);
}
.settings-btn-outline:hover{border-color:var(--brand-primary);color:var(--brand-primary);}
.settings-btn-danger{background:var(--danger-border);color:#fff;}
.settings-btn-danger:hover{filter:brightness(0.9);}


/* About links */
.settings-links{
    display:flex;
    flex-wrap:wrap;
    gap:14px;
    margin-top:12px;
}
.settings-links a{
    font-size:13.5px;
    color:var(--brand-primary);
    text-decoration:none;
    font-weight:600;
}
.settings-links a:hover{text-decoration:underline;}

/* Mobile */
@media (max-width:640px){
    .settings-card-body{padding:14px;}
    .settings-theme-choices{grid-template-columns:repeat(3,1fr);gap:8px;}
    .settings-theme-btn{padding:12px 6px;min-height:64px;font-size:12px;}
    .settings-theme-btn i{font-size:18px;}
    .settings-actions .settings-btn{flex:1 1 100%;justify-content:center;}
}

/* ============================================================
   RTL SUPPORT (Urdu — html[dir="rtl"])
   Activated by loadLanguage() when locale _meta.dir === "rtl".
   ============================================================ */
html[dir="rtl"] body { direction: rtl; text-align: right; }
html[dir="rtl"] .header-top { flex-direction: row-reverse; }
html[dir="rtl"] .header-actions { flex-direction: row-reverse; }
html[dir="rtl"] .logo { text-align: right; }

/* Sidebar slides in from the LEFT in RTL */
html[dir="rtl"] #sidebar {
    right: auto;
    left: 0;
    transform: translateX(-100%);
    border-left: none;
    border-right: 1px solid var(--border-light);
}
html[dir="rtl"] #sidebar.open { transform: translateX(0); }
html[dir="rtl"] .sidebar-nav-link { text-align: right; }
html[dir="rtl"] .sidebar-nav-link i { margin-right: 0; margin-left: 10px; }

/* Footer columns flow right-to-left */
html[dir="rtl"] .footer-main { direction: rtl; }
html[dir="rtl"] .footer-col { text-align: right; }

/* Form inputs */
html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select { text-align: right; direction: rtl; }
html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="url"],
html[dir="rtl"] input[type="tel"],
html[dir="rtl"] input[type="password"] { direction: ltr; text-align: left; }

/* Settings page mirroring */
html[dir="rtl"] .settings-card-header { flex-direction: row-reverse; text-align: right; }
html[dir="rtl"] .settings-card-header i { margin-right: 0; }
html[dir="rtl"] .settings-actions { flex-direction: row-reverse; }
html[dir="rtl"] .settings-actions .settings-btn { flex-direction: row-reverse; }
html[dir="rtl"] .settings-row-inline { flex-direction: row-reverse; }
html[dir="rtl"] .settings-links { flex-direction: row-reverse; }

/* Profile sidebar tabs */
html[dir="rtl"] .profile-tab-btn { text-align: right; }
html[dir="rtl"] .profile-tab-btn i { margin-right: 0; margin-left: 8px; }

/* Generic icon spacing flip */
html[dir="rtl"] button i,
html[dir="rtl"] a i { margin-right: 0; }
html[dir="rtl"] button > i + span,
html[dir="rtl"] a > i + span { margin-right: 6px; }

/* Defensive LTR reset: if html has no dir, empty dir, or any non-rtl value,
   body stays LTR. Guards against stale state from prior sessions. */
html:not([dir="rtl"]) body { direction: ltr; text-align: left; }


/* ============================================================
   PHASE 5 — UNIFIED DESIGN SYSTEM
   Card · Button · Form · Empty State · Skeleton · Focus
   These are NEW utility classes that pages can opt into.
   Existing legacy styles remain intact for backward compatibility.
   ============================================================ */

/* ----- Card 5.5 ----- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-card);
    transition: var(--transition-theme), var(--transition-shadow), var(--transition-transform);
}
.card:hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-2px);
}
.card-header {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 12px;
}
.card-body { color: var(--text-secondary); font-size: 14px; line-height: 1.6; }

/* ----- Button system 5.6 ----- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 20px;
    border-radius: var(--radius-md);
    font-size: 14.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition-theme), var(--transition-shadow), var(--transition-transform);
    text-decoration: none;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}
.btn-primary:hover:not(:disabled) {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: transparent;
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--brand-surface);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-primary);
    border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--brand-primary);
}

.btn-danger {
    background: var(--danger-border);
    color: #fff;
    border-color: var(--danger-border);
}
.btn-danger:hover:not(:disabled) { filter: brightness(0.92); transform: translateY(-1px); }

.btn-sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn-lg { min-height: 52px; padding: 0 28px; font-size: 16px; }
.btn-block { width: 100%; }

/* ----- Form 5.7 ----- */
.field { margin-bottom: 16px; }
.field-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.field-input,
.field-textarea,
.field-select {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 16px; /* prevent iOS zoom */
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field-textarea { min-height: 96px; resize: vertical; }
.field-input:focus,
.field-textarea:focus,
.field-select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px var(--brand-primary);
}
.field-input.is-invalid,
.field-textarea.is-invalid {
    border-color: var(--danger-border);
}
.field-input.is-invalid:focus,
.field-textarea.is-invalid:focus {
    box-shadow: 0 0 0 2px var(--danger-border);
}
.field-error {
    display: block;
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--danger-text);
}
.field-help {
    display: block;
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--text-muted);
}

/* ----- Empty state 5.8 ----- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state-icon {
    font-size: 40px;
    color: var(--text-muted);
    opacity: 0.45;
    margin-bottom: 14px;
}
.empty-state-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 6px;
}
.empty-state-desc {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0 0 20px;
    max-width: 380px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.55;
}
.empty-state .btn { margin: 0 6px; }

/* ----- API error state ----- */
/* Shown when a backend call fails after JSON fallbacks were removed.
   Used by details/search/index pages on .catch() of cachedFetch / fetch. */
.api-error {
    padding: 40px 20px;
    text-align: center;
    color: var(--danger-text);
    font-size: 14px;
    line-height: 1.55;
}

/* ----- Micro-interactions 5.10 ----- */
:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}
button, a, input, textarea, select { outline: none; }
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* ----- Skeleton loader 5.11 ----- */
.skeleton {
    display: block;
    background: linear-gradient(90deg, var(--bg-tertiary) 0%, var(--bg-card-hover) 50%, var(--bg-tertiary) 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
    border-radius: var(--radius-sm);
}
.skeleton-text { height: 14px; margin: 6px 0; }
.skeleton-text.lg { height: 20px; }
.skeleton-text.sm { height: 10px; }
.skeleton-title { height: 22px; width: 60%; margin: 8px 0 14px; }
.skeleton-circle { border-radius: 50%; width: 48px; height: 48px; }
.skeleton-card {
    height: 180px;
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
}
.skeleton-line-90 { width: 90%; }
.skeleton-line-75 { width: 75%; }
.skeleton-line-60 { width: 60%; }
.skeleton-line-40 { width: 40%; }

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ----- Professional loading and page-transition motion ----- */
.skeleton-card,
.carousel-card.skeleton-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-light);
    background:
        radial-gradient(circle at 18% 14%, rgba(11,83,148,0.12), transparent 28%),
        linear-gradient(135deg, var(--bg-card), var(--bg-secondary));
    box-shadow: var(--shadow-sm);
}
.skeleton-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 15%, rgba(255,255,255,0.42) 42%, transparent 68%);
    transform: translateX(-120%);
    animation: csm-sheen 1.8s ease-in-out infinite;
}
[data-theme="dark"] .skeleton-card::after {
    background: linear-gradient(110deg, transparent 15%, rgba(255,255,255,0.08) 42%, transparent 68%);
}
.motion-enter {
    animation: csm-rise-in 520ms cubic-bezier(.2,.8,.2,1) both;
}
.motion-enter-stagger > * {
    animation: csm-rise-in 520ms cubic-bezier(.2,.8,.2,1) both;
}

.local-price-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    margin: 0 0 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-accent);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 650;
}

.local-price-banner[hidden] {
    display: none;
}

.local-price-banner .price-source {
    color: var(--text-muted);
    font-weight: 600;
}

.local-price-banner .price-confidence-low {
    color: var(--warning-color, #b45309);
    cursor: help;
}

.price-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: csm-spin 0.8s linear infinite;
    flex: 0 0 auto;
}

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

.rx-required-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    margin-left: 6px;
    border-radius: 999px;
    background: rgba(220, 38, 38, 0.10);
    color: #dc2626;
    border: 1px solid rgba(220, 38, 38, 0.28);
    font-size: 12px;
    vertical-align: middle;
    cursor: help;
}

.price-region-note {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 650;
}

.carousel-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.carousel-card-footer a {
    color: inherit;
    font-weight: 750;
    text-decoration: none;
}

.carousel-card-footer a:hover {
    text-decoration: underline;
}
.motion-enter-stagger > *:nth-child(1) { animation-delay: 20ms; }
.motion-enter-stagger > *:nth-child(2) { animation-delay: 70ms; }
.motion-enter-stagger > *:nth-child(3) { animation-delay: 120ms; }
.motion-enter-stagger > *:nth-child(4) { animation-delay: 170ms; }
.motion-enter-stagger > *:nth-child(5) { animation-delay: 220ms; }
.motion-enter-stagger > *:nth-child(n+6) { animation-delay: 260ms; }
.motion-page-next {
    animation: csm-slide-next 360ms cubic-bezier(.2,.8,.2,1) both;
}
.motion-page-prev {
    animation: csm-slide-prev 360ms cubic-bezier(.2,.8,.2,1) both;
}
.profile-panel.motion-panel-enter,
.med-panel.motion-panel-enter {
    animation: csm-panel-in 340ms cubic-bezier(.2,.8,.2,1) both;
}
@keyframes csm-sheen {
    0% { transform: translateX(-120%); }
    55%, 100% { transform: translateX(120%); }
}
@keyframes csm-rise-in {
    from { opacity: 0; transform: translateY(14px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes csm-slide-next {
    from { opacity: 0; transform: translateX(24px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes csm-slide-prev {
    from { opacity: 0; transform: translateX(-24px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes csm-panel-in {
    from { opacity: 0; transform: translateX(18px); }
    to { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .skeleton { animation: none; }
    .card:hover, .btn-primary:hover, .btn-secondary:hover { transform: none; }
}

/* ==================================================
   PHASE 7 — MOBILE IMPROVEMENTS
   ================================================== */

/* 7.2 iOS input zoom fix — iOS Safari zooms any input <16px on focus */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* 7.3 44px minimum touch targets on mobile */
@media (max-width: 768px) {
    button,
    a.btn,
    .btn,
    .icon-btn,
    .header-icon-btn,
    .sidebar-nav-link,
    .profile-tab-btn,
    .theme-btn,
    .lang-btn,
    .carousel-btn,
    .menu-btn,
    .search-submit,
    .landing-search-submit,
    .landing-type-btn {
        min-height: 44px;
        min-width: 44px;
    }
}

/* 7.4 Responsive tables — wrap <table> in .table-wrap for horizontal scroll */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
}
.table-wrap table { min-width: 560px; }
@media (max-width: 640px) {
    table { font-size: 13px; }
}

/* 7.5 Chat input sticky bottom on mobile */
@media (max-width: 768px) {
    .chat-input-wrap,
    .chat-composer {
        position: sticky;
        bottom: 0;
        background: var(--bg-card);
        border-top: 1px solid var(--border-color);
        padding: 10px 12px;
        z-index: 10;
        /* Account for iOS virtual-keyboard / safe area */
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }
}

/* 7.10 CLS — reserve space for common image slots */
img { max-width: 100%; height: auto; }
img[width][height] { aspect-ratio: attr(width) / attr(height); }

/* ===========================================================
   8. MOBILE OVERHAUL — touch targets, typography floor, gutters
   =========================================================== */

/* 8.1 Touch targets — enforce 44px floor on interactive elements ≤900px */
@media (max-width: 1024px) {
    .menu-btn,
    .carousel-btn,
    .med-title-action-btn,
    .cookie-accept-btn,
    .lang-btn,
    .theme-toggle-btn,
    .header-icon-btn {
        min-width: 44px;
        min-height: 44px;
    }
    .carousel-btn { width: 44px; height: 44px; }
}

/* 8.2 Typography floor — prevent iOS zoom on input focus, lift body text */
@media (max-width: 768px) {
    body { font-size: 15px; }
    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea {
        font-size: 16px;
    }
}

/* 8.3 Container / page gutters at very small widths */
@media (max-width: 640px) {
    .container,
    .page-content {
        padding-left: 14px;
        padding-right: 14px;
    }
}

/* 8.4 640px breakpoint — shrink header spacing for small tablets */
@media (max-width: 640px) {
    .header-top { padding: 10px 12px; gap: 8px; }
    .logo-name { font-size: 18px; }
    .logo-tagline { font-size: 12px; }
}

/* 8.5 Prevent horizontal overflow globally */
html, body { overflow-x: hidden; }


/* ==============================================
   v8 RESPONSIVE PASS — phone / tablet / desktop
   Consolidated rules applied globally via cascade
   so every page gets consistent tap targets,
   layout clamping, and popover behaviour.
   ============================================== */

/* ---- Layout wrappers: hard-clamp to viewport on phone ---- */
@media (max-width: 640px) {
    .container,
    .page-content,
    .med-page-wrapper,
    .landing-body,
    .profile-shell,
    .auth-card {
        max-width: 100%;
        padding-left: 14px;
        padding-right: 14px;
    }
    /* Tappable min size for all interactive glyphs/links in body text */
    .page-content a[href],
    .page-content button,
    .page-content [role="button"] {
        min-height: 44px;
    }
    /* Tables: let them scroll horizontally rather than overflow the page */
    table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    /* Absolute-positioned popovers fit within the viewport */
    .landing-type-dropdown,
    .attach-menu,
    .search-suggestions {
        max-width: calc(100vw - 32px);
        right: auto;
    }
    /* Prose pages (privacy/terms/about) — don't let long words blow the line */
    .prose, .prose p, .prose li {
        overflow-wrap: anywhere;
        word-break: break-word;
    }
    /* Hero typography ceiling */
    h1, .hero-title { font-size: clamp(22px, 6vw, 28px); line-height: 1.2; }
    h2 { font-size: clamp(18px, 5vw, 22px); }
}

/* ---- 375px narrow-phone polish ---- */
@media (max-width: 375px) {
    .container,
    .page-content,
    .med-page-wrapper,
    .landing-body,
    .profile-shell {
        padding-left: 12px;
        padding-right: 12px;
    }
    h1, .hero-title { font-size: 20px; }
    .logo-name { font-size: 16px; }
    .logo-tagline { display: none; }
    /* Keep the language dropdown panel readable at 320 */
    .lang-select-panel { max-height: 260px; }
}

/* ---- Details page chem canvas — cap height on phone ---- */
@media (max-width: 640px) {
    .chem-3d-canvas,
    .chem3d-canvas,
    .chem-canvas {
        height: min(360px, 60vh) !important;
        max-height: 60vh;
    }
}

/* ---- Subscription plan cards responsive ladder ---- */
@media (max-width: 640px)  { .plan-cards, .sub-plans { grid-template-columns: 1fr !important; } }
@media (min-width: 641px) and (max-width: 1023px) { .plan-cards, .sub-plans { grid-template-columns: 1fr 1fr !important; } }

/* ---- Prose readability cap ---- */
.prose, article, .legal-content {
    max-width: 72ch;
}

/* ---- Login / auth form ergonomics on phone ---- */
@media (max-width: 640px) {
    .auth-input, .login-input, input[type="email"], input[type="password"], input[type="text"].auth-field {
        min-height: 48px;
        font-size: 16px;  /* prevents iOS zoom-on-focus */
    }
}

/* ===== Change-password modal ===== */
.pw-modal{position:fixed;inset:0;z-index:1000;display:flex;align-items:center;justify-content:center;padding:16px}
.pw-modal[hidden]{display:none}
.pw-modal-backdrop{position:absolute;inset:0;background:rgba(0,0,0,0.55);backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px)}
.pw-modal-card{position:relative;width:min(440px,100%);max-height:90vh;overflow:auto;background:var(--bg-secondary);color:var(--text-primary);border:1px solid var(--border-color);border-radius:16px;box-shadow:var(--shadow-lg);padding:24px;transition:var(--transition-theme)}
.pw-modal-header{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:16px}
.pw-modal-header h3{margin:0;font-size:18px;font-weight:700;color:var(--text-primary)}
.pw-modal-close{appearance:none;background:transparent;border:none;color:var(--text-muted);font-size:28px;line-height:1;cursor:pointer;width:44px;height:44px;display:flex;align-items:center;justify-content:center;border-radius:8px}
.pw-modal-close:hover{background:var(--bg-primary);color:var(--text-primary)}
.pw-view{display:flex;flex-direction:column;gap:14px}
.pw-view[hidden]{display:none}
.pw-field{display:flex;flex-direction:column;gap:6px;font-size:13px;color:var(--text-muted);font-weight:600}
.pw-field input{width:100%;min-height:48px;padding:10px 14px;border:1px solid var(--border-color);border-radius:12px;background:var(--bg-primary);color:var(--text-primary);font-size:15px;box-sizing:border-box;transition:border-color 0.15s,box-shadow 0.15s}
.pw-field input:focus{outline:none;border-color:var(--brand-primary);box-shadow:0 0 0 2px rgba(77,163,255,0.25)}
.pw-field input[readonly]{background:var(--bg-primary);opacity:0.8;cursor:default}
.pw-btn-primary{width:100%;min-height:48px;padding:12px 18px;border:none;border-radius:12px;background:var(--brand-primary);color:#fff;font-size:15px;font-weight:700;cursor:pointer;transition:background 0.15s,opacity 0.15s}
.pw-btn-primary:hover{background:var(--brand-primary-hover,#1557b0)}
.pw-btn-primary[aria-busy="true"],.pw-btn-primary[disabled]{opacity:0.65;cursor:wait}
.pw-link{display:block;text-align:center;padding:10px 4px;font-size:14px;color:var(--text-muted);text-decoration:none;min-height:44px;line-height:24px}
.pw-link:hover{color:var(--brand-primary);text-decoration:underline}
.pw-form-error{color:#c62828;font-size:13px;padding:8px 10px;background:rgba(198,40,40,0.08);border-radius:8px;border:1px solid rgba(198,40,40,0.2)}
.pw-intro{margin:0;font-size:14px;color:var(--text-muted);line-height:1.5}
.pw-captcha-row{display:flex;align-items:stretch;gap:8px}
.pw-captcha-image{flex:1;min-height:60px;border:1px solid var(--border-color);border-radius:10px;background:#fff;display:flex;align-items:center;justify-content:center;padding:4px;overflow:hidden}
.pw-captcha-image svg{width:100%;height:auto;max-height:56px}
.pw-captcha-refresh{width:48px;min-height:48px;border:1px solid var(--border-color);border-radius:10px;background:var(--bg-primary);color:var(--text-primary);cursor:pointer;font-size:16px;display:flex;align-items:center;justify-content:center}
.pw-captcha-refresh:hover{background:var(--brand-primary);color:#fff;border-color:var(--brand-primary)}
@media (max-width:640px){
    .pw-modal{padding:8px}
    .pw-modal-card{padding:18px;border-radius:14px}
    .pw-modal-header h3{font-size:17px}
}
[dir="rtl"] .pw-view,[dir="rtl"] .pw-field{text-align:right}
[dir="rtl"] .pw-captcha-row{flex-direction:row-reverse}

/* === ARTICLE / NEWS DETAIL POLISH (additive — works alongside .detail-card) === */
.detail-body.article-body {
    line-height: 1.8;
    font-size: 16px;
    color: var(--text-primary);
}
.detail-body.article-body p { margin-bottom: 16px; }
.detail-body.article-body ul {
    padding-left: 20px;
    margin: 0 0 16px;
}
.detail-body.article-body li {
    margin-bottom: 8px;
    line-height: 1.7;
}
.detail-body.article-body li::marker { color: var(--brand-primary); }

.article-section-header {
    font-size: 18px;
    font-weight: 700;
    color: var(--brand-primary);
    margin: 28px 0 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--bg-accent);
}
.detail-body.article-body > .article-section-header:first-child { margin-top: 0; }

.detail-body.news-body {
    line-height: 1.8;
    font-size: 16px;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-left: 4px solid var(--brand-primary);
    padding: 20px 24px;
    border-radius: 0 8px 8px 0;
    margin: 20px 0;
}
.detail-body.news-body p { margin-bottom: 14px; }
.detail-body.news-body p:last-child { margin-bottom: 0; }
.detail-body.news-body .article-section-header {
    color: var(--brand-primary);
    margin: 18px 0 10px;
}

