@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800;1,9..40,400;1,9..40,700&family=DM+Mono:wght@400;500&display=swap');

:root,
[data-theme="light"] {
    --bg: #f4f5f8;
    --surface: #ffffff;
    --surface-2: #eef0f5;
    --border: #e2e5ec;
    --border-focus: #3b7df8;
    --text-primary: #0f1623;
    --text-secondary: #5c6578;
    --text-muted: #9ba3b4;
    --accent: #3b7df8;
    --accent-hover: #2563eb;
    --accent-subtle: #eef3ff;
    --gold: #ffd250;
    --danger: #ef4444;
    --danger-subtle: #fef2f2;
    --danger-border: #fecaca;
    --success: #10b981;
    --success-subtle: #f0fdf4;
    --dark: #0a0a0f;
    --dark-2: #131320;
    --dark-border: #1e1e2e;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,.09), 0 2px 4px rgba(0,0,0,.04);
    --font: 'DM Sans', sans-serif;
    --font-mono: 'DM Mono', monospace;
    --topbar-h: 60px;
}

/* ── Dark Theme ──────────────────────────────────────────────────────────── */
[data-theme="dark"] {
    --bg: #1a1a26;
    --surface: #23233a;
    --surface-2: #2c2c45;
    --border: #3a3a55;
    --border-focus: #ffd250;
    --text-primary: #f0f0f8;
    --text-secondary: #a0a0c0;
    --text-muted: #6a6a8a;
    --accent: #ffd250;
    --accent-hover: #f5c430;
    --accent-subtle: rgba(255,210,80,0.12);
    --gold: #ffd250;
    --danger: #f87171;
    --danger-subtle: rgba(239,68,68,0.12);
    --danger-border: rgba(239,68,68,0.35);
    --success: #34d399;
    --success-subtle: rgba(52,211,153,0.12);
    --dark: #13131e;
    --dark-2: #1e1e2e;
    --dark-border: #2e2e45;
}

[data-theme="dark"] body { background: var(--bg); color: var(--text-primary); }
[data-theme="dark"] .topbar { background: #13131e; border-color: #2a2a40; }

/* Light theme topbar - warm neutral, clearly different from ocean */
[data-theme="light"] .topbar { background: #2d2d2d; border-color: #404040; }
[data-theme="light"] .page-hero { background: #2d2d2d; }
[data-theme="light"] .hero { background: #2d2d2d; }

/* Olive theme topbar */
[data-theme="warm"] .topbar { background: #2c2416; border-color: #3d3221; }
[data-theme="warm"] .page-hero { background: #2c2416; }
[data-theme="warm"] .hero { background: #2c2416; }

/* Ocean theme topbar */
[data-theme="ocean"] .topbar { background: #03304a; border-color: #044a6e; }
[data-theme="ocean"] .page-hero { background: #03304a; }
[data-theme="ocean"] .hero { background: #03304a; }

/* Forest theme topbar */
[data-theme="forest"] .topbar { background: #1a2e1a; border-color: #2d4a2d; }
[data-theme="forest"] .page-hero { background: #1a2e1a; }
[data-theme="forest"] .hero { background: #1a2e1a; }

/* All non-dark themes: ensure topbar text is white */
[data-theme="light"] .topbar,
[data-theme="warm"] .topbar,
[data-theme="ocean"] .topbar,
[data-theme="forest"] .topbar { color: white; }
[data-theme="light"] .topbar h1,
[data-theme="warm"] .topbar h1,
[data-theme="ocean"] .topbar h1,
[data-theme="forest"] .topbar h1 { color: white; }
[data-theme="light"] .topbar nav a,
[data-theme="warm"] .topbar nav a,
[data-theme="ocean"] .topbar nav a,
[data-theme="forest"] .topbar nav a { color: rgba(255,255,255,0.65); }
[data-theme="light"] .topbar nav a:hover,
[data-theme="warm"] .topbar nav a:hover,
[data-theme="ocean"] .topbar nav a:hover,
[data-theme="forest"] .topbar nav a:hover { color: white; }
[data-theme="dark"] .form-card,
[data-theme="dark"] .filter-card,
[data-theme="dark"] .table-wrap,
[data-theme="dark"] .rx-card { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] table thead tr { background: var(--surface-2); }
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--surface-2);
    border-color: var(--border);
}
[data-theme="dark"] .page-hero { background: #13131e; }
[data-theme="dark"] .hero { background: #13131e; }
[data-theme="dark"] .stats-bar { background: var(--surface); border-color: var(--border); }

/* ── Olive / Warm Theme ──────────────────────────────────────────────────── */
[data-theme="warm"] {
    --bg: #f5f3ee;
    --surface: #fefcf7;
    --surface-2: #ede9df;
    --border: #d4cfc4;
    --border-focus: #8b7355;
    --text-primary: #2c2416;
    --text-secondary: #6b5d48;
    --text-muted: #a09078;
    --accent: #8b7355;
    --accent-hover: #7a6245;
    --accent-subtle: #f0ebe0;
    --gold: #c9a227;
    --danger: #c0392b;
    --danger-subtle: #fdf0ee;
    --danger-border: #f5c6c2;
    --success: #27ae60;
    --success-subtle: #edfaf3;
    --dark: #2c2416;
    --dark-2: #3d3221;
    --dark-border: #c4bfb4;
}

/* ── Ocean / Blue Theme ──────────────────────────────────────────────────── */
[data-theme="ocean"] {
    --bg: #f0f4f8;
    --surface: #ffffff;
    --surface-2: #e2ecf6;
    --border: #c5d8ee;
    --border-focus: #0077b6;
    --text-primary: #023e58;
    --text-secondary: #2c6e8a;
    --text-muted: #7aacbe;
    --accent: #0096c7;
    --accent-hover: #0077b6;
    --accent-subtle: #e0f2f9;
    --gold: #f4a261;
    --danger: #e63946;
    --danger-subtle: #fdecea;
    --danger-border: #f9b4b8;
    --success: #2a9d8f;
    --success-subtle: #e8f8f5;
    --dark: #03304a;
    --dark-2: #044a6e;
    --dark-border: #b8d4e8;
}

/* ── Forest / Green Theme ────────────────────────────────────────────────── */
[data-theme="forest"] {
    --bg: #f0f4f0;
    --surface: #ffffff;
    --surface-2: #e4ede4;
    --border: #c8dcc8;
    --border-focus: #2d6a4f;
    --text-primary: #1a2e1a;
    --text-secondary: #3d6b3d;
    --text-muted: #7aaa7a;
    --accent: #40916c;
    --accent-hover: #2d6a4f;
    --accent-subtle: #d8f3dc;
    --gold: #d4a017;
    --danger: #d62828;
    --danger-subtle: #fdecea;
    --danger-border: #f9b4b8;
    --success: #52b788;
    --success-subtle: #e8f8f0;
    --dark: #1a2e1a;
    --dark-2: #2d4a2d;
    --dark-border: #b8d4b8;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    background: var(--bg);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--dark);
    border-bottom: 1px solid var(--dark-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    z-index: 100;
    box-shadow: 0 2px 20px rgba(0,0,0,0.3);
}

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    flex-shrink: 0;
}

.topbar-logo-icon {
    width: 30px;
    height: 30px;
    background: var(--gold);
    border-radius: 8px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%230a0a0f'%3E%3Cpath d='M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z'/%3E%3C/svg%3E");
    background-size: 17px;
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
}

.topbar-logo-name {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 1px;
    color: white;
}

.topbar h1 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 800;
    color: white;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    cursor: default;
}

.topbar h1::before {
    content: '';
    display: inline-block;
    width: 30px;
    height: 30px;
    background: var(--gold);
    border-radius: 8px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%230a0a0f'%3E%3Cpath d='M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z'/%3E%3C/svg%3E");
    background-size: 17px;
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
}

.topbar nav { display: flex; align-items: center; gap: 2px; }

.topbar nav a {
    text-decoration: none;
    color: rgba(255,255,255,0.55);
    font-size: 13.5px;
    font-weight: 500;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
}

.topbar nav a:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.9); }
.topbar nav a.active { background: rgba(255,210,80,0.15); color: var(--gold); }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.topbar-login-link {
    font-size: 13px;
    font-weight: 600;
    color: var(--gold);
    text-decoration: none;
    padding: 6px 12px;
    border: 1px solid rgba(255,210,80,0.3);
    border-radius: 6px;
    transition: background 0.15s;
}

.topbar-login-link:hover {
    background: rgba(255,210,80,0.1);
}

.topbar-store-name {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255,255,255,0.45);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .topbar-store-name { display: none; }
    .topbar nav a { padding: 7px 10px; font-size: 12.5px; }
}

.topbar-logout-btn {
    height: 30px;
    padding: 0 12px;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.15);
    background: transparent;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.topbar-logout-btn:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.9);
    border-color: rgba(255,255,255,0.25);
}


.container {
    max-width: 1320px;
    margin: 0 auto;
    padding: calc(var(--topbar-h) + 28px) 28px 60px;
}

.page-hero {
    background: var(--dark);
    border-radius: 16px;
    padding: 36px 40px;
    margin-bottom: 28px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.page-hero::before {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    border-radius: 50%;
    border: 1px solid rgba(255,210,80,0.07);
    top: -200px; right: -100px;
    pointer-events: none;
}

.page-hero::after {
    content: '';
    position: absolute;
    width: 240px; height: 240px;
    border-radius: 50%;
    border: 1px solid rgba(255,210,80,0.1);
    top: -100px; right: 0px;
    pointer-events: none;
}

.page-hero-left { position: relative; z-index: 1; }

.page-hero-eyebrow {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 8px;
    opacity: 0.8;
}

.page-hero h2 {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -1px;
    color: white;
    margin: 0;
}

.page-hero-stats {
    display: flex;
    gap: 32px;
    position: relative;
    z-index: 1;
    flex-wrap: wrap;
}

.page-hero-stat { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }

.page-hero-stat-value {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: white;
    line-height: 1;
}

.page-hero-stat-label {
    font-size: 11px;
    font-weight: 500;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; color: var(--text-primary); margin: 0 0 24px; }
h3 { font-size: 11px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-muted); margin: 0 0 14px; }

.form-card, .filter-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.form-card:hover, .filter-card:hover { box-shadow: var(--shadow-md); }
.form-row, .filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

input, select {
    height: 36px;
    padding: 0 12px;
    font-family: var(--font);
    font-size: 13.5px;
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    min-width: 140px;
}
textarea {
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13.5px;
}

/* Placeholder: use the theme's secondary text (darker than muted) so field
   hints are easy to read while still matching the theme. Must NOT use
   -webkit-text-fill-color here. */
input::placeholder,
textarea::placeholder { color: var(--text-secondary); opacity: 1; }

/* Ensure typed text is always visible across themes */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea { color: #f0f0f8 !important; }

[data-theme="warm"] input,
[data-theme="warm"] select,
[data-theme="warm"] textarea { color: #2c2416 !important; }

[data-theme="ocean"] input,
[data-theme="ocean"] select,
[data-theme="ocean"] textarea { color: #023e58 !important; }

[data-theme="forest"] input,
[data-theme="forest"] select,
[data-theme="forest"] textarea { color: #1a2e1a !important; }

[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea { color: #0f1623 !important; }
input:focus, select:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(59,125,248,.12); }
input[type="number"] { min-width: 110px; }

select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
    cursor: pointer;
}

/* Select placeholder — muted color when no value selected */
select.sel-placeholder:not(.has-value),
select.sel-placeholder option[value=""] { color: var(--text-muted); }
select.sel-placeholder option:not([value=""]) { color: var(--text-primary); }

button, a button {
    height: 36px;
    padding: 0 16px;
    font-family: var(--font);
    font-size: 13.5px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
    white-space: nowrap;
}

button:hover { background: var(--surface-2); border-color: #d1d5db; }
button:active { transform: translateY(1px); }

button[type="submit"]:not(.action-btn) {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(59,125,248,0.25);
}

button[type="submit"]:not(.action-btn):hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(59,125,248,0.35);
}

.summary {
    display: inline-flex;
    align-items: center;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 18px;
    margin: 8px 0 16px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
}

.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 13.5px; }
thead { background: var(--dark); border-bottom: 2px solid var(--dark-border); }

th {
    padding: 12px 16px;
    text-align: left;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.45);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: color 0.15s;
}

th:hover { color: rgba(255,255,255,0.8); }
th.sort-asc, th.sort-desc { color: var(--gold); }
th.sort-asc::after { content: " ↑"; font-size: 11px; }
th.sort-desc::after { content: " ↓"; font-size: 11px; }

td { padding: 12px 16px; border-top: 1px solid var(--border); color: var(--text-primary); vertical-align: middle; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: #f8f9fc; }

td form { margin: 0; display: inline; }

.action-btn {
    height: 28px;
    padding: 0 10px;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 5px;
    min-width: auto;
    margin: 0 2px;
}

.action-btn[value="1"]:hover { background: var(--success-subtle); border-color: #86efac; color: #16a34a; }
.action-btn[value="-1"]:hover { background: var(--danger-subtle); border-color: var(--danger-border); color: var(--danger); }
.action-btn[onclick] { color: var(--danger); border-color: var(--danger-border); }
.action-btn[onclick]:hover { background: var(--danger-subtle); border-color: var(--danger); }

.error-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--danger-subtle);
    border: 1px solid var(--danger-border);
    color: #b91c1c;
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-weight: 500;
}

.error-box::before { content: '⚠'; font-size: 15px; flex-shrink: 0; }

[dir="auto"] { text-align: start; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

@media (max-width: 768px) {
    .page-hero { padding: 28px 24px; }
    .page-hero h2 { font-size: 24px; }
    .page-hero-stats { gap: 20px; }
    .page-hero-stat-value { font-size: 18px; }
    .page-hero-stat { align-items: flex-start; }
}

@media (max-width: 640px) {
    .container { padding: calc(var(--topbar-h) + 16px) 16px 32px; }
    .form-card, .filter-card { padding: 16px; }
    .topbar { padding: 0 16px; }
}



/* ═══════════════════════════════════════════════════════════════════════════
   RTL OVERRIDES — uses !important to override all base styles
   Triggered by html[dir="rtl"] set in base.html when lang=he or ar
   ═══════════════════════════════════════════════════════════════════════════ */

[dir="rtl"] { direction: rtl; text-align: right; }
[dir="rtl"] body { direction: rtl !important; }

/* Topbar */
[dir="rtl"] .topbar { flex-direction: row-reverse !important; }
[dir="rtl"] .topbar h1 { flex-direction: row-reverse !important; color: white !important; }
/* RX tables always LTR regardless of page direction */
[dir="rtl"] .rx-table,
[dir="rtl"] .rx-table-wrap,
[dir="rtl"] .rx-history-table { direction: ltr !important; }

/* Inputs inside RX tables must type LTR and align left */
[dir="rtl"] .rx-table input,
[dir="rtl"] .rx-table select,
[dir="rtl"] .rx-table td,
[dir="rtl"] .rx-table th { direction: ltr !important; text-align: left !important; }

[dir="rtl"] .rx-table input[type="text"],
[dir="rtl"] .rx-table input[type="number"] { text-align: left !important; direction: ltr !important; }

/* Full exam modal table always LTR */
[dir="rtl"] #full-exam-overlay table,
[dir="rtl"] #full-exam-overlay td,
[dir="rtl"] #full-exam-overlay th { direction: ltr !important; text-align: left; }

[dir="rtl"] .topbar nav { direction: rtl !important; flex-direction: unset !important; }
[dir="rtl"] .topbar-user { flex-direction: row-reverse !important; }

/* Mobile menu */
[dir="rtl"] .mobile-menu { text-align: right !important; }
[dir="rtl"] .mobile-menu a { text-align: right !important; padding-right: 8px !important; padding-left: 0 !important; }
[dir="rtl"] .mobile-menu-user { flex-direction: row-reverse !important; }

/* Page hero */
/* page-hero RTL: swap children order using flex order property */
[dir="rtl"] .page-hero { direction: rtl !important; }
[dir="rtl"] .page-hero-left { order: 2 !important; text-align: right !important; }
[dir="rtl"] .page-hero-stats { order: 1 !important; text-align: right !important; }
[dir="rtl"] .page-hero-left h2 { text-align: right !important; }
[dir="rtl"] .page-hero-eyebrow { text-align: right !important; direction: rtl !important; }
[dir="rtl"] .page-hero-stat { align-items: flex-end !important; text-align: right !important; }
[dir="rtl"] .page-hero-stat-value { text-align: right !important; }
[dir="rtl"] .page-hero-stat-label { text-align: right !important; }

/* Home hero */
[dir="rtl"] .hero { direction: rtl !important; }
[dir="rtl"] .hero-content { text-align: right !important; align-items: flex-start !important; }
[dir="rtl"] .hero-title { text-align: right !important; align-items: flex-start !important; }
[dir="rtl"] .hero-desc { text-align: right !important; }
[dir="rtl"] .hero-eyebrow { text-align: right !important; }
[dir="rtl"] .hero-ctas { flex-direction: row-reverse !important; justify-content: flex-start !important; }
[dir="rtl"] .hero-glasses { left: 40px !important; right: auto !important; }

/* Stats bar */
[dir="rtl"] .stats-bar { flex-direction: row-reverse !important; }
[dir="rtl"] .stat-pill { text-align: right !important; }
[dir="rtl"] .stat-pill-value { text-align: right !important; }
[dir="rtl"] .stat-pill-label { text-align: right !important; }

/* Feature cards */
[dir="rtl"] .feature-card { text-align: right !important; direction: rtl !important; }
[dir="rtl"] .feature-card h3 { text-align: right !important; }
[dir="rtl"] .feature-card p { text-align: right !important; }

/* Forms */
[dir="rtl"] .form-row { flex-direction: row !important; justify-content: flex-start !important; }
[dir="rtl"] .filter-row { flex-direction: row !important; justify-content: flex-start !important; }
[dir="rtl"] .form-card { direction: rtl !important; text-align: right !important; }
[dir="rtl"] .form-card h3 { text-align: right !important; }
[dir="rtl"] .filter-card { direction: rtl !important; text-align: right !important; }
[dir="rtl"] .filter-card h3 { text-align: right !important; }
[dir="rtl"] .form-card input,
[dir="rtl"] .form-card select,
[dir="rtl"] .form-card textarea,
[dir="rtl"] .filter-card input,
[dir="rtl"] .filter-card select { direction: rtl !important; text-align: right !important; }

/* Inputs */
[dir="rtl"] input[type="text"],
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="number"],
[dir="rtl"] input[type="password"],
[dir="rtl"] textarea,
[dir="rtl"] select { text-align: right !important; direction: rtl !important; }

/* Tables */
[dir="rtl"] .table-wrap { direction: rtl !important; }
[dir="rtl"] table { direction: rtl !important; }
[dir="rtl"] th { text-align: right !important; }
[dir="rtl"] td { text-align: right !important; }

/* Type selector */
[dir="rtl"] .type-selector { flex-direction: row-reverse !important; }

/* Rx form */
[dir="rtl"] .rx-form-card { direction: rtl !important; }
[dir="rtl"] .rx-section-title { text-align: right !important; }
[dir="rtl"] .rx-field { align-items: flex-end !important; }
[dir="rtl"] .rx-field label { text-align: right !important; }
[dir="rtl"] .rx-table th { text-align: center !important; }
[dir="rtl"] .rx-table td { text-align: center !important; }
[dir="rtl"] .eye-label { text-align: right !important; }

/* Prescription cards */
[dir="rtl"] .rx-card { direction: rtl !important; }
[dir="rtl"] .rx-card-header { flex-direction: row-reverse !important; }
[dir="rtl"] .rx-card-date { text-align: right !important; }
[dir="rtl"] .rx-card-actions { flex-direction: row-reverse !important; }
[dir="rtl"] .rx-row { flex-direction: row-reverse !important; }
[dir="rtl"] .rx-row-label { text-align: right !important; }
[dir="rtl"] .rx-chips { flex-direction: row-reverse !important; }

/* Patient info */
[dir="rtl"] .info-field { align-items: flex-start !important; }
[dir="rtl"] .info-label { text-align: right !important; }
[dir="rtl"] .info-value { text-align: right !important; }

/* Photo panel */
[dir="rtl"] .photo-grid { flex-direction: row-reverse !important; }
[dir="rtl"] .photo-actions { flex-direction: row-reverse !important; }

/* Error box */
[dir="rtl"] .error-box { text-align: right !important; direction: rtl !important; }

/* input[list] - explicit color to fix datalist-attached inputs */
input[list] { color: var(--text-primary); background: var(--surface); }
[data-theme="dark"] input[list] { color: #f0f0f8; background: var(--surface-2); }
[data-theme="warm"] input[list] { color: #2c2416; }
[data-theme="ocean"] input[list] { color: #023e58; }
[data-theme="forest"] input[list] { color: #1a2e1a; }
[data-theme="light"] input[list] { color: #0f1623; }

/* Fix topbar logo visibility in RTL */
[dir="rtl"] .topbar h1::before { flex-shrink: 0; }

/* Settings page - only has left section, no stats */
[dir="rtl"] .page-hero-left { direction: rtl !important; order: 1 !important; width: 100% !important; }
[dir="rtl"] .page-hero h2 { text-align: right !important; width: 100% !important; }
[dir="rtl"] .page-hero-eyebrow { display: block !important; text-align: right !important; width: 100% !important; }

/* Table cells and headers in form areas */
[dir="rtl"] .form-card table th { text-align: right !important; }
[dir="rtl"] .form-card table td { text-align: right !important; }
