/* ============================================================
   FONT DECLARATIONS — Emerald & Gold Design System
   Fonts served from /fonts/ (path relative to Admin IIS site root)
   ============================================================ */
@font-face { font-family: 'Tajawal'; font-weight: 300; font-style: normal; font-display: swap; src: url('/fonts/tajawal/tajawal-300.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+0000-00FF; }
@font-face { font-family: 'Tajawal'; font-weight: 400; font-style: normal; font-display: swap; src: url('/fonts/tajawal/tajawal-400.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+0000-00FF; }
@font-face { font-family: 'Tajawal'; font-weight: 500; font-style: normal; font-display: swap; src: url('/fonts/tajawal/tajawal-500.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+0000-00FF; }
@font-face { font-family: 'Tajawal'; font-weight: 700; font-style: normal; font-display: swap; src: url('/fonts/tajawal/tajawal-700.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+0000-00FF; }
@font-face { font-family: 'Tajawal'; font-weight: 900; font-style: normal; font-display: swap; src: url('/fonts/tajawal/tajawal-900.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+0000-00FF; }
@font-face { font-family: 'Be Vietnam Pro'; font-weight: 400; font-style: normal; font-display: swap; src: url('/fonts/be-vietnam-pro/be-vietnam-pro-400.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC; }
@font-face { font-family: 'Be Vietnam Pro'; font-weight: 400; font-style: italic; font-display: swap; src: url('/fonts/be-vietnam-pro/be-vietnam-pro-400-italic.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC; }
@font-face { font-family: 'Be Vietnam Pro'; font-weight: 500; font-style: normal; font-display: swap; src: url('/fonts/be-vietnam-pro/be-vietnam-pro-500.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC; }
@font-face { font-family: 'Be Vietnam Pro'; font-weight: 700; font-style: normal; font-display: swap; src: url('/fonts/be-vietnam-pro/be-vietnam-pro-700.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC; }
@font-face { font-family: 'Material Symbols Outlined'; font-weight: 100 700; font-style: normal; font-display: block; src: url('/fonts/material-symbols/material-symbols-outlined.woff2') format('woff2'); }

/* Material Symbols base class */
.material-symbols-outlined {
    font-family: 'Material Symbols Outlined', sans-serif;
    font-weight: normal; font-style: normal; font-size: 24px; line-height: 1;
    letter-spacing: normal; text-transform: none; display: inline-block;
    white-space: nowrap; word-wrap: normal; direction: ltr;
    -webkit-font-smoothing: antialiased; font-feature-settings: 'liga';
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    transition: font-variation-settings 200ms ease;
}
.material-symbols-outlined.icon-sm { font-size: 18px; font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20; }
.material-symbols-outlined.icon-filled, .active .material-symbols-outlined { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }

/* ============================================================
   DESIGN TOKENS — Emerald & Gold
   ============================================================ */
/* Structural tokens — no colours, so nothing here can be themed away. */
:root {
    --admin-radius: 10px;
    --font-family: 'Be Vietnam Pro', 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --glass-blur: blur(20px) saturate(1.4);
}

/* ------------------------------------------------------------
   ADMIN PALETTE

   Scoped to the admin roots, NOT to :root, and that is deliberate.
   The admin portal is served by the chat host, so themes.css defines
   --nav-bg, --text-primary, --accent and friends on <html> under
   [data-theme="..."] selectors that outrank anything admin.css can
   declare on :root. The admin UI used to inherit those, so picking a
   light chat theme turned the sidebar near-white while its link colour
   stayed hard-coded white — the nav items became invisible.

   Custom properties resolve from the nearest ancestor that declares
   them, so declaring the whole palette here — below <html> — makes the
   admin portal immune to the chat theme regardless of specificity.
   The chat-app aliases are redeclared too, so the existing rules that
   reference them stay correct inside this subtree.

   Light and dark both keep the deep emerald sidebar: white-on-emerald
   is legible in either mode, and it is the one surface that broke.
   ------------------------------------------------------------ */
.admin-layout,
.admin-login-page {
    --admin-content-bg: #f1f4f3;
    --admin-card-bg: #ffffff;
    --admin-text: #16211d;
    --admin-text-muted: #596b64;
    --admin-border: #dbe4e0;
    --admin-primary: #0f6b57;
    --admin-primary-hover: #0a5344;
    --admin-danger: #b3392a;
    --admin-danger-soft: #fdeeec;
    --admin-success: #157f52;
    --admin-warning: #a3690a;

    --admin-sidebar-bg: #0d332b;
    --admin-sidebar-text: rgba(255, 255, 255, 0.87);
    --admin-sidebar-heading: #ffffff;
    --admin-sidebar-subtitle: rgba(255, 255, 255, 0.58);
    --admin-sidebar-active: #ffd79a;
    --admin-sidebar-active-bg: rgba(255, 215, 154, 0.14);
    --admin-sidebar-hover: rgba(255, 255, 255, 0.10);
    --admin-sidebar-hover-text: #ffffff;

    --admin-topbar-bg: #ffffff;
    --admin-topbar-border: #e2e9e6;

    /* Aliases consumed by existing rules in this file. */
    --bg-primary: var(--admin-content-bg);
    --bg-secondary: #ffffff;
    --text-primary: var(--admin-text);
    --text-secondary: var(--admin-text-muted);
    --accent: var(--admin-primary);
    --accent-hover: var(--admin-primary-hover);
    --accent-text: #ffffff;
    --accent-rgb: 15, 107, 87;
    --accent-light: #ffd79a;
    --border: var(--admin-border);
    --nav-bg: var(--admin-sidebar-bg);
    --nav-text: var(--admin-sidebar-text);
    --card-bg: var(--admin-card-bg);
    --hover-bg: #eaefed;
    --input-bg: #f6f8f7;
    --input-bg-focus: #ffffff;
    --input-border: #c8d4cf;
    --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 16px 32px rgba(15,107,87,0.10), 0 4px 8px rgba(0,0,0,0.06);
    --color-secondary: rgba(255,255,255,0.85);
    --color-secondary-fixed: #ffd79a;
    --glass-bg: rgba(255, 255, 255, 0.88);

    color-scheme: light;
}

/* Dark — follows the OS unless the portal has been set to light. */
@media (prefers-color-scheme: dark) {
    html:not([data-admin-theme="light"]) .admin-layout,
    html:not([data-admin-theme="light"]) .admin-login-page {
        --admin-content-bg: #101613;
        --admin-card-bg: #18211d;
        --admin-text: #e7ece9;
        --admin-text-muted: #9bada6;
        --admin-border: #28342f;
        --admin-primary: #3fae90;
        --admin-primary-hover: #55c4a5;
        --admin-danger: #e0796a;
        --admin-danger-soft: #2e1e1b;
        --admin-success: #4fb883;
        --admin-warning: #d3a24a;

        --admin-sidebar-bg: #0a1311;
        --admin-sidebar-text: rgba(255, 255, 255, 0.84);
        --admin-sidebar-subtitle: rgba(255, 255, 255, 0.50);
        --admin-sidebar-active-bg: rgba(255, 215, 154, 0.12);

        --admin-topbar-bg: #151d1a;
        --admin-topbar-border: #232e29;

        --bg-secondary: #18211d;
        --accent-rgb: 63, 174, 144;
        --hover-bg: #1f2a25;
        --input-bg: #131b18;
        --input-bg-focus: #18211d;
        --input-border: #303d37;
        --shadow: 0 1px 3px rgba(0,0,0,0.45), 0 1px 2px rgba(0,0,0,0.3);
        --shadow-md: 0 16px 32px rgba(0,0,0,0.5), 0 4px 8px rgba(0,0,0,0.35);
        --color-secondary: rgba(255,255,255,0.85);
        --glass-bg: rgba(21, 29, 26, 0.88);

        color-scheme: dark;
    }
}

/* Dark — chosen explicitly in the portal. */
html[data-admin-theme="dark"] .admin-layout,
html[data-admin-theme="dark"] .admin-login-page {
    --admin-content-bg: #101613;
    --admin-card-bg: #18211d;
    --admin-text: #e7ece9;
    --admin-text-muted: #9bada6;
    --admin-border: #28342f;
    --admin-primary: #3fae90;
    --admin-primary-hover: #55c4a5;
    --admin-danger: #e0796a;
    --admin-danger-soft: #2e1e1b;
    --admin-success: #4fb883;
    --admin-warning: #d3a24a;

    --admin-sidebar-bg: #0a1311;
    --admin-sidebar-text: rgba(255, 255, 255, 0.84);
    --admin-sidebar-subtitle: rgba(255, 255, 255, 0.50);
    --admin-sidebar-active-bg: rgba(255, 215, 154, 0.12);

    --admin-topbar-bg: #151d1a;
    --admin-topbar-border: #232e29;

    --bg-secondary: #18211d;
    --accent-rgb: 63, 174, 144;
    --hover-bg: #1f2a25;
    --input-bg: #131b18;
    --input-bg-focus: #18211d;
    --input-border: #303d37;
    --shadow: 0 1px 3px rgba(0,0,0,0.45), 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 16px 32px rgba(0,0,0,0.5), 0 4px 8px rgba(0,0,0,0.35);
    --color-secondary: rgba(255,255,255,0.85);
    --glass-bg: rgba(21, 29, 26, 0.88);

    color-scheme: dark;
}

/* Page ground behind the layout, so there is no flash of the chat theme. */
html { background: #f1f4f3; }
@media (prefers-color-scheme: dark) {
    html:not([data-admin-theme="light"]) { background: #101613; }
}
html[data-admin-theme="dark"] { background: #101613; }
html[data-admin-theme="light"] { background: #f1f4f3; }

/* ============================================================
   BASE — body font, reset, headings
   ============================================================ */
html, body {
    font-family: var(--font-family);
    font-size: 15px;
    background: var(--bg-primary);
    color: var(--text-primary);
    margin: 0; padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { font-family: var(--font-family); color: var(--text-primary); margin: 0 0 16px; line-height: 1.3; }
h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 20px; }
h3 { font-size: 1.05rem; font-weight: 700; }

*, *::before, *::after { box-sizing: border-box; }

/* ============================================================
   LAYOUT
   ============================================================ */
/* Sets colour and background explicitly: <body> sits above this scope and still
   carries the chat theme's --text-primary, so anything that merely inherited
   would pick up the wrong theme's text colour. */
.admin-layout {
    display: flex; height: 100vh; overflow: hidden; max-width: 100%;
    background: var(--admin-content-bg);
    color: var(--admin-text);
}

/* Sidebar */
.admin-sidebar {
    width: 256px; min-width: 256px; background: var(--admin-sidebar-bg);
    color: var(--admin-sidebar-text); display: flex; flex-direction: column;
    transition: transform 0.25s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,0.12);
}
.sidebar-header {
    padding: 22px 20px 14px;
    box-shadow: inset 0 -1px 0 rgba(255,255,255,0.1);
}
.sidebar-header h2 { margin: 0 0 2px; font-size: 1.2rem; font-weight: 700; color: var(--admin-sidebar-heading); }
.sidebar-subtitle {
    font-size: 0.72rem;
    color: var(--admin-sidebar-subtitle);
    text-transform: uppercase; letter-spacing: 0.06em;
}

.sidebar-nav { list-style: none; padding: 10px 0; margin: 0; flex: 1; overflow-y: auto; }
.sidebar-nav li a {
    display: flex; align-items: center; gap: 10px; padding: 11px 20px;
    color: var(--admin-sidebar-text);
    text-decoration: none; font-size: 0.88rem; font-weight: 500;
    border-inline-start: 3px solid transparent;
    transition: background 0.15s, color 0.15s;
}
.sidebar-nav li a:hover { background: var(--admin-sidebar-hover); color: var(--admin-sidebar-hover-text); }
.sidebar-nav li a:focus-visible {
    outline: 2px solid var(--admin-sidebar-active);
    outline-offset: -2px;
}
.sidebar-nav li a.active {
    background: var(--admin-sidebar-active-bg);
    border-inline-start-color: var(--admin-sidebar-active);
    color: var(--admin-sidebar-active);
    font-weight: 600;
}
.sidebar-nav li a .material-symbols-outlined { opacity: 0.75; flex-shrink: 0; }
.sidebar-nav li a.active .material-symbols-outlined {
    opacity: 1;
    color: var(--admin-sidebar-active);
    font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 20;
}

/* Main area */
.admin-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.admin-topbar {
    height: 56px; min-height: 56px;
    background: var(--admin-topbar-bg);
    border-bottom: 1px solid var(--admin-topbar-border);
    display: flex; align-items: center; padding: 0 20px; gap: 14px;
    position: relative; z-index: 10;
}
.topbar-title { flex: 1; font-weight: 600; font-size: 0.95rem; color: var(--admin-text); }
.hamburger-btn {
    display: none; background: none; border: none; cursor: pointer;
    color: var(--admin-text); padding: 4px; border-radius: 6px;
    transition: background 0.15s;
}
.hamburger-btn:hover { background: var(--hover-bg); }
.hamburger-btn .material-symbols-outlined { font-size: 22px; display: block; }

.theme-toggle-btn {
    display: inline-flex; align-items: center; justify-content: center;
    background: none; border: 1px solid var(--admin-border);
    width: 34px; height: 34px; border-radius: 50%;
    cursor: pointer; color: var(--admin-text-muted);
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    flex: none;
}
.theme-toggle-btn:hover {
    color: var(--admin-primary);
    border-color: var(--admin-primary);
    background: var(--hover-bg);
}
.theme-toggle-btn:focus-visible {
    outline: 2px solid var(--admin-primary);
    outline-offset: 2px;
}
.theme-toggle-btn .material-symbols-outlined { font-size: 19px; display: block; }

.logout-btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: none; border: 1px solid var(--admin-border);
    padding: 6px 14px; border-radius: 20px;
    cursor: pointer; font-size: 0.82rem; font-weight: 500;
    color: var(--admin-text-muted); transition: all 0.2s;
    font-family: var(--font-family);
}
.logout-btn:hover { border-color: var(--admin-danger); color: var(--admin-danger); background: var(--admin-danger-soft); }

.admin-content { flex: 1; overflow-y: auto; padding: 24px; background: var(--admin-content-bg); }

/* ============================================================
   CARDS
   ============================================================ */
.admin-card {
    background: var(--admin-card-bg); border-radius: 1rem;
    border: none; box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.admin-card h3 { margin: 0 0 16px; }

/* Summary Cards (legacy class names — kept for backwards compat) */
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.summary-card {
    background: var(--admin-card-bg); border-radius: 1rem;
    border: none; box-shadow: var(--shadow); padding: 18px; text-decoration: none; color: inherit;
    transition: box-shadow 0.2s, transform 0.15s;
}
.summary-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.summary-card .card-label { font-size: 0.75rem; color: var(--admin-text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.summary-card .card-value { font-size: 1.9rem; font-weight: 700; color: var(--text-primary); margin: 6px 0 0; }

/* ============================================================
   DASHBOARD — Header + Metric Tiles grid
   Used by Dashboard.razor + MetricTile.razor (feature 025, US1)
   ============================================================ */
.dashboard-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.dashboard-header h2 { margin: 0; }
.dashboard-header-actions {
    display: flex; align-items: center; gap: 10px;
}
.auto-refresh-label {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.82rem; color: var(--admin-text-muted);
}
.auto-refresh-label select {
    padding: 4px 8px; border-radius: 6px; border: 1px solid var(--admin-border);
    background: var(--admin-card-bg); font-size: 0.82rem; width: auto;
}
.btn-secondary {
    padding: 7px 16px; border-radius: var(--admin-radius); border: 1px solid var(--admin-border);
    background: var(--admin-card-bg); color: var(--admin-text); font-size: 0.82rem;
    cursor: pointer; transition: background 0.15s;
}
.btn-secondary:hover { background: var(--hover-bg); border-color: var(--admin-primary); color: var(--admin-text); }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-tile {
    display: block;
    background: var(--admin-card-bg);
    border-radius: 1rem;
    border: none;
    box-shadow: var(--shadow);
    padding: 20px;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s, transform 0.15s;
}
a.metric-tile:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); cursor: pointer; }
.metric-tile-label {
    font-size: 0.78rem;
    color: var(--admin-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    margin-bottom: 6px;
}
.metric-tile-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--admin-primary);
    line-height: 1.2;
}
.metric-tile-sublabel {
    font-size: 0.75rem;
    color: var(--admin-text-muted);
    margin-top: 4px;
}

/* Health-status tint classes for the Background Services tile */
.metric-health-ok .metric-tile-value { color: var(--admin-success); }
.metric-health-warn .metric-tile-value { color: #d97706; }
.metric-health-fail .metric-tile-value { color: var(--admin-danger); }

/* ============================================================
   FORMS & INPUTS
   ============================================================ */
.admin-form { max-width: 420px; margin: 0 auto; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--admin-text); margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 9px 12px;
    border: 1.5px solid var(--input-border);
    border-radius: var(--admin-radius); font-size: 0.88rem;
    background: var(--input-bg); color: var(--text-primary);
    font-family: var(--font-family);
    box-sizing: border-box; transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--color-secondary);
    background: var(--input-bg-focus);
    box-shadow: 0 0 0 3px rgba(119,90,25,0.15);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 20px; border: none; border-radius: 20px;
    cursor: pointer; font-size: 0.88rem; font-weight: 600;
    font-family: var(--font-family);
    transition: all 0.2s; text-decoration: none;
}
.btn-primary { background: linear-gradient(135deg, #003229 0%, #005042 100%); color: #fff; }
.btn-primary:hover { background: linear-gradient(135deg, #001f18 0%, #003229 100%); box-shadow: 0 4px 12px rgba(0,50,41,0.3); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger { background: var(--admin-danger); color: #fff; border-radius: 20px; }
.btn-danger:hover { background: #a93226; box-shadow: 0 4px 10px rgba(192,57,43,0.3); }
.btn-outline {
    background: transparent; border: 1.5px solid var(--admin-border);
    color: var(--admin-text); border-radius: 20px;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb), 0.04); }
.btn-sm { padding: 5px 14px; font-size: 0.8rem; }

/* ============================================================
   HIDE CLIENT NAV — When any admin page (.admin-login-page,
   .admin-layout) is present in the DOM, the main client app's
   navigation bar (.app-nav) must not render. This CSS rule is a
   defence-in-depth complement to the MainLayout.IsAdminPage check:
   even if the server DLL is stale or the CDN serves a cached
   SSR shell, the nav bar still disappears on admin routes.
   ============================================================ */
.admin-login-page ~ .app-layout > .app-nav,
.admin-layout ~ .app-layout > .app-nav,
body:has(.admin-login-page) .app-nav,
body:has(.admin-layout) .app-nav { display: none !important; }
body:has(.admin-login-page) .app-layout,
body:has(.admin-layout) .app-layout { display: contents; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.admin-login-page {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--admin-sidebar-bg) 0%, #163d31 45%, var(--admin-content-bg) 100%);
    color: var(--admin-text);
}
.admin-login-card {
    background: var(--admin-card-bg); border-radius: 1.25rem;
    border: none; padding: 40px 40px 32px; width: 100%; max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
}
.admin-login-card h1 { margin: 0 0 6px; font-size: 1.6rem; color: var(--admin-text); text-align: center; font-weight: 700; }
.admin-login-card .subtitle { text-align: center; color: var(--admin-text-muted); margin-bottom: 28px; font-size: 0.9rem; }
.admin-login-card .form-group label { font-weight: 600; }
.admin-login-card .btn-primary { margin-top: 8px; padding: 12px; font-size: 0.95rem; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--admin-radius); margin-bottom: 14px; font-size: 0.85rem; }
/* Tinted from the semantic colour against the card surface, so both
   themes get a readable alert without a second set of tokens. */
.alert-error {
    background: color-mix(in srgb, var(--admin-danger) 12%, var(--admin-card-bg));
    color: var(--admin-danger);
    border-left: 3px solid var(--admin-danger);
}
.alert-success {
    background: color-mix(in srgb, var(--admin-success) 12%, var(--admin-card-bg));
    color: var(--admin-success);
    border-left: 3px solid var(--admin-success);
}
/* Neutral notice — an expired session is not the operator's mistake, so it must
   not be dressed as an error next to the sign-in form. */
.alert-info {
    background: color-mix(in srgb, var(--admin-warning) 12%, var(--admin-card-bg));
    color: var(--admin-warning);
    border-left: 3px solid var(--admin-warning);
}

/* ============================================================
   SETTINGS PAGE
   ============================================================ */

/* Sticky save bar */
.settings-save-bar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 18px; margin-bottom: 16px;
    background: linear-gradient(135deg, #003229 0%, #005042 100%);
    border-radius: 1rem; color: #fff;
    box-shadow: 0 4px 16px rgba(0,50,41,0.25);
    animation: slideDown 0.2s ease;
}
.settings-save-bar .save-count {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.88rem; font-weight: 500; opacity: 0.95;
}
.settings-save-actions { display: flex; gap: 8px; flex-shrink: 0; }
.save-bar-discard {
    background: rgba(255,255,255,0.12) !important;
    color: rgba(255,255,255,0.85) !important;
    border: 1px solid rgba(255,255,255,0.25) !important;
    border-radius: 20px !important; padding: 5px 14px !important;
}
.save-bar-discard:hover { background: rgba(255,255,255,0.2) !important; color: #fff !important; }
.save-bar-save {
    background: #fff !important; color: #003229 !important;
    font-weight: 700 !important; border-radius: 20px !important; padding: 5px 16px !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.save-bar-save:hover { background: #f0fdf4 !important; }
.save-bar-save:disabled { opacity: 0.6; cursor: not-allowed; }

@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.settings-category { margin-bottom: 20px; background: var(--card-bg); border-radius: 1rem; overflow: hidden; box-shadow: var(--shadow); }
.settings-category h3 { margin: 0; font-size: 0.95rem; color: var(--text-primary); padding: 14px 18px; font-weight: 700; background: rgba(var(--accent-rgb), 0.03); box-shadow: inset 0 -1px 0 rgba(var(--accent-rgb), 0.08); }
.setting-row {
    display: flex; align-items: center; gap: 16px; padding: 12px 18px;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.04);
    transition: background 0.15s;
}
.setting-row:last-child { box-shadow: none; }
.setting-row:hover { background: rgba(var(--accent-rgb), 0.02); }
.setting-info { flex: 1; min-width: 180px; }
.setting-info .setting-name { font-weight: 600; font-size: 0.88rem; color: var(--text-primary); display: flex; align-items: center; gap: 4px; }
.setting-info .setting-desc { font-size: 0.78rem; color: var(--admin-text-muted); margin-top: 2px; line-height: 1.4; }
.setting-control { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.setting-control input, .setting-control select {
    width: 200px; padding: 7px 10px;
    border: 1.5px solid var(--input-border); border-radius: var(--admin-radius);
    font-size: 0.85rem; background: var(--input-bg); color: var(--text-primary);
    font-family: var(--font-family);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.setting-control input:focus, .setting-control select:focus {
    outline: none; border-color: var(--color-secondary);
    background: var(--input-bg-focus);
    box-shadow: 0 0 0 2px rgba(119,90,25,0.15);
}

/* Color picker group — hex-color settings show a native color input + text + swatch */
.setting-color-group {
    display: flex; align-items: center; gap: 8px;
}
.setting-color-picker {
    width: 42px !important; height: 38px; padding: 2px !important;
    border: 1.5px solid var(--input-border); border-radius: var(--admin-radius);
    cursor: pointer; background: transparent;
}
.setting-color-picker::-webkit-color-swatch-wrapper { padding: 2px; }
.setting-color-picker::-webkit-color-swatch { border: none; border-radius: 4px; }
.setting-color-picker::-moz-color-swatch { border: none; border-radius: 4px; }
.setting-color-text { width: 120px !important; font-family: 'Consolas', 'Menlo', monospace; }
.setting-color-swatch {
    display: inline-block; width: 24px; height: 24px; border-radius: 50%;
    border: 2px solid var(--admin-border); flex-shrink: 0;
}

/* Dirty indicator */
.setting-dirty-dot { color: var(--color-secondary); font-size: 0.55rem; vertical-align: middle; margin-left: 3px; }

/* Toggle switch — scoped to admin pages only */
.admin-layout .toggle-switch { position: relative; width: 46px; height: 24px; flex-shrink: 0; }
.admin-layout .toggle-switch input { opacity: 0; width: 0; height: 0; }
.admin-layout .toggle-slider {
    position: absolute; inset: 0; background: #cbd5e1; border-radius: 24px;
    cursor: pointer; transition: background 0.25s;
}
.admin-layout .toggle-slider::before {
    content: ""; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px;
    background: white; border-radius: 50%; transition: transform 0.25s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.admin-layout .toggle-switch input:checked + .toggle-slider { background: var(--admin-primary); }
.admin-layout .toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }

/* ============================================================
   TABLES
   ============================================================ */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin-table th {
    text-align: left; padding: 10px 14px;
    background: rgba(var(--accent-rgb), 0.04);
    box-shadow: inset 0 -2px 0 rgba(var(--accent-rgb), 0.12);
    color: var(--admin-text-muted); font-weight: 600; font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.04em;
    white-space: nowrap;
}
.admin-table td { padding: 10px 14px; box-shadow: inset 0 -1px 0 var(--admin-border); color: var(--admin-text); }
.admin-table tr:hover td { background: rgba(var(--accent-rgb), 0.025); }
.admin-table tr.log-row-expanded td { background: rgba(var(--accent-rgb), 0.04); }
.log-message-cell { max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 0.72rem; font-weight: 600; white-space: nowrap; }
.badge-info { background: rgba(var(--accent-rgb), 0.14); color: var(--admin-primary); }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-grey { background: #f1f5f9; color: #64748b; }
.badge-new { background: #dcfce7; color: #15803d; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
    display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px;
    padding: 14px 16px; background: var(--admin-card-bg); border-radius: 1rem;
    border: none; box-shadow: var(--shadow);
}
.filter-bar .form-group { margin-bottom: 0; }
.filter-bar .form-group label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--admin-text-muted); font-weight: 600; }
.filter-bar .form-group input, .filter-bar .form-group select {
    padding: 7px 10px; font-size: 0.85rem;
    background: var(--input-bg); color: var(--text-primary); border: 1.5px solid var(--input-border);
}
.filter-bar .form-group input:focus, .filter-bar .form-group select:focus {
    outline: none; border-color: var(--color-secondary);
    background: var(--input-bg-focus);
    box-shadow: 0 0 0 2px rgba(119,90,25,0.15);
}
.filter-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filter-row .form-group { min-width: 130px; }
.filter-search { flex: 1; min-width: 180px; }
.filter-actions {
    display: flex; gap: 8px; align-items: center; padding-top: 4px;
    box-shadow: inset 0 1px 0 rgba(0,0,0,0.05);
    flex-wrap: wrap;
}

/* ============================================================
   PAGINATION — single line
   ============================================================ */
.pagination {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; margin-top: 12px;
    background: var(--admin-card-bg); border-radius: 1rem; box-shadow: var(--shadow);
    font-size: 0.82rem; color: var(--admin-text-muted);
    flex-wrap: nowrap; gap: 12px;
}
.pagination-info { white-space: nowrap; flex-shrink: 1; overflow: hidden; text-overflow: ellipsis; }
.pagination-controls { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.pagination-controls button {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; padding: 0;
    border: 1.5px solid var(--admin-border); background: var(--admin-card-bg);
    border-radius: 8px; cursor: pointer; color: var(--admin-text);
    transition: all 0.15s;
}
.pagination-controls button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb), 0.05); }
.pagination-controls button:disabled { opacity: 0.35; cursor: not-allowed; }
.pagination-pages { font-weight: 600; color: var(--text-primary); font-size: 0.82rem; white-space: nowrap; padding: 0 2px; }
.pagination-controls select {
    padding: 4px 8px; border: 1.5px solid var(--admin-border);
    border-radius: 8px; font-size: 0.82rem;
    background: var(--input-bg); color: var(--text-primary);
    font-family: var(--font-family); cursor: pointer;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: var(--admin-card-bg); border-radius: 1rem; padding: 24px; width: 90%; max-width: 480px; max-height: 80vh; overflow-y: auto; box-shadow: var(--shadow-md); }
.modal-content h3 { margin: 0 0 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ============================================================
   TOAST
   ============================================================ */
.admin-toast {
    position: fixed; bottom: 20px; right: 20px;
    padding: 12px 20px; border-radius: 12px; color: #fff;
    font-size: 0.85rem; font-weight: 500; z-index: 2000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    animation: slideIn 0.25s ease;
    max-width: 320px;
}
.admin-toast.success { background: var(--admin-success); }
.admin-toast.error { background: var(--admin-danger); }
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============================================================
   LOG EXPANDED DETAIL
   ============================================================ */
/* Tinted from the page background so the expanded row reads as recessed in
   both themes. These were literal light colours, which left the detail pane
   pale in dark mode with dark-mode text on top of it. */
.expandable-detail { padding: 0; background: var(--admin-content-bg); box-shadow: inset 0 -1px 0 rgba(0,0,0,0.04); }

.log-detail-header {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 16px 8px;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.05);
    background: color-mix(in srgb, var(--admin-text) 5%, var(--admin-content-bg));
    color: var(--admin-text);
    flex-wrap: wrap;
}
.log-detail-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.log-meta-item {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.78rem; color: var(--admin-text-muted);
}
.log-source { font-size: 0.76rem; font-family: 'Consolas', 'Menlo', monospace; color: var(--accent); }

.copy-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 12px; border-radius: 20px;
    background: var(--admin-card-bg); border: 1.5px solid var(--admin-border);
    font-size: 0.78rem; font-weight: 600; color: var(--admin-text-muted);
    cursor: pointer; font-family: var(--font-family);
    transition: all 0.15s; flex-shrink: 0;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb), 0.05); }

.log-detail-section { padding: 10px 16px; }
.log-section-label {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--admin-text-muted); margin-bottom: 6px;
}
.log-section-error { color: var(--admin-danger); }

.log-pre {
    margin: 0; padding: 10px 14px;
    background: #1e2d24; color: #d4e8d4;
    border-radius: 8px; overflow-x: auto;
    font-size: 0.78rem; line-height: 1.6;
    white-space: pre-wrap; word-break: break-word;
    font-family: 'Consolas', 'Menlo', 'Monaco', monospace;
}
.log-pre-error { background: #2d1e1e; color: #f5b8b8; }
.log-pre-props { background: #1e2028; color: #b8c8d8; }

/* ============================================================
   AUDIT VALUES — Compact, high-contrast blocks for the audit
   detail panel. The log-pre style is designed for multi-line
   log content and looks heavy/low-contrast on a single-word
   audit value like "enabled" / "disabled".
   ============================================================ */
.audit-values {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}
@media (max-width: 720px) {
    .audit-values { grid-template-columns: 1fr; }
}
.audit-value {
    display: block;
    margin: 0;
    padding: 10px 14px;
    background: color-mix(in srgb, var(--admin-text) 4%, var(--admin-card-bg));
    color: var(--admin-text);
    border: 1px solid var(--admin-border);
    border-left: 3px solid var(--admin-text-muted);
    border-radius: 6px;
    font-size: 0.88rem;
    line-height: 1.5;
    font-family: 'Consolas', 'Menlo', 'Monaco', monospace;
    white-space: pre-wrap;
    word-break: break-word;
}
/* Old value: muted amber/grey accent so the user can distinguish "before" at a glance. */
.audit-value-old { border-left-color: #c97d3a; background: #fdf7f1; }
/* New value: primary brand green accent so "after" stands out. */
.audit-value-new { border-left-color: #2e7d32; background: #f1f8f2; }

/* RTL: flip the left accent stripe to the right side so it still aligns with the "start" of the block. */
[dir="rtl"] .audit-value { border-left: 1px solid #e0e8e0; border-right: 3px solid #7a8a7a; }
[dir="rtl"] .audit-value-old { border-right-color: #c97d3a; border-left-color: #e0e8e0; }
[dir="rtl"] .audit-value-new { border-right-color: #2e7d32; border-left-color: #e0e8e0; }

/* ============================================================
   USER MODERATION — two-column layout: list + detail panel
   ============================================================ */
.users-layout { display: flex; gap: 20px; align-items: flex-start; }
.users-list { flex: 1; min-width: 0; }
.users-detail {
    flex: 0 0 380px; position: sticky; top: 20px;
    max-height: calc(100vh - 120px); overflow-y: auto;
}
.user-detail-stats {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; text-align: center;
    margin: 8px 0;
}
.user-detail-stats div { background: var(--admin-content-bg); border-radius: 8px; padding: 10px 6px; }
.user-detail-stats strong { font-size: 1.3rem; color: var(--admin-primary); }
.user-detail-stats span { font-size: 0.75rem; color: var(--admin-text-muted); }
.device-list { list-style: none; padding: 0; margin: 0; }
.device-list li { padding: 8px 0; border-bottom: 1px solid var(--admin-border); }
.device-list li:last-child { border-bottom: none; }

@media (max-width: 960px) {
    .users-layout { flex-direction: column; }
    .users-detail { flex: none; width: 100%; position: static; max-height: none; }
}

/* Scrollable table wrapper */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; position: relative; }
.table-responsive .admin-table { min-width: 560px; }

/* ============================================================
   SIDEBAR OVERLAY (mobile)
   ============================================================ */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 998; }

/* ============================================================
   RESPONSIVE — Tablet (769px – 1199px)
   ============================================================ */
@media (min-width: 769px) and (max-width: 1199px) {
    .admin-sidebar { width: 210px; min-width: 210px; }
    .summary-cards { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
    .dashboard-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
}

/* ============================================================
   RESPONSIVE — 768px (tablet / sidebar collapse)
   ============================================================ */
@media (max-width: 768px) {
    .admin-sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 999; width: 260px; min-width: 260px; transform: translateX(-100%); }
    .admin-sidebar.open { transform: translateX(0); }
    .hamburger-btn { display: flex; }
    .sidebar-overlay { display: block; }
    .setting-row { flex-direction: column; align-items: flex-start; gap: 8px; }
    .setting-control { width: 100%; }
    .setting-control input, .setting-control select { width: 100%; }
    .filter-row { flex-direction: column; }
    .filter-row .form-group { width: 100%; min-width: unset; }
    .filter-bar .form-group input, .filter-bar .form-group select { width: 100%; }
    .filter-actions { flex-wrap: wrap; }
    .admin-content { padding: 14px; }
    .modal-content { width: 95%; max-width: none; padding: 18px; }
    .settings-save-bar { flex-wrap: wrap; gap: 8px; }
    .log-detail-header { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* ============================================================
   RESPONSIVE — 480px (mobile)
   ============================================================ */
@media (max-width: 480px) {
    .admin-content { padding: 10px; }
    .admin-card { padding: 14px; }
    .admin-login-card { padding: 20px; margin: 0 10px; max-width: none; }
    .summary-cards { grid-template-columns: 1fr; gap: 10px; }
    .summary-card { padding: 14px; }
    .summary-card .card-value { font-size: 1.5rem; }
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .metric-tile { padding: 14px; }
    .metric-tile-value { font-size: 1.5rem; }
    .dashboard-header { flex-direction: column; align-items: stretch; }
    .dashboard-header-actions { justify-content: space-between; }
    .modal-content { width: 100%; margin: 0 6px; border-radius: 8px; padding: 14px; max-height: 90vh; }
    .admin-topbar { padding: 0 10px; }
    .admin-table th, .admin-table td { padding: 8px 8px; font-size: 0.78rem; }
    .filter-bar { padding: 10px; gap: 8px; }
    .btn { padding: 8px 16px; }
    .btn-sm { padding: 5px 10px; font-size: 0.78rem; }
    h2 { font-size: 1.25rem; }
    .pagination { padding: 8px 12px; }
    .pagination-info { font-size: 0.76rem; }
}

/* ============================================================
   LOG ANALYTICS
   These class names were referenced by Logs.razor but never had
   any styling, so the analytics block rendered unstyled.
   Layout uses logical properties throughout so it mirrors in RTL
   without a parallel set of rules.
   ============================================================ */
.log-analytics-card { padding: 18px 20px 20px; }

.analytics-head {
    display: flex; flex-wrap: wrap; align-items: baseline;
    justify-content: space-between; gap: 8px 16px; margin-bottom: 16px;
}
.analytics-head h3 { margin: 0; }
.analytics-window {
    font-size: 0.75rem; color: var(--admin-text-muted);
    font-variant-numeric: tabular-nums;
}

/* Summary tiles — auto-fit so five tiles reflow to 2 or 1 column on narrow screens */
.log-analytics-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}
.summary-item {
    background: var(--admin-content-bg);
    border: 1px solid var(--admin-border);
    border-inline-start: 3px solid var(--admin-border);
    border-radius: var(--admin-radius);
    padding: 12px 14px;
    min-width: 0;
}
.summary-label {
    font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--admin-text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.summary-value {
    font-size: 1.6rem; font-weight: 700; color: var(--admin-text);
    line-height: 1.2; margin-top: 4px;
    font-variant-numeric: tabular-nums;
}
.summary-unit { font-size: 0.9rem; font-weight: 600; color: var(--admin-text-muted); margin-inline-start: 2px; }
.summary-item.summary-error { border-inline-start-color: var(--admin-danger); }
.summary-item.summary-error .summary-value { color: var(--admin-danger); }
.summary-item.summary-warn { border-inline-start-color: var(--admin-warning); }
.summary-item.summary-warn .summary-value { color: var(--admin-warning); }

/* Panels: wide ones take the full row, the rest pair up */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    align-items: start;
}
.analytics-panel {
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    padding: 14px;
    background: var(--admin-card-bg);
    min-width: 0;   /* lets charts shrink instead of overflowing the grid track */
}
.analytics-panel h4 {
    margin: 0 0 10px; font-size: 0.85rem; font-weight: 700;
    color: var(--admin-text); letter-spacing: 0.01em;
}
@media (min-width: 900px) {
    .analytics-panel-wide { grid-column: span 2; }
}

.chart-container { width: 100%; min-width: 0; }
.chart-container .apexcharts-canvas { margin: 0 auto; }
/* ApexCharts injects its own tooltip markup outside our token scope */
.apexcharts-tooltip { border: 1px solid var(--admin-border) !important; box-shadow: var(--shadow-md) !important; }

/* Top errors */
.top-errors-table .top-error-sig {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.78rem;
    word-break: break-word;
    max-width: 0;           /* with table-layout auto this lets the cell wrap */
}
.top-error-row { cursor: pointer; }
.top-error-row:hover td { background: rgba(var(--accent-rgb), 0.06); }
.admin-table .col-num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.admin-table .col-level { width: 110px; white-space: nowrap; }
.admin-table .col-seen { width: 96px; white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 0.78rem; }
.admin-table .col-time { width: 150px; white-space: nowrap; }
.logs-table .log-time { font-size: 0.78rem; font-variant-numeric: tabular-nums; }

/* Log detail panes stay LTR — stack traces and JSON are not translatable content */
.log-pre { direction: ltr; text-align: left; }

/* Empty + loading states */
.empty-state { text-align: center; padding: 40px 20px; color: var(--admin-text-muted); }
.empty-icon { font-size: 40px; opacity: 0.5; display: block; margin: 0 auto 8px; }
.empty-hint { color: var(--admin-text-muted); font-size: 0.85rem; margin: 12px 0 0; }
.admin-loading { color: var(--admin-text-muted); padding: 20px 4px; }

/* ============================================================
   LANGUAGE TOGGLE
   ============================================================ */
.lang-toggle-btn {
    display: inline-flex; align-items: center; justify-content: center;
    background: none; border: 1px solid var(--admin-border);
    min-width: 34px; height: 34px; padding: 0 8px; border-radius: 17px;
    cursor: pointer; color: var(--admin-text-muted);
    font-family: var(--font-family); font-size: 0.78rem; font-weight: 700;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    flex: none;
}
.lang-toggle-btn:hover {
    color: var(--admin-primary); border-color: var(--admin-primary); background: var(--hover-bg);
}
.lang-toggle-btn:focus-visible { outline: 2px solid var(--admin-primary); outline-offset: 2px; }

/* ============================================================
   RIGHT-TO-LEFT
   Most of the layout mirrors on its own because it is built with
   flex/grid and logical properties. These are the cases that do not.
   ============================================================ */
[dir="rtl"] .admin-sidebar { box-shadow: -2px 0 12px rgba(0,0,0,0.12); }
[dir="rtl"] .admin-table th,
[dir="rtl"] .admin-table td { text-align: right; }
[dir="rtl"] .admin-table .col-num { text-align: left; }

/* Chevrons point at a direction, so they have to be swapped, not mirrored */
[dir="rtl"] .nav-prev,
[dir="rtl"] .nav-next { transform: scaleX(-1); }

/* Numbers, timestamps and identifiers read left-to-right even in Arabic */
[dir="rtl"] .summary-value,
[dir="rtl"] .analytics-window,
[dir="rtl"] .pagination-pages,
[dir="rtl"] .log-time,
[dir="rtl"] .col-seen,
[dir="rtl"] .top-error-sig { direction: ltr; text-align: right; }
[dir="rtl"] .admin-table .col-num { direction: ltr; }

[dir="rtl"] .log-source,
[dir="rtl"] .log-meta-item { direction: ltr; }

/* Mobile sidebar slides in from the right */
@media (max-width: 768px) {
    /* The base mobile rule pins the drawer with left:0. Keeping that in RTL and
       only flipping the transform parks the closed drawer at x=+260px — on screen,
       covering the content. Anchor it to the right edge so translateX(100%)
       actually moves it out of view. */
    [dir="rtl"] .admin-sidebar {
        left: auto;
        right: 0;
        transform: translateX(100%);
    }
    [dir="rtl"] .admin-sidebar.open { transform: translateX(0); }
}

/* ============================================================
   MOBILE REFINEMENTS
   ============================================================ */
@media (max-width: 900px) {
    .analytics-panel-wide { grid-column: auto; }
}

@media (max-width: 768px) {
    .log-analytics-card { padding: 14px; }
    .analytics-grid { grid-template-columns: 1fr; gap: 12px; }
    .analytics-panel { padding: 12px 10px; }
    .log-analytics-summary { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
    .summary-value { font-size: 1.3rem; }
    .analytics-head { flex-direction: column; align-items: flex-start; gap: 4px; }

    /* Keep the top bar usable at 360px: the logout label is the first thing to go */
    .logout-label { display: none; }
    .logout-btn { padding: 6px 10px; }
    .admin-topbar { padding: 0 12px; gap: 8px; }
    .topbar-title { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 480px) {
    .log-analytics-summary { grid-template-columns: repeat(2, 1fr); }
    .admin-table .col-time { width: auto; }
    .filter-actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* ============================================================
   HINTS
   A "what is this?" marker that explains a term in plain language.
   Opens on hover, on keyboard focus and on tap — hover alone would
   leave the explanations unreachable on a phone.
   ============================================================ */
.hint { position: relative; display: inline-flex; align-items: center; vertical-align: middle; }
.hint-block { display: flex; }

.hint-trigger {
    background: none; border: none; padding: 0; margin-inline-start: 5px;
    cursor: help; color: var(--admin-text-muted);
    display: inline-flex; align-items: center;
    opacity: 0.65; transition: opacity 0.15s, color 0.15s;
    line-height: 1;
}
.hint-trigger .material-symbols-outlined { font-size: 15px; display: block; }
.hint-trigger:hover, .hint-trigger:focus-visible { opacity: 1; color: var(--admin-primary); }
.hint-trigger:focus-visible { outline: 2px solid var(--admin-primary); outline-offset: 2px; border-radius: 50%; }

.hint-bubble {
    position: absolute;
    bottom: calc(100% + 8px);
    inset-inline-start: 50%;
    transform: translateX(-50%);
    z-index: 60;
    width: max-content;
    max-width: min(300px, 80vw);
    background: var(--admin-sidebar-bg);
    color: rgba(255, 255, 255, 0.94);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.5;
    text-align: start;
    text-transform: none;
    letter-spacing: 0;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    pointer-events: none;
    white-space: normal;
}
/* RTL flips inset-inline-start, so the translate has to flip with it */
[dir="rtl"] .hint-bubble { transform: translateX(50%); }

.hint-bubble::after {
    content: "";
    position: absolute;
    top: 100%;
    inset-inline-start: 50%;
    margin-inline-start: -5px;
    border: 5px solid transparent;
    border-top-color: var(--admin-sidebar-bg);
}

.hint:hover .hint-bubble,
.hint-trigger:focus-visible + .hint-bubble,
.hint-bubble.hint-open { opacity: 1; visibility: visible; }

/* Near the top of a scroll container there is no room above — flip below */
.summary-item .hint-bubble,
thead .hint-bubble { bottom: auto; top: calc(100% + 8px); }
.summary-item .hint-bubble::after,
thead .hint-bubble::after {
    top: auto; bottom: 100%;
    border-top-color: transparent; border-bottom-color: var(--admin-sidebar-bg);
}

/* An explanatory line above a section, for pages that need more than a marker */
.page-intro {
    display: flex; align-items: flex-start; gap: 8px;
    background: color-mix(in srgb, var(--admin-primary) 8%, var(--admin-card-bg));
    border: 1px solid color-mix(in srgb, var(--admin-primary) 22%, transparent);
    border-radius: var(--admin-radius);
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 0.85rem;
    color: var(--admin-text);
    line-height: 1.55;
}
.page-intro .material-symbols-outlined { font-size: 18px; color: var(--admin-primary); flex: none; margin-top: 1px; }

@media (max-width: 480px) {
    .hint-bubble { max-width: 70vw; }
}

/* The internal class name, kept under the friendly job name so a technical
   reader can still match a row to the code. Always LTR — it is an identifier. */
.job-technical-name {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.7rem;
    color: var(--admin-text-muted);
    opacity: 0.75;
    margin-top: 2px;
    direction: ltr;
    text-align: start;
}
[dir="rtl"] .job-technical-name { text-align: right; }
