/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .split { grid-template-columns:1fr; }
  .form-row { grid-template-columns:1fr; }
  .main { padding:20px; }
  .order-modal-card { width:min(95vw,760px); }
}

@media (max-width: 640px) {
  .stats-grid { grid-template-columns:1fr 1fr; }
  .sidebar { display:none; }
  .main { margin-left:0; }
  html[dir="rtl"] .main { margin-right:0; }
  .setup-assistant-fab {
    right: 10px;
    bottom: 10px;
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }
  .setup-assistant-popup {
    right: 10px;
    left: 10px;
    width: auto;
    bottom: 60px;
  }
  html[dir="rtl"] .setup-assistant-fab {
    left: 10px;
    right: auto;
  }
  html[dir="rtl"] .setup-assistant-popup {
    left: 10px;
    right: 10px;
  }
}

/* OVIXE-INSPIRED IVR DASHBOARD THEME */
:root {
  color-scheme: dark;
  --blue-darker: #070a13;
  --blue-dark: #0b1120;
  --blue-panel: #0c1222;
  --blue-base: #0f172a;
  --blue-muted: #1f2a44;
  --blue-line: #404249;
  --blue-border: #656565;
  --blue-light: #e7e8ea;

  --violet-dark: #0f2a56;
  --violet-base: #2563eb;
  --violet-soft: #dbeafe;
  --accent-base: #0ea5e9;

  --surface-gradient: linear-gradient(
    133.84deg,
    #67718a -16.04%,
    #38435e 9.33%,
    #0f172a 32.02%,
    #0f172a 62.06%,
    #38435e 87.42%,
    #67718a 112.12%
  );
  --shadow-card: 2.7px 8px 20px 2.7px rgba(12, 10, 11, 0.8);

  --sidebar: 245px;
  --sidebar-sm: 86px;

  --bg: var(--blue-base);
  --surface: var(--blue-panel);
  --surface2: #111b32;
  --surface3: #17233e;
  --border: rgba(231, 232, 234, 0.2);
  --border2: rgba(231, 232, 234, 0.32);
  --blue: var(--violet-base);
  --blue-dim: rgba(37, 99, 235, 0.2);
  --blue-glow: rgba(37, 99, 235, 0.4);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.14);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.14);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.15);
  --purple: #60a5fa;
  --purple-dim: rgba(96, 165, 250, 0.2);
  --text: var(--blue-light);
  --text2: #a2aec8;
  --text3: #c6d1ea;
  /* Aliases used by client detail modal */
  --bg1:    var(--blue-darker);
  --bg2:    var(--blue-panel);
  --bg3:    var(--blue-muted);
  --accent: var(--accent-base);
  --hover:  rgba(14,165,233,0.1);
  --text1:  var(--blue-light);
}

html,
body {
  font-family: 'Inter', sans-serif;
  background: var(--blue-base);
  color: var(--text);
}

body {
  padding-left: var(--sidebar);
  transition: padding-left .22s ease;
}

body.collapsed {
  padding-left: var(--sidebar-sm);
}

body::before {
  background:
    radial-gradient(ellipse 74% 56% at 0% 0%, rgba(37, 99, 235, 0.18) 0%, transparent 62%),
    radial-gradient(ellipse 62% 46% at 100% 100%, rgba(14, 165, 233, 0.12) 0%, transparent 64%);
}

html[dir='rtl'] body {
  padding-left: 0;
  padding-right: var(--sidebar);
}

html[dir='rtl'] body.collapsed {
  padding-right: var(--sidebar-sm);
}

.dashboard-topbar {
  position: fixed;
  inset: 0 0 auto var(--sidebar);
  height: 112px;
  padding: 26px 34px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  background: linear-gradient(180deg, rgba(12, 18, 34, 0.95) 0%, rgba(12, 18, 34, 0.78) 72%, rgba(12, 18, 34, 0) 100%);
  backdrop-filter: blur(6px);
  z-index: 420;
  transition: inset .22s ease;
}

body.collapsed .dashboard-topbar {
  inset-inline-start: var(--sidebar-sm);
}

html[dir='rtl'] .dashboard-topbar {
  left: 0 !important;
  right: var(--sidebar) !important;
  /* Use physical properties - logical inset-inline maps incorrectly for our fixed layout */
}

html[dir='rtl'] body.collapsed .dashboard-topbar {
  right: var(--sidebar-sm) !important;
}

.topbar-left {
  display: flex;
  align-items: center;
  min-width: 0;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(140deg, #0ea5e9 0%, #2563eb 72%);
  display: grid;
  place-items: center;
  font-size: 19px;
  box-shadow: 0 12px 22px rgba(37, 99, 235, 0.36);
}

.topbar-brand-copy p {
  margin: 0;
  font-family: 'Urbanist', sans-serif;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.05;
}

.topbar-brand-copy span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text2);
  letter-spacing: .35px;
}

.topbar-search {
  margin-inline: auto;
  width: min(540px, 100%);
  height: 61px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--blue-dark);
  color: #d3daec;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
}

.topbar-search svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: #d7dff2;
}

.topbar-search input {
  width: 100%;
  border: 0;
  background: transparent;
  color: #dfe6f7;
  font-family: 'Urbanist', sans-serif;
  font-size: 18px;
  line-height: 1;
  outline: none;
}

.topbar-search input::placeholder {
  color: #8fa1c3;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-icon-btn {
  width: 61px;
  height: 61px;
  border-radius: 50%;
  border: 1px solid rgba(231, 232, 234, 0.16);
  background: var(--blue-dark);
  color: #edf2ff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.topbar-icon-btn svg {
  width: 20px;
  height: 20px;
}

.topbar-icon-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(231, 232, 234, 0.34);
  background: #101a31;
}

.topbar-icon-btn.has-dot {
  position: relative;
}

.topbar-alert-dot {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #0f172a;
}

html[dir='rtl'] .topbar-alert-dot {
  right: auto;
  left: 16px;
}

/* ── Topbar RTL layout fixes ── */
/* flex-direction: row-reverse on .dashboard-topbar handles left/right flip */
html[dir='rtl'] .topbar-search {
  margin-inline: auto;
}
html[dir='rtl'] .topbar-right {
  flex-direction: row-reverse;
}
html[dir='rtl'] .topbar-brand {
  flex-direction: row-reverse;
}

.alerts-panel {
  position: fixed;
  top: 102px;
  right: 40px;
  width: min(420px, calc(100vw - 32px));
  max-height: min(68vh, 620px);
  border-radius: 16px;
  border: 1px solid rgba(231, 232, 234, 0.2);
  background: rgba(12, 18, 34, 0.96);
  box-shadow: 0 24px 44px rgba(3, 7, 18, 0.48);
  z-index: 470;
  display: none;
  overflow: hidden;
}

html[dir='rtl'] .alerts-panel {
  right: auto;
  left: 40px;
}

.alerts-panel.open {
  display: block;
}

.alerts-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(231, 232, 234, 0.12);
}

.alerts-panel-title {
  font-family: 'Urbanist', sans-serif;
  font-size: 15px;
  color: #f4f7ff;
  line-height: 1.2;
}

.alerts-panel-sub {
  margin-top: 4px;
  font-size: 12px;
  color: #9fb0d0;
}

.alerts-panel-close {
  border: 0;
  background: transparent;
  color: #9fb0d0;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}

.alerts-panel-close:hover {
  color: #f4f7ff;
}

.alerts-panel-list {
  max-height: calc(68vh - 72px);
  overflow: auto;
}

.alerts-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(231, 232, 234, 0.08);
}

.alerts-item:last-child {
  border-bottom: 0;
}

.alerts-item-btn {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

html[dir='rtl'] .alerts-item-btn {
  text-align: right;
}

.alerts-item-dot {
  margin-top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.alerts-item-dot.info {
  background: #38bdf8;
}

.alerts-item-dot.warn {
  background: #f59e0b;
}

.alerts-item-dot.danger {
  background: #ef4444;
}

.alerts-item-copy {
  min-width: 0;
}

.alerts-item-title {
  font-size: 13px;
  color: #f7fbff;
  line-height: 1.3;
  word-break: break-word;
}

.alerts-item-meta {
  margin-top: 4px;
  font-size: 12px;
  color: #93a6c8;
}

.alerts-item.unread .alerts-item-title {
  font-weight: 600;
}

.alerts-item:not(.unread) .alerts-item-dot {
  display: none;
}

.alerts-empty {
  padding: 18px 16px;
  color: #9fb0d0;
  font-size: 13px;
}

#logTable tr.log-row-flash > td {
  background: rgba(56, 189, 248, 0.16);
}

html[dir='rtl'] .alerts-panel {
  right: auto;
  left: 40px;
}

@media (max-width: 980px) {
  .alerts-panel {
    top: 92px;
    right: 16px;
    left: 16px;
    width: auto;
  }
  html[dir='rtl'] .alerts-panel {
    right: 16px;
    left: 16px;
  }
}

.topbar-profile {
  min-height: 44px;
  border: 1px solid rgba(231, 232, 234, 0.16);
  border-radius: 50%;
  background: transparent;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0;
  cursor: pointer;
  transition: border-color .16s ease, transform .16s ease;
}

.topbar-profile:hover {
  border-color: rgba(231, 232, 234, 0.32);
  transform: translateY(-1px);
}

.topbar-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  background: radial-gradient(circle at 20% 20%, #0ea5e9, #2563eb 65%, #0f2a56);
  overflow: hidden;
}

.topbar-profile p {
  margin: 0;
  font-family: 'Urbanist', sans-serif;
  font-size: 15px;
  line-height: 1.1;
  color: #f5f8ff;
}

.topbar-profile span {
  display: block;
  margin-top: 2px;
  color: #9eabc8;
  font-size: 12px;
}

.main {
  max-width: none;
  margin: 0;
  padding: 146px 38px 38px;
}

body.collapsed .main {
  margin-left: 0;
}

html[dir='rtl'] .main {
  margin-right: 0;
}

html[dir='rtl'] body.collapsed .main {
  margin-right: 0;
}

