/* EdgeCentral portal design system — ported from the ServiceDesk reference mockup:
   RTL Hebrew layout, Heebo font, calm/soft color system. Keep new UI within these tokens. */

:root {
  --accent: #1E6FD9;
  --accent-bg-soft: rgba(30, 111, 217, 0.10);
  --bg-page: #F4F7FB;
  --bg-card: #FFFFFF;
  --bg-sidebar: #FFFFFF;
  --border-color: #E6ECF4;
  --border-color-strong: #D9E2EE;
  --radius-card: 14px;
  --radius-btn: 9px;
  --shadow-card: 0 1px 0 rgba(15, 31, 60, 0.02);
  --pad-card: 22px;

  --ink: #0E1A2B;
  --ink-muted: #5A6B82;
  --ink-faint: #8A9BB1;
  --ink-hairline: #C4CEDE;

  --success: #16A36C;
  --warning: #E8651A;
  --danger: #DC3741;
}

:root[data-theme="dark"] {
  --accent: #4C8DFF;
  --accent-bg-soft: rgba(76, 141, 255, 0.16);
  --bg-page: #0F1620;
  --bg-card: #16202C;
  --bg-sidebar: #131B26;
  --border-color: #223044;
  --border-color-strong: #2B3B52;

  --ink: #E7EDF5;
  --ink-muted: #9BAAC0;
  --ink-faint: #6C7C93;
  --ink-hairline: #33445C;

  --success: #34C98A;
  --warning: #F0924A;
  --danger: #F0616A;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: "Heebo", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg-page);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  direction: rtl;
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
::selection { background: rgba(30, 111, 217, 0.18); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color-strong); border-radius: 99px; border: 2px solid var(--bg-page); }
::-webkit-scrollbar-thumb:hover { background: #B8C5D8; }

/* ---- App shell ---- */
.ec-app { min-height: 100vh; display: flex; background: var(--bg-page); }

.ec-sidebar {
  width: 244px; background: var(--bg-sidebar); border-inline-start: 1px solid var(--border-color);
  display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
}
.ec-sidebar-logo {
  height: 64px; display: flex; align-items: center; gap: 10px; padding: 0 22px; border-bottom: 1px solid #F0F4FA;
}
.ec-sidebar-logo .mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.ec-sidebar-logo .title { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; }
.ec-sidebar-logo .subtitle { font-size: 10.5px; color: var(--ink-faint); font-weight: 500; letter-spacing: 0.04em; margin-top: -1px; }

.ec-nav { padding: 12px; flex: 1; overflow-y: auto; }
.ec-nav-heading { font-size: 10.5px; color: var(--ink-faint); font-weight: 600; padding: 8px 10px 6px; letter-spacing: 0.06em; }
.ec-nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 9px;
  color: #1F2D44; font-size: 13.5px; font-weight: 500; margin-bottom: 2px; letter-spacing: -0.01em;
  transition: background .15s;
}
.ec-nav-item:hover { background: #F5F8FC; }
.ec-nav-item.active { background: var(--accent-bg-soft); color: var(--accent); font-weight: 600; }
.ec-nav-item .icon { width: 20px; text-align: center; color: var(--ink-muted); flex-shrink: 0; }
.ec-nav-item.active .icon { color: var(--accent); }
.ec-nav-item .badge {
  background: var(--accent); color: #fff; border-radius: 99px; padding: 1px 7px; font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums; margin-inline-start: auto;
}

.ec-avatar {
  width: 36px; height: 36px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 14px;
  font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ec-user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ec-user-role { font-size: 11px; color: var(--ink-muted); }

dialog::backdrop { background: rgba(10,16,26,0.45); }

/* Top-bar popups (bell, account): a <details>, so they open without JS; layout.js closes them on an outside click. */
.ec-popover { position: relative; }
.ec-popover > summary { list-style: none; cursor: pointer; position: relative; }
.ec-popover > summary::-webkit-details-marker { display: none; }
.ec-popover[open] > summary { box-shadow: 0 0 0 3px var(--accent-bg-soft); }
.ec-popover-panel {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 50; width: 240px; padding: 6px;
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15,31,60,0.14);
}
.ec-account-menu > summary { width: 34px; height: 34px; font-size: 13.5px; }

.ec-notif-panel { width: 360px; padding: 0; overflow: hidden; }
.ec-notif-head { padding: 12px 16px; font-weight: 700; border-bottom: 1px solid var(--border-color); }
.ec-notif-list { max-height: min(420px, 60vh); overflow-y: auto; }
.ec-notif-item { display: flex; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border-color); color: var(--ink); }
a.ec-notif-item:hover { background: var(--accent-bg-soft); }
.ec-notif-item .dot { width: 8px; height: 8px; border-radius: 99px; margin-top: 7px; flex-shrink: 0; background: transparent; }
.ec-notif-item.unread .dot { background: var(--accent); }
.ec-notif-item.unread .title { font-weight: 700; }
.ec-notif-item .title { font-size: 13.5px; }
.ec-notif-item .body { font-size: 12.5px; color: var(--ink-muted); overflow-wrap: anywhere; }
.ec-notif-item .time { font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
.ec-notif-empty { padding: 28px 16px; text-align: center; color: var(--ink-muted); font-size: 13px; }
.ec-notif-all { display: block; padding: 10px 16px; text-align: center; font-weight: 600; color: var(--accent); font-size: 13px; }
.ec-notif-all:hover { background: var(--accent-bg-soft); }
.ec-account-head { padding: 8px 12px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border-color); }
.ec-account-panel .ec-nav-item { color: var(--ink); padding: 8px 12px; }
.ec-account-panel .ec-nav-item:hover { background: var(--accent-bg-soft); }
.ec-account-logout { margin: 4px 0 0; padding-top: 4px; border-top: 1px solid var(--border-color); }
.ec-account-panel button.ec-nav-item { border: 0; background: none; cursor: pointer; font-family: inherit; text-align: start; }

.ec-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ec-topbar {
  height: 64px; background: var(--bg-card); border-bottom: 1px solid var(--border-color); display: flex;
  align-items: center; justify-content: space-between; padding: 0 26px; gap: 16px; position: sticky; top: 0; z-index: 10;
}
.ec-breadcrumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.ec-breadcrumbs .sep { color: var(--ink-hairline); font-size: 11px; }
.ec-breadcrumbs .current { color: var(--ink); font-weight: 600; }
.ec-breadcrumbs .prior { color: var(--ink-muted); font-weight: 500; }

.ec-page { padding: 26px; max-width: 1480px; width: 100%; margin: 0 auto; flex: 1; }

/* ---- Cards ---- */
.ec-card {
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.ec-card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px 0; }
.ec-card-header h3 { margin: 0; font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; }
.ec-card-body { padding: var(--pad-card); }

.ec-stat {
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-card);
  padding: 20px 22px;
}
.ec-stat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.ec-stat-icon {
  width: 32px; height: 32px; border-radius: 9px; background: var(--accent-bg-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700;
}
.ec-stat-label { font-size: 13px; color: var(--ink-muted); font-weight: 500; }
.ec-stat-value { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.ec-stat-delta { margin-top: 10px; font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.ec-stat-delta.up { color: var(--success); }
.ec-stat-delta.down { color: var(--danger); }

.ec-grid { display: grid; gap: 16px; }
.ec-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.ec-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.ec-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
/* A grid column may not grow past the screen because of what's inside it: wide tables scroll in their own wrap. */
.ec-grid > * { min-width: 0; }
@media (max-width: 1100px) { .ec-grid.cols-3, .ec-grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .ec-grid.cols-2, .ec-grid.cols-3, .ec-grid.cols-4 { grid-template-columns: 1fr; } }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: var(--radius-btn);
  font-size: 13.5px; font-weight: 600; border: 1px solid transparent; cursor: pointer; letter-spacing: -0.01em;
  white-space: nowrap; transition: all .15s;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { filter: brightness(0.94); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--border-color-strong); }
.btn-ghost:hover { background: #F5F8FC; }
.btn-subtle { background: #F3F6FB; color: var(--ink); }
.btn-danger { background: #fff; color: var(--danger); border-color: #F2C8CC; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn.disabled { opacity: 0.4; pointer-events: none; }

/* ---- Forms ---- */
.field { display: block; margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; letter-spacing: -0.01em; }
.field .hint { font-size: 12px; color: var(--ink-faint); margin-top: 6px; }
.field .required { color: var(--danger); margin-inline-start: 4px; }
.input, select.input, textarea.input {
  width: 100%; height: 40px; border-radius: var(--radius-btn); border: 1px solid var(--border-color-strong);
  background: #fff; padding: 0 12px; font-size: 13.5px; color: var(--ink); outline: none; font-family: inherit;
}
textarea.input { height: auto; padding: 11px 12px; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30,111,217,0.12); }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row > .field { flex: 1; min-width: 220px; }

/* ---- Badges / Pills ---- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.pill-online, .pill-online2, .pill-success { background: rgba(22,163,108,0.12); color: var(--success); }
.pill-warning { background: rgba(232,101,26,0.12); color: var(--warning); }
.pill-offline, .pill-disabled { background: rgba(90,107,130,0.12); color: var(--ink-muted); }
.pill-danger, .pill-autherror, .pill-streamerror { background: rgba(220,55,65,0.12); color: var(--danger); }
.pill-neutral { background: #F3F6FB; color: var(--ink-muted); }
.pill-accent { background: var(--accent-bg-soft); color: var(--accent); }

/* ---- Table ---- */
.ec-table-wrap { overflow-x: auto; }
table.ec-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.ec-table th {
  text-align: start; color: var(--ink-muted); font-weight: 600; font-size: 12px; letter-spacing: 0.02em;
  padding: 10px 14px; border-bottom: 1px solid var(--border-color);
}
table.ec-table td { padding: 12px 14px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
table.ec-table tr:last-child td { border-bottom: none; }
table.ec-table tr:hover td { background: #FAFBFD; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-color); margin-bottom: 18px; }
.tabs a {
  padding: 11px 14px; font-size: 13.5px; font-weight: 600; color: var(--ink-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; letter-spacing: -0.01em; display: inline-block;
}
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- Misc ---- */
.ec-empty { padding: 60px 20px; text-align: center; color: var(--ink-muted); }
.ec-empty .icon { font-size: 40px; color: var(--ink-hairline); margin-bottom: 12px; }
.ec-empty .title { font-size: 15px; color: var(--ink); font-weight: 600; margin-bottom: 6px; }

.ec-toast {
  position: fixed; bottom: 24px; inset-inline-start: 24px; z-index: 1000; background: #0E1A2B; color: #fff;
  padding: 12px 18px; border-radius: 10px; font-size: 13.5px; font-weight: 500;
  box-shadow: 0 10px 30px rgba(15,31,60,0.25); display: flex; align-items: center; gap: 10px;
}

.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }
.mono { font-variant-numeric: tabular-nums; }
.text-danger { color: var(--danger); }
.mt-0 { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.inline { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; }

.validation-summary-errors, .field-validation-error {
  color: var(--danger); font-size: 12.5px;
}
.validation-summary-errors ul { margin: 6px 0 0; padding-inline-start: 18px; }

.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-page);
  padding: 16px;
}
.login-card { width: 380px; max-width: 100%; padding: 32px; }

/* ---- Mobile menu toggle + sidebar drawer (hidden on desktop) ---- */
.ec-menu-toggle {
  display: none; align-items: center; justify-content: center; width: 36px; height: 36px;
  border-radius: 9px; border: 1px solid var(--border-color-strong); background: #fff; color: var(--ink);
  font-size: 16px; cursor: pointer; flex-shrink: 0;
}
.ec-sidebar-backdrop { display: none; }
.ec-nav-mobile-only, .ec-tabbar, .ec-phone-only, .ec-phone-block { display: none; }
.ec-event-cards, .ec-review-bar, .ec-review-bar-space, .ec-filters-toggle { display: none; }
.ec-filters > summary::-webkit-details-marker { display: none; }
.ec-push-reminder[hidden] { display: none; }

/* ---- Responsive breakpoints ---- */
@media (max-width: 900px) {
  .ec-sidebar {
    /* Physical `right`, not a logical inset-inline-* property or transform: this app is RTL-only
       (no LTR mode ever), and the sidebar already sits on the physical right edge in the desktop
       layout — plain `right` avoids both the inline-start/end RTL mixup and any compositor-layer
       transform quirks, sliding the drawer in/out by animating its own edge position directly. */
    position: fixed; right: -280px; top: 0; height: 100dvh; z-index: 110; width: 264px;
    transition: right .22s ease; box-shadow: -10px 0 28px rgba(15,31,60,0.18);
  }
  .ec-sidebar.open { right: 0; }
  .ec-menu-toggle { display: inline-flex; }
  .ec-sidebar-backdrop.open {
    display: block; position: fixed; inset: 0; background: rgba(10,16,26,0.45); z-index: 100;
  }
  /* Installed as an app on a notched phone (viewport-fit=cover), the page runs under the status
     bar and home indicator -- the safe-area insets keep the top bar and tab bar clear of them. */
  .ec-topbar {
    padding: env(safe-area-inset-top) 14px 0; gap: 10px;
    height: calc(56px + env(safe-area-inset-top));
  }
  .ec-breadcrumbs { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .ec-topbar .inline { gap: 6px; }
  .ec-desktop-only { display: none !important; }
  .ec-phone-only { display: inline-flex; }
  .ec-phone-block { display: block; }

  /* iOS zooms into any field under 16px when it gets focus, and stays zoomed. */
  .input, select.input, textarea.input { font-size: 16px; height: 44px; }
  textarea.input { height: auto; }
  input.mono.input { font-size: 18px; }

  .ec-filters-toggle { display: inline-flex; list-style: none; margin-bottom: 12px; cursor: pointer; }
  .ec-event-table { display: none; }
  .ec-event-cards { display: flex; flex-direction: column; gap: 12px; }
  .ec-event-card {
    display: block; overflow: hidden; color: inherit; text-decoration: none;
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-card);
  }
  .ec-event-card img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #0B1220; }
  .ec-event-card-body { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; }

  .ec-review-bar {
    display: flex; gap: 8px; position: fixed; left: 0; right: 0; z-index: 85;
    bottom: calc(56px + env(safe-area-inset-bottom)); padding: 8px 12px;
    background: var(--bg-card); border-top: 1px solid var(--border-color); box-shadow: 0 -6px 16px rgba(15,31,60,0.08);
  }
  .ec-review-bar .btn { flex: 1; min-height: 44px; justify-content: center; padding: 8px 4px; }
  .ec-review-bar-space { display: block; height: 64px; }

  .ec-push-reminder {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; position: fixed; left: 12px; right: 12px; z-index: 84;
    bottom: calc(68px + env(safe-area-inset-bottom)); padding: 12px 14px; border-radius: var(--radius-card);
    background: var(--accent); color: #fff; box-shadow: 0 6px 20px rgba(15,31,60,0.25);
  }
  .ec-push-reminder a { color: #fff; font-weight: 600; text-decoration: none; flex: 1; }
  .ec-push-reminder button { background: none; border: 0; color: #fff; font-size: 16px; padding: 4px 8px; cursor: pointer; }
  .ec-nav-mobile-only { display: block; }
  .ec-page { padding: 14px 14px calc(78px + env(safe-area-inset-bottom)); }
  .ec-card-body { padding: 16px; }
  .ec-card-header { padding: 14px 16px 0; }

  .ec-tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    background: var(--bg-card); border-top: 1px solid var(--border-color);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .ec-tabbar a, .ec-tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0 7px;
    font-size: 11px; font-weight: 500; color: var(--ink-muted); background: none; border: 0; font-family: inherit; cursor: pointer;
  }
  .ec-tabbar .icon { font-size: 18px; line-height: 1; }
  .ec-tabbar a.active { color: var(--accent); font-weight: 600; }

  /* On a phone the bell sits too close to the screen edge for a dropdown -- pin the panel to the
     screen instead, just under the top bar. */
  .ec-notif-panel {
    position: fixed; top: calc(60px + env(safe-area-inset-top)); left: 10px; right: 10px; width: auto;
  }
  .ec-notif-list { max-height: calc(100dvh - 220px); }
}

@media (max-width: 640px) {
  .form-row { gap: 12px; }
  .form-row > .field { flex-basis: 100%; min-width: 0; }
  .ec-stat { padding: 16px; }
  .ec-stat-value { font-size: 26px; }
  table.ec-table th, table.ec-table td { padding: 8px 10px; font-size: 12.5px; }
  .spread { flex-wrap: wrap; gap: 10px; }
  .spread > .inline { flex-wrap: wrap; }
  .btn { padding: 8px 12px; }
  .ec-topbar .pill { display: none; }
}

/* Long JSON has no spaces to wrap at; without this it widens the whole page on a phone. */
.ec-card pre { overflow-wrap: anywhere; }

/* Not inline: display in a style attribute beats the hidden attribute, and the unused player showed as a broken picture. */
.live-media { display: block; }
.live-media[hidden] { display: none; }
