/* EgyptAuth — application shell, page scaffolding, login, 404 and page-specific layout. */

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40; width: var(--sidebar-w);
  display: flex; flex-direction: column; background: var(--bg); border-inline-end: 1px solid var(--border);
  transition: width var(--t) var(--ease), transform var(--t-slow) var(--ease);
}
.main { flex: 1; min-width: 0; margin-inline-start: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; transition: margin var(--t) var(--ease); }
.shell.is-rail .sidebar { width: var(--rail-w); }
.shell.is-rail .main { margin-inline-start: var(--rail-w); }

.sb-brand { display: flex; align-items: center; gap: 10px; height: var(--header-h); padding-inline: 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sb-brand img { width: 28px; height: 28px; flex-shrink: 0; object-fit: contain; }
.sb-brand .name { font-weight: 600; font-size: var(--fs-md); letter-spacing: -0.01em; color: var(--text); white-space: nowrap; }
.brand-word { display: inline-flex; unicode-bidi: isolate; }
.brand-egypt { color: var(--brand-egypt); }
.brand-auth { color: var(--brand-auth); }
.sb-switch { padding: 10px 10px 4px; }
.app-switch { display: flex; align-items: center; gap: 8px; width: 100%; height: 36px; padding-inline: 8px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); transition: border-color var(--t-fast), background var(--t-fast); min-width: 0; }
.app-switch:hover { border-color: var(--border-strong); background: var(--raised); }
.app-switch .meta { flex: 1; min-width: 0; text-align: start; line-height: 1.2; }
.app-switch .meta .lbl { font-size: var(--fs-xs); color: var(--text-3); }
.app-switch .meta .val { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-switch > .icon { color: var(--text-3); }
.sb-nav { flex: 1; overflow-y: auto; padding: 10px 10px 14px; }
.nav-group + .nav-group { margin-top: 10px; }
.nav-label {
  display: flex; align-items: center; gap: 6px; width: 100%; height: 26px; padding: 0 8px; border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: 500; color: var(--text-3); white-space: nowrap; overflow: hidden; text-align: start;
  transition: color var(--t-fast);
}
.nav-label:hover { color: var(--text-2); }
.nav-label .caret { margin-inline-start: auto; opacity: 0.7; transition: transform var(--t) var(--ease); }
.nav-group.is-collapsed .nav-label .caret { transform: rotate(-90deg); }
[dir="rtl"] .nav-group.is-collapsed .nav-label .caret { transform: rotate(90deg); }
.nav-group.is-collapsed .nav-item:not(.is-active) { display: none; }
.nav-items { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 11px; height: 34px; padding-inline: 9px; border-radius: var(--r);
  color: var(--text-2); font-weight: 500; white-space: nowrap; transition: background var(--t-fast), color var(--t-fast);
}
.nav-item .icon { width: 18px; height: 18px; color: var(--text-3); transition: color var(--t-fast); }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item:hover .icon { color: var(--text-2); }
.nav-item.is-active { background: var(--nav-active); color: var(--text); }
.nav-item.is-active .icon { color: var(--gold-text); --icon-tone: var(--gold); --icon-tone-opacity: 0.38; }
.nav-item.is-active::before { content: ""; position: absolute; inset-inline-start: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gold); }
[dir="rtl"] .nav-item.is-active::before { border-radius: 3px 0 0 3px; }
.nav-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-item .count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 18px; padding-inline: 6px;
  border-radius: 999px; background: var(--raised); border: 1px solid var(--border); color: var(--text-2);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1;
}
.nav-item.is-active .count { background: var(--gold-soft); border-color: var(--gold-line); color: var(--gold-text); }
.sb-foot { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); color: var(--text-3); font-size: var(--fs-sm); flex-shrink: 0; }
.sb-foot .ver { font-family: var(--font-mono); font-size: 11px; white-space: nowrap; }
.sb-foot .btn-icon { margin-inline-start: auto; }

.shell.is-rail .sb-brand { padding-inline: 0; justify-content: center; }
.shell.is-rail .sb-brand .name,
.shell.is-rail .nav-label,
.shell.is-rail .nav-item .label,
.shell.is-rail .nav-item .count,
.shell.is-rail .app-switch .meta,
.shell.is-rail .app-switch > .icon,
.shell.is-rail .sb-foot .ver,
.shell.is-rail .sb-foot .ws-label { display: none; }
.shell.is-rail .sb-switch { padding-inline: 10px; }
.shell.is-rail .app-switch { justify-content: center; padding: 0; }
.shell.is-rail .nav-item { justify-content: center; padding: 0; }
.shell.is-rail .nav-group + .nav-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
@media (min-width: 961px) { .shell.is-rail .nav-group.is-collapsed .nav-item:not(.is-active) { display: flex; } }
.shell.is-rail .sb-foot { flex-direction: column; padding-inline: 0; }
.shell.is-rail .sb-foot .btn-icon { margin-inline-start: 0; }
.shell.is-rail .sb-foot .btn-icon .icon { transform: scaleX(-1); }
[dir="rtl"] .shell.is-rail .sb-foot .btn-icon .icon { transform: none; }
[dir="rtl"] .shell:not(.is-rail) .sb-foot .btn-icon .icon { transform: scaleX(-1); }

.sb-backdrop { position: fixed; inset: 0; z-index: 35; background: var(--overlay); opacity: 0; pointer-events: none; transition: opacity var(--t) var(--ease); }

@media (max-width: 960px) {
  .sidebar, .shell.is-rail .sidebar { width: min(280px, 86vw); transform: translateX(-100%); }
  [dir="rtl"] .sidebar, [dir="rtl"] .shell.is-rail .sidebar { transform: translateX(100%); }
  .main, .shell.is-rail .main { margin-inline-start: 0; }
  .shell.is-mobile-open .sidebar { transform: none; }
  .shell.is-mobile-open .sb-backdrop { opacity: 1; pointer-events: auto; }
  .shell.is-rail .sb-brand { padding-inline: 16px; justify-content: flex-start; }
  .shell.is-rail .sb-brand .name, .shell.is-rail .nav-label, .shell.is-rail .nav-item .label, .shell.is-rail .nav-item .count,
  .shell.is-rail .app-switch .meta, .shell.is-rail .app-switch > .icon, .shell.is-rail .sb-foot .ver, .shell.is-rail .sb-foot .ws-label { display: revert; }
  .shell.is-rail .nav-item { justify-content: flex-start; padding-inline: 8px; }
  .shell.is-rail .app-switch { justify-content: flex-start; padding-inline: 8px; }
  .sb-collapse { display: none; }
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--header-h); display: flex; align-items: center; gap: 8px;
  padding-inline: 16px; background: var(--topbar-bg); border-bottom: 1px solid var(--border);
}
.topbar .menu-btn { display: none; }
@media (max-width: 960px) { .topbar .menu-btn { display: inline-grid; } .topbar { padding-inline: 10px; } }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; font-size: var(--fs-base); }
.crumbs a, .crumbs span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a { color: var(--text-3); transition: color var(--t-fast); }
.crumbs a:hover { color: var(--text); }
.crumbs .sep { color: var(--text-4); flex-shrink: 0; }
.crumbs .current { color: var(--text); font-weight: 500; }
@media (max-width: 640px) { .crumbs > :not(:last-child) { display: none; } }
.search-trigger { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding-inline: 10px 6px; width: 220px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); color: var(--text-3); font-size: var(--fs-base); transition: border-color var(--t-fast), color var(--t-fast); }
.search-trigger:hover { border-color: var(--border-strong); color: var(--text-2); }
.search-trigger .lbl { flex: 1; text-align: start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-trigger .keys { display: inline-flex; gap: 2px; }
@media (max-width: 800px) { .search-trigger { width: auto; padding-inline: 8px; } .search-trigger .lbl, .search-trigger .keys { display: none; } }
.status-pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding-inline: 8px; border-radius: var(--r); color: var(--text-3); font-size: var(--fs-sm); }
.status-pill.is-bad { color: var(--amber-text); }
@media (max-width: 640px) { .status-pill .ws-label { display: none; } }
.bell { position: relative; }
.bell .badge-count { position: absolute; top: 3px; inset-inline-end: 3px; min-width: 14px; height: 14px; padding-inline: 3px; border-radius: 7px; background: var(--red); color: var(--on-solid); font-size: 9px; font-weight: 600; display: grid; place-items: center; line-height: 1; font-variant-numeric: tabular-nums; }
.account-btn { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding-inline: 4px 8px; border-radius: var(--r); transition: background var(--t-fast); }
.account-btn:hover { background: var(--hover); }
.account-btn .name { color: var(--text); font-weight: 500; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .account-btn .name { display: none; } }
.notif-menu { width: 340px; }
.notif-item { display: flex; gap: 10px; padding: 8px; border-radius: var(--r-sm); }
.notif-item + .notif-item { border-top: 1px solid var(--border); border-radius: 0; }
.notif-item .t { color: var(--text); font-size: var(--fs-base); }
.notif-item .s { color: var(--text-3); font-size: var(--fs-sm); overflow-wrap: anywhere; }

/* ---------- Page scaffolding ---------- */
.content { flex: 1; width: 100%; max-width: var(--content-max); margin-inline: auto; padding: 24px 24px 48px; min-width: 0; }
@media (max-width: 640px) { .content { padding: 16px 12px 40px; } }
.page { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-header .titles { min-width: 0; }
.page-title { font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.018em; color: var(--text); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-sub { color: var(--text-3); margin-top: 2px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-back { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); font-size: var(--fs-sm); margin-bottom: 6px; transition: color var(--t-fast); }
.page-back:hover { color: var(--text); }
.page-loading { display: grid; place-items: center; padding: 80px 0; color: var(--text-3); }

.settings-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; }
.settings-layout .subnav { position: sticky; top: calc(var(--header-h) + 24px); }
@media (max-width: 900px) { .settings-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; } .settings-layout .subnav { position: static; } }
.settings-section { scroll-margin-top: calc(var(--header-h) + 16px); }

.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } }
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 180px; }

/* ---------- Auth screens ---------- */
.auth { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; background: var(--bg); }
.auth-top { display: flex; align-items: center; justify-content: flex-end; gap: 4px; padding: 16px 20px; }
.acc-appearance { padding-top: var(--s3); border-top: 1px solid var(--border); }
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 8px 16px 64px; }
.auth-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
.auth-emblem { width: 72px; height: 72px; object-fit: contain; margin-bottom: 6px; }
.auth-wordmark { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.auth-tagline { font-size: var(--fs-md); color: var(--text-3); }
@media (max-height: 720px) { .auth-emblem { width: 64px; height: 64px; } .auth-main { gap: 20px; } }
.auth-card { width: 100%; max-width: 360px; }
.auth-card h1 { font-size: var(--fs-xl); margin-bottom: 4px; }
.auth-card .lead { color: var(--text-3); margin-bottom: 24px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-foot { padding: 16px 20px; color: var(--text-4); font-size: var(--fs-sm); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.otp-input { text-align: center; letter-spacing: 0.5em; font-family: var(--font-mono); font-size: 18px; height: 42px; padding-inline-start: 0.5em; direction: ltr; }

/* ---------- Boot / 404 ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; color: var(--text-3); }
.boot-inner img { width: 56px; height: 56px; object-fit: contain; animation: boot-pulse 1.6s ease-in-out infinite; }
@keyframes boot-pulse { 0%, 100% { opacity: 0.75; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .boot-inner img { animation: none; } }
.notfound { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 96px 16px; }
.notfound .code { font-family: var(--font-mono); font-size: 13px; color: var(--text-3); background: none; border: 0; padding: 0; }
.notfound h1 { font-size: var(--fs-xl); }

/* ---------- Reseller generate result ---------- */
.keys-out { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: var(--r); background: var(--bg); }
.keys-out .k { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.keys-out .k:last-child { border-bottom: 0; }
.keys-out .k .idx { color: var(--text-4); font-family: var(--font-mono); font-size: 11px; min-width: 28px; }
.keys-out .k .v { flex: 1; font-family: var(--font-mono); font-size: 12px; color: var(--text); direction: ltr; text-align: left; user-select: all; }

/* ---------- Shell additions ---------- */
.app-switch .meta > span { display: block; }
.input-wrap.no-icon > .input { padding-inline-start: 10px; }
@media (min-width: 961px) { .shell.is-rail .sb-nav { overflow: visible; } }
.page-host { min-width: 0; }

/* Navigation and reading rhythm, shared by staff and reseller views. */
.skip-link { position: fixed; inset-block-start: -80px; inset-inline-start: 16px; z-index: 100; padding: 10px 16px; background: var(--raised); border: 1px solid var(--border-strong); border-radius: var(--r); }
.skip-link:focus { inset-block-start: 8px; }
.sb-close { display: none; }
.shell:not(.is-rail) .sidebar [data-tip]::after { display: none; }
.sb-nav { overflow-x: hidden; }
.table-note { display: block; width: 200px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.table td { vertical-align: middle; }
[lang="ar"] body { line-height: 1.7; }
[lang="ar"] .nav-item { line-height: 1.5; }
.modal-title { font-size: var(--fs-lg); }
.modal-body .field + .field { margin-top: 4px; }
@media (max-width: 960px) {
  .sb-close { display: grid; position: absolute; inset-block-start: 4px; inset-inline-end: 8px; width: 44px; height: 44px; }
  .sb-brand { padding-inline-end: 60px; }
  .nav-item { height: 44px; }
  .nav-label { height: 36px; }
  .app-switch { height: 44px; }
  .sb-foot .ver { overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 640px) {
  .btn, .btn-sm, .btn-icon, .input, .select, .menu-item { min-height: 40px; }
  .btn-icon { min-width: 40px; }
  .topbar { gap: 4px; }
  .topbar .bell, .topbar .status-pill { display: none; }
  .table-note { width: 180px; }
}

/* Customer subscription banner (under the top bar) */
.sub-banner-wrap { padding: 12px 24px 0; max-width: var(--content-max); width: 100%; margin-inline: auto; }
@media (max-width: 640px) { .sub-banner-wrap { padding: 10px 12px 0; } }
.sub-banner {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--r);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); flex-wrap: wrap;
}
.sub-banner > .icon { flex-shrink: 0; }
.sub-banner.warn { border-color: var(--amber-line); background: var(--tint-amber); }
.sub-banner.warn > .icon { color: var(--amber-text); }
.sub-banner.danger { border-color: var(--red-line); background: var(--tint-red); }
.sub-banner.danger > .icon { color: var(--red-text); }
.sub-banner .grow { min-width: 200px; color: var(--text); }

/* Usage meters (subscription page, reseller quotas) */
.meter { display: flex; flex-direction: column; gap: 6px; }
.meter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.meter-head .lbl { color: var(--text-2); }
.meter-head .val { color: var(--text); font-variant-numeric: tabular-nums; }

/* Tables embedded inside a card body drop their own frame; icon size inside chips. */
.card-body.flush > .table-card,
.card-body.flush > div > .table-card { border: 0; border-radius: 0; background: transparent; }
.chip .icon { width: 12px; height: 12px; }
.modal-icon.success { color: var(--green-text); border-color: var(--green-line); background: var(--green-soft); }


/* Page styles: monitoring pages . */

/* Tables embedded in a .card (dashboard): drop the table-card's own frame so the card provides it. */
.mon-embed > [data-ref] > .table-card { border: 0; border-radius: 0; background: transparent; }

/* Dashboard activity feed: bounded height, scrolls inside the card. */
.mon-feed { max-height: 420px; overflow-y: auto; }


/* Page styles: apps pages . */

/* Currently selected application row in the apps table. */
.table tbody tr.row.is-current > td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
[dir="rtl"] .table tbody tr.row.is-current > td:first-child { box-shadow: inset -2px 0 0 var(--accent); }

/* Owner chip (customer link) */
.chip.owner-chip { color: var(--text-2); transition: border-color var(--t-fast), color var(--t-fast); }
.chip.owner-chip:hover { color: var(--text); border-color: var(--border-strong); }
.page-title .chip { font-weight: 400; letter-spacing: 0; }

/* Tables embedded inside a card body (overview summary / countries). */
.apps-embed > .table-card { border: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); background: transparent; }

/* Settings danger zone */
.danger-zone { border-color: var(--red-line); }
.danger-zone .card-header { border-bottom-color: var(--red-line); }
.danger-zone .card-title .icon { color: var(--red-text); }

/* Variables: keep the masked/revealed value from stretching the row. */
.var-value { max-width: 100%; }
.var-value > .mono { max-width: 420px; }


/* Page styles: config pages . */

/* Settings: sticky unsaved-changes bar at the bottom of the settings form. */
.save-bar {
  position: sticky; bottom: 16px; z-index: 20; display: flex; align-items: center; gap: 10px; margin-top: 16px;
  padding-block: 8px; padding-inline: 14px 8px; background: var(--raised); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-float); color: var(--text);
}
.save-bar > .icon { color: var(--amber-text); flex-shrink: 0; }

/* Webhooks */
.wh-url { max-width: 380px; color: var(--text); }
.wh-chip-label { min-width: 88px; padding-top: 2px; }
.wh-kv { max-width: 560px; }
.wh-group .check-grid { max-height: none; }
.wh-group-title { margin-bottom: 0; }
.wh-groups.is-disabled { opacity: 0.55; }
.wh-groups.is-disabled .check-row { cursor: not-allowed; }


/* Page styles: platform pages . */
/* Customers: clickable status summary tiles */
.pf-stat { text-align: start; cursor: pointer; transition: background var(--t-fast); }
.pf-stat:hover { background: var(--hover); }
.pf-stat.is-active { background: var(--raised); }
.stat-row > .pf-stat:first-child { border-start-start-radius: var(--r-lg); border-end-start-radius: var(--r-lg); }
.stat-row > .pf-stat:last-child { border-start-end-radius: var(--r-lg); border-end-end-radius: var(--r-lg); }

/* Platform plans: responsive card grid, dimmed inactive plans */
.pf-plan-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.pf-plan { display: flex; flex-direction: column; }
.pf-plan > .card-body { flex: 1; }
.pf-plan.is-inactive { opacity: 0.72; }


/* Application > Integration: client SDK card */
.sdk-langs { overflow-x: auto; scrollbar-width: none; margin-block: -2px; padding-block: 2px; }
.sdk-langs::-webkit-scrollbar { display: none; }
.sdk-langs .seg { flex-wrap: nowrap; }
.sdk-langs .seg > button { white-space: nowrap; height: 30px; padding-inline: 12px; }
.sdk-row { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.sdk-row > .field { flex: 1 1 320px; }
.sdk-row > .btn { margin-top: 22px; flex: none; }
.sdk-code { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--bg); overflow: hidden; }
.sdk-code-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 6px 6px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
[dir="rtl"] .sdk-code-head { padding: 6px 12px 6px 6px; }
.sdk-req { font-size: var(--fs-sm); color: var(--text-3); min-width: 0; }
.sdk-code > .code { border: 0; border-radius: 0; margin: 0; max-height: 420px; }
.sdk-note { display: flex; align-items: flex-start; gap: 8px; margin: 0; font-size: var(--fs-sm); color: var(--text-2); }
.sdk-note > .icon { flex: none; margin-top: 2px; color: var(--accent-text); }
.sdk-also { border-top: 1px solid var(--border); padding-top: 12px; }
.sdk-also-title { font-size: var(--fs-sm); font-weight: 600; color: var(--text); margin-bottom: 8px; }
.sdk-also ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sdk-also li { display: flex; align-items: flex-start; gap: 8px; font-size: var(--fs-sm); color: var(--text-2); }
.sdk-also li > .icon { flex: none; margin-top: 2px; color: var(--text-3); --icon-tone: var(--gold); --icon-tone-opacity: 0.45; }
@media (max-width: 640px) { .sdk-row > .btn { margin-top: 0; width: 100%; justify-content: center; } }
