/**
 * portal.css
 *
 * NOVAY AI brand theme on top of Bootstrap 5 (RTL + LTR).
 * Designed around four ideas the brand book calls out:
 *   1. Purple as the primary surface, light blue as accent
 *   2. Cairo (Arabic) + Montserrat (Latin) typography
 *   3. Generous spacing and radii — not "admin template" cramped
 *   4. Status as colour, not just text
 */

:root {
  /* Brand */
  --novay-primary:        #8e67c3;
  --novay-primary-dark:   #5a3d87;
  --novay-primary-soft:   #b49ad7;
  --novay-deep:           #22192e;
  --novay-deep-2:         #342647;
  --novay-secondary:      #a1c8d9;
  --novay-bg:             #f7f5fb;
  --novay-bg-2:           #fbfaff;
  --novay-ink:            #2a2233;
  --novay-ink-soft:       #6b6079;
  --novay-line:           rgba(34, 25, 46, .08);

  /* Status */
  --novay-success:        #21c98a;
  --novay-success-bg:     #e6faf2;
  --novay-warning:        #f4a72b;
  --novay-warning-bg:     #fff5e2;
  --novay-danger:         #e0506b;
  --novay-danger-bg:      #fdebef;

  /* Layout */
  --portal-radius:        1rem;
  --portal-radius-sm:     .55rem;

  /* Bootstrap variable overrides */
  --bs-primary:           #8e67c3;
  --bs-primary-rgb:       142, 103, 195;
  --bs-link-color:        #5a3d87;
  --bs-link-hover-color:  #22192e;
  --bs-link-color-rgb:    90, 61, 135;
  --bs-body-bg:           var(--novay-bg);
  --bs-body-color:        var(--novay-ink);
  --bs-border-radius:     var(--portal-radius-sm);
  --bs-border-radius-lg:  var(--portal-radius);
}

/* Type ----------------------------------------------------------------- */
html, body {
  font-family: 'Montserrat', 'Cairo', 'Segoe UI', system-ui, sans-serif;
  font-feature-settings: "ss01", "cv11";
  background: var(--novay-bg);
  color: var(--novay-ink);
}
body { overflow-x: clip; } /* the full-bleed canopy uses 50vw margins */
[lang="ar"], [lang="ar"] body {
  font-family: 'Cairo', 'Montserrat', 'Segoe UI', system-ui, sans-serif;
}
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
  font-weight: 700;
  letter-spacing: -.012em;
  color: var(--novay-deep);
}
.text-muted, .small.text-muted { color: var(--novay-ink-soft) !important; }

/* Layout shell --------------------------------------------------------- */
main.container-fluid { max-width: 1480px; margin: 0 auto; padding-inline: 1.25rem 1.25rem; padding-bottom: 3rem; }
@media (min-width: 1200px) { main.container-fluid { padding-inline: 2rem 2rem; } }

/* Buttons -------------------------------------------------------------- */
.btn {
  font-weight: 600;
  letter-spacing: .005em;
  border-radius: var(--portal-radius-sm);
  padding-inline: 1rem;
}
.btn-primary {
  --bs-btn-bg: var(--novay-primary);
  --bs-btn-border-color: var(--novay-primary);
  --bs-btn-hover-bg: var(--novay-primary-dark);
  --bs-btn-hover-border-color: var(--novay-primary-dark);
  --bs-btn-active-bg: var(--novay-deep-2);
  --bs-btn-active-border-color: var(--novay-deep-2);
  box-shadow: 0 6px 18px rgba(142, 103, 195, .25);
}
.btn-primary:hover { box-shadow: 0 8px 22px rgba(90, 61, 135, .35); }
.btn-outline-primary {
  --bs-btn-color: var(--novay-primary);
  --bs-btn-border-color: var(--novay-primary);
  --bs-btn-hover-bg: var(--novay-primary);
  --bs-btn-hover-border-color: var(--novay-primary);
}
.btn-warning {
  --bs-btn-bg: var(--novay-warning);
  --bs-btn-border-color: var(--novay-warning);
  --bs-btn-color: #fff;
  --bs-btn-hover-bg: #d18c14;
  --bs-btn-hover-border-color: #d18c14;
  --bs-btn-hover-color: #fff;
}

/* Navbar --------------------------------------------------------------- */
.navbar.bg-primary,
.navbar-dark.bg-primary {
  background: #1a1325 !important;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  padding-block: .65rem;
  box-shadow: none;
}
.navbar .container-fluid { max-width: 1480px; }
.navbar-brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: .04em;
  color: #fff !important;
}
.brand-mark {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--novay-primary) 0%, var(--novay-primary-dark) 100%);
  color: #fff;
  border-radius: 8px;
  font-weight: 800;
  font-size: .9rem;
  letter-spacing: -.02em;
}
.navbar .nav-link {
  color: rgba(255, 255, 255, .72) !important;
  font-weight: 500;
  padding-inline: .85rem;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border-radius: 8px;
  transition: background .15s, color .15s;
}
.navbar .nav-link:hover,
.navbar .nav-link.active {
  color: #fff !important;
  background: rgba(255, 255, 255, .07);
}
.navbar .nav-link i { font-size: 1rem; opacity: .85; }
.navbar .dropdown-menu {
  border: 0;
  border-radius: var(--portal-radius-sm);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .18);
  padding: .35rem;
}
.navbar .dropdown-item {
  border-radius: 6px;
  padding: .5rem .75rem;
  font-size: .92rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.navbar .dropdown-item:hover { background: var(--novay-bg); color: var(--novay-deep); }
.navbar .dropdown-item.active { background: var(--novay-primary); color: #fff; }

/* Avatar dropdown trigger */
.avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--novay-primary) 0%, var(--novay-primary-dark) 100%);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, .12);
  font-weight: 700;
  font-size: .85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.avatar-btn:hover { border-color: rgba(255, 255, 255, .35); }

/* Login ---------------------------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background:
    radial-gradient(circle at 25% 20%, rgba(142, 103, 195, .55) 0%, transparent 55%),
    radial-gradient(circle at 75% 80%, rgba(161, 200, 217, .28) 0%, transparent 55%),
    linear-gradient(135deg, #1a1224 0%, var(--novay-primary-dark) 100%);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, .04) 1px, transparent 1px) 0 0/14px 14px;
  pointer-events: none;
}
.login-wrap { width: 100%; max-width: 440px; position: relative; }
.login-page .login-card {
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: var(--portal-radius);
  background: rgba(255, 255, 255, .07);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  backdrop-filter: blur(26px) saturate(150%);
  box-shadow: 0 30px 70px rgba(15, 8, 28, .45);
  color: #fff;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .login-page .login-card { background: rgba(26, 19, 37, .92); }
}
.login-card .card-body { padding: 2.5rem 2rem; }
.login-card .form-label { color: rgba(255, 255, 255, .75); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.login-card .form-control {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14);
  color: #fff;
  border-radius: var(--portal-radius-sm);
  padding: .8rem 1rem;
  font-size: 1rem;
}
.login-card .form-control::placeholder { color: rgba(255, 255, 255, .4); }
.login-card .form-control:focus {
  background: rgba(255, 255, 255, .12);
  border-color: var(--novay-primary-soft);
  box-shadow: 0 0 0 3px rgba(142, 103, 195, .35);
  color: #fff;
}
.login-card .form-control:-webkit-autofill {
  -webkit-text-fill-color: #fff;
  -webkit-box-shadow: 0 0 0 1000px #372a4d inset;
  caret-color: #fff;
}
.login-card .btn-primary {
  background: linear-gradient(135deg, var(--novay-primary) 0%, var(--novay-primary-dark) 100%);
  color: #fff;
  border: 0;
  font-weight: 700;
  padding: .85rem;
  letter-spacing: .02em;
  box-shadow: 0 10px 24px rgba(142, 103, 195, .35);
}
.login-card .btn-primary:hover {
  background: linear-gradient(135deg, var(--novay-primary-dark) 0%, var(--novay-deep-2) 100%);
  color: #fff;
  box-shadow: 0 14px 28px rgba(90, 61, 135, .45);
}
.login-card .btn-outline-secondary {
  border-color: rgba(255, 255, 255, .25);
  color: rgba(255, 255, 255, .75);
  background: transparent;
}
.login-card .btn-outline-secondary.active,
.login-card .btn-outline-secondary:hover {
  background: var(--novay-primary);
  border-color: var(--novay-primary);
  color: #fff;
}
.login-card .alert-danger {
  border-radius: var(--portal-radius-sm);
  background: rgba(224, 80, 107, .16);
  border-color: rgba(224, 80, 107, .4);
  color: #ffc2ce;
}

.login-brand { display: flex; flex-direction: column; align-items: center; margin-bottom: 1.75rem; }
.login-brand .brand-mark-lg {
  width: 68px; height: 68px;
  border-radius: 18px;
  font-size: 1.9rem;
  box-shadow: 0 14px 34px rgba(142, 103, 195, .45);
  margin-bottom: 1rem;
}
.login-brand .brand-name {
  color: #fff; font-weight: 800; font-size: 1.6rem; letter-spacing: .05em;
}
.login-brand .brand-subtitle { color: rgba(255, 255, 255, .62); font-size: .9rem; margin-top: .5rem; text-align: center; }

.login-page .text-muted { color: rgba(255, 255, 255, .65) !important; }
.login-page .login-link { color: rgba(255, 255, 255, .65); font-size: .88rem; text-decoration: none; }
.login-page .login-link:hover { color: #fff; text-decoration: underline; }
.login-card .alert-success {
  border-radius: var(--portal-radius-sm);
  background: rgba(33, 201, 138, .16);
  border-color: rgba(33, 201, 138, .4);
  color: #a9f0d3;
}

/* Cards ---------------------------------------------------------------- */
.card {
  border-radius: var(--portal-radius);
  border: 1px solid var(--novay-line);
  background: #fff;
  box-shadow: 0 1px 2px rgba(34, 25, 46, .04);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--novay-line);
  font-weight: 600;
  color: var(--novay-deep);
  padding: 1rem 1.25rem;
}
.card-body { padding: 1.25rem; }

/* Dashboard tile ------------------------------------------------------- */
.dash-tile {
  position: relative;
  padding: 1.4rem 1.4rem 1.5rem;
  border-radius: var(--portal-radius);
  border: 1px solid var(--novay-line);
  background: #fff;
  text-decoration: none;
  display: block;
  overflow: hidden;
  isolation: isolate;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.dash-tile::before {
  content: "";
  position: absolute; left: 0; right: 0; top: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--novay-primary), var(--novay-primary-soft));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .25s ease;
}
[dir="rtl"] .dash-tile::before { transform-origin: right; }
.dash-tile .tile-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 600;
  color: var(--novay-ink-soft);
  margin-bottom: .35rem;
}
.dash-tile .tile-value {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1.05;
  color: var(--novay-primary-dark);
  letter-spacing: -.02em;
}
.dash-tile .tile-icon {
  position: absolute;
  bottom: -.25rem;
  inset-inline-end: -.25rem;
  font-size: 5rem;
  color: var(--novay-primary);
  opacity: .07;
  z-index: -1;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.dash-tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px rgba(34, 25, 46, .09);
  border-color: rgba(142, 103, 195, .25);
}
.dash-tile:hover::before { transform: scaleX(1); }
.dash-tile:hover .tile-icon { opacity: .14; transform: rotate(-6deg) scale(1.05); }

/* Status pills (online/offline/loading) -------------------------------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .78rem;
  font-weight: 600;
  padding: .35rem .75rem;
  border-radius: 999px;
  letter-spacing: .02em;
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-pill.is-online   { background: var(--novay-success-bg); color: #137a55; }
.status-pill.is-online   .dot { background: var(--novay-success); box-shadow: 0 0 0 0 rgba(33, 201, 138, .6); animation: pulse-dot 1.6s ease-out infinite; }
.status-pill.is-offline  { background: var(--novay-danger-bg);  color: #b53349; }
.status-pill.is-offline  .dot { background: var(--novay-danger); }
.status-pill.is-warning  { background: var(--novay-warning-bg); color: #a36d05; }
.status-pill.is-warning  .dot { background: var(--novay-warning); }
.status-pill.is-loading  { background: rgba(34, 25, 46, .07); color: var(--novay-ink-soft); }
.status-pill.is-loading  .dot { background: var(--novay-ink-soft); }
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 rgba(33, 201, 138, .55); }
  70%  { box-shadow: 0 0 0 8px rgba(33, 201, 138, 0); }
  100% { box-shadow: 0 0 0 0 rgba(33, 201, 138, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .status-pill.is-online .dot { animation: none; }
}

/* Telemetry canopy ------------------------------------------------------ */
/* The navbar and the PBX live-status hero fuse into one dark band: what is
   happening NOW lives on dark, what you configure lives on light below. */
.canopy {
  margin-inline: calc(50% - 50vw);
  padding-inline: calc(50vw - 50%);
  padding-block: 1.9rem 4.6rem; /* deep bottom: the tiles overlap this edge */
  background:
    radial-gradient(720px 340px at 14% -35%, rgba(142, 103, 195, .40) 0%, transparent 70%),
    radial-gradient(560px 280px at 86% -25%, rgba(161, 200, 217, .14) 0%, transparent 70%),
    #1a1325;
  color: #fff;
}
.canopy h1, .canopy h2, .canopy h3 { color: #fff; }
.canopy .text-muted { color: rgba(255, 255, 255, .55) !important; }
.canopy .eyebrow {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .12em;
  color: rgba(255, 255, 255, .45); font-weight: 600; margin-bottom: .6rem;
}
.canopy .status-pill.is-loading { background: rgba(255, 255, 255, .08); color: rgba(255, 255, 255, .7); }
.canopy .status-pill.is-loading .dot { background: rgba(255, 255, 255, .6); }
.canopy .alert-warning { background: rgba(244, 167, 43, .12); border-color: rgba(244, 167, 43, .35); color: #ffd9a0; }

/* Content that overlaps the canopy seam */
.pull-up { margin-top: -3.1rem; position: relative; z-index: 1; }

/* PBX status hero numbers ---------------------------------------------- */
.pbx-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .9rem;
  margin-bottom: 0;
}
.pbx-hero .hero-cell {
  padding: 1rem 1.1rem;
  background: var(--novay-bg-2);
  border-radius: var(--portal-radius-sm);
  border: 1px solid var(--novay-line);
}
.pbx-hero .hero-cell .label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--novay-ink-soft); font-weight: 600;
}
.pbx-hero .hero-cell .value {
  font-size: 1.85rem; font-weight: 800; color: var(--novay-primary-dark);
  letter-spacing: -.015em; line-height: 1.1;
  font-variant-numeric: tabular-nums; /* count-up must not jitter */
}
.canopy .hero-cell { background: rgba(255, 255, 255, .055); border-color: rgba(255, 255, 255, .09); }
.canopy .hero-cell .label { color: rgba(255, 255, 255, .5); }
.canopy .hero-cell .value { color: #fff; text-shadow: 0 0 26px rgba(142, 103, 195, .55); }

/* Disposition pills inside tables -------------------------------------- */
.disp-pill {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  padding: .25rem .6rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.disp-pill.is-answered { background: var(--novay-success-bg); color: #137a55; }
.disp-pill.is-failed   { background: var(--novay-danger-bg);  color: #b53349; }
.disp-pill.is-busy     { background: var(--novay-warning-bg); color: #a36d05; }
.disp-pill.is-other    { background: rgba(34, 25, 46, .07); color: var(--novay-ink-soft); }

/* Tables --------------------------------------------------------------- */
.table {
  --bs-table-bg: transparent;
  --bs-table-hover-bg: #faf7ff;
}
.table thead th {
  background: transparent;
  color: var(--novay-ink-soft);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .72rem;
  border-bottom: 1px solid var(--novay-line);
}
.table tbody td { vertical-align: middle; border-color: var(--novay-line); }
.table tbody tr:nth-child(even) { background: rgba(142, 103, 195, .035); }
.table tbody tr:hover { background: var(--bs-table-hover-bg); }
.num-mono { font-family: 'JetBrains Mono', 'Fira Mono', SFMono-Regular, Consolas, monospace; font-size: .92em; }

/* Forms ---------------------------------------------------------------- */
.form-control:focus, .form-select:focus {
  border-color: var(--novay-primary);
  box-shadow: 0 0 0 3px rgba(142, 103, 195, .18);
}
.form-control, .form-select {
  border-radius: var(--portal-radius-sm);
  padding: .55rem .85rem;
}

/* Toasts --------------------------------------------------------------- */
.toast {
  min-width: 260px;
  border: 1px solid var(--novay-line);
  border-radius: var(--portal-radius-sm);
}

/* Resource picker ------------------------------------------------------ */
.resource-picker { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.75rem; align-items: stretch; }
.resource-picker select { height: 240px; border-radius: var(--portal-radius-sm); }
.resource-picker .pick-actions { display: flex; flex-direction: column; gap: .5rem; justify-content: center; }
@media (max-width: 768px) {
  .resource-picker { grid-template-columns: 1fr; }
  .resource-picker .pick-actions { flex-direction: row; }
}

/* RTL bootstrap quirks ------------------------------------------------- */
[dir="rtl"] .navbar-brand { margin-right: 0; margin-left: 1rem; }
[dir="rtl"] .me-auto { margin-left: auto !important; margin-right: 0 !important; }
[dir="rtl"] .form-text { text-align: right; }

/* Audio player --------------------------------------------------------- */
audio { width: 100%; max-width: 300px; height: 32px; }

/* Entrance animations -------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .fade-in-up { animation: fadeInUp .42s cubic-bezier(.2,.8,.2,1) both; }
  .fade-in-up-1 { animation-delay: .04s; }
  .fade-in-up-2 { animation-delay: .08s; }
  .fade-in-up-3 { animation-delay: .12s; }
  .fade-in-up-4 { animation-delay: .16s; }
  .fade-in-up-5 { animation-delay: .20s; }
  .fade-in-up-6 { animation-delay: .24s; }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
