/* ============================================================
   Kalytera SuperAdmin design tokens — mirrors the tenant portal
   design system (src/Kalytera.Cloud.Web/wwwroot/css/site.css) so
   the admin console reads as the same product. Every component
   reads from these variables; no page should hardcode a hex value.
   ============================================================ */
:root {
  /* Brand */
  --k-primary: #2563eb;
  --k-primary-hover: #1d4ed8;
  --k-primary-active: #1b46c2;
  --k-primary-050: #eff4ff;
  --k-primary-100: #dbe6fe;
  --k-primary-soft: rgba(37, 99, 235, 0.12);

  /* Neutral surfaces & text (slate) */
  --k-bg: #f3f6fb;
  --k-surface: #ffffff;
  --k-surface-2: #f8fafc;
  --k-surface-3: #f1f5f9;
  --k-border: #e2e8f0;
  --k-border-strong: #cbd5e1;
  --k-text: #152033;
  --k-text-muted: #64748b;
  --k-text-subtle: #94a3b8;

  /* Semantic (foreground / soft background pairs) */
  --k-success: #16a34a;   --k-success-bg: #dcfce7;  --k-success-fg: #166534;
  --k-warning: #d97706;   --k-warning-bg: #fef3c7;  --k-warning-fg: #92400e;
  --k-danger:  #dc2626;   --k-danger-bg:  #fee2e2;  --k-danger-fg:  #991b1b;
  --k-info:    #2563eb;   --k-info-bg:    #dbeafe;  --k-info-fg:    #1e40af;
  --k-neutral-bg: #eef2f7; --k-neutral-fg: #475569;

  /* Live status */
  --k-status-online: #16a34a;
  --k-status-recording: #dc2626;
  --k-status-idle: #64748b;
  --k-status-error: #d97706;
  --k-status-offline: #94a3b8;

  /* Dark sidebar */
  --k-sidebar-1: #0b1220;
  --k-sidebar-2: #131c33;
  --k-sidebar-link: #aeb9cc;

  /* Spacing (4px base) */
  --k-space-1: 0.25rem;
  --k-space-2: 0.5rem;
  --k-space-3: 0.75rem;
  --k-space-4: 1rem;
  --k-space-5: 1.5rem;
  --k-space-6: 2rem;

  /* Radius */
  --k-radius-sm: 0.45rem;
  --k-radius: 0.65rem;
  --k-radius-lg: 1rem;
  --k-radius-pill: 999px;

  /* Elevation */
  --k-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --k-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --k-shadow-lg: 0 20px 60px rgba(2, 6, 23, 0.35);
}

html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--k-bg);
  color: var(--k-text);
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.2);
}

/* ===== Button system =====
   One consistent look across the console: medium weight, softly rounded, smooth
   motion, brand-aligned colours. Variant colours go through Bootstrap's --bs-btn-*
   vars so component-scoped rules still override them cleanly. */
.btn {
  --bs-btn-font-weight: 500;
  --bs-btn-border-radius: 0.5rem;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease,
    box-shadow 0.15s ease, transform 0.04s ease;
}
.btn-sm {
  --bs-btn-border-radius: 0.45rem;
}
.btn-lg {
  --bs-btn-border-radius: 0.6rem;
}
.btn:active {
  transform: translateY(0.5px);
}

.btn-primary {
  --bs-btn-bg: #2563eb;
  --bs-btn-border-color: #2563eb;
  --bs-btn-hover-bg: #1d4ed8;
  --bs-btn-hover-border-color: #1d4ed8;
  --bs-btn-active-bg: #1b46c2;
  --bs-btn-active-border-color: #1b46c2;
  --bs-btn-disabled-bg: #93b4f5;
  --bs-btn-disabled-border-color: #93b4f5;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover {
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.3);
}

.btn-success {
  --bs-btn-bg: #16a34a;
  --bs-btn-border-color: #16a34a;
  --bs-btn-hover-bg: #15803d;
  --bs-btn-hover-border-color: #15803d;
  --bs-btn-active-bg: #166534;
  --bs-btn-active-border-color: #166534;
}

.btn-outline-primary {
  --bs-btn-color: #2563eb;
  --bs-btn-border-color: #bcd0f7;
  --bs-btn-hover-bg: #2563eb;
  --bs-btn-hover-border-color: #2563eb;
  --bs-btn-active-bg: #1d4ed8;
  --bs-btn-active-border-color: #1d4ed8;
}
.btn-outline-secondary {
  --bs-btn-color: #475569;
  --bs-btn-border-color: #cbd5e1;
  --bs-btn-hover-bg: #f1f5f9;
  --bs-btn-hover-color: #0f172a;
  --bs-btn-hover-border-color: #94a3b8;
  --bs-btn-active-bg: #e2e8f0;
  --bs-btn-active-color: #0f172a;
  --bs-btn-active-border-color: #94a3b8;
}
.btn-outline-success {
  --bs-btn-color: #16a34a;
  --bs-btn-border-color: #bbf7d0;
  --bs-btn-hover-bg: #16a34a;
  --bs-btn-hover-border-color: #16a34a;
}
.btn-outline-danger {
  --bs-btn-color: #dc2626;
  --bs-btn-border-color: #fecaca;
  --bs-btn-hover-bg: #dc2626;
  --bs-btn-hover-border-color: #dc2626;
}
.btn-outline-warning {
  --bs-btn-color: #b45309;
  --bs-btn-border-color: #fde68a;
  --bs-btn-hover-bg: #f59e0b;
  --bs-btn-hover-color: #1f2937;
  --bs-btn-hover-border-color: #f59e0b;
}
.btn-outline-info {
  --bs-btn-color: #1e40af;
  --bs-btn-border-color: #bfdbfe;
  --bs-btn-hover-bg: #2563eb;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-border-color: #2563eb;
}

/* ============================================================
   Dark sidebar shell — mirrors the tenant portal's
   .tenant-shell / .tenant-sidebar so the two portals feel like
   one product. Named admin-* here to stay self-contained.
   ============================================================ */
.admin-shell {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 248px;
  flex: 0 0 248px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, #0b1220 0%, #131c33 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-content {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 1.75rem;
}

/* Brand header */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1.15rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.sidebar-brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  font-size: 1.2rem;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
}
.sidebar-brand-logo { width: 40px; height: auto; display: block; flex: 0 0 auto; }
.sidebar-brand-name { color: #fff; font-weight: 700; font-size: 1.05rem; line-height: 1.1; }
.sidebar-brand-tenant { color: #64748b; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* Scrollable nav area */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem 0.6rem 1rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

.sidebar-section {
  color: #5b6b86;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  padding: 0.9rem 0.7rem 0.35rem;
}

.sidebar-link {
  border-radius: 0.6rem;
  color: #aeb9cc;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.7rem;
  margin-bottom: 0.1rem;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  position: relative;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.sidebar-icon { width: 18px; height: 18px; flex: 0 0 18px; opacity: 0.85; }

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.sidebar-link.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.22), rgba(37, 99, 235, 0.06));
  color: #fff;
}
.sidebar-link.active::before {
  content: "";
  position: absolute;
  left: -0.6rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  border-radius: 0 3px 3px 0;
  background: #3b82f6;
}
.sidebar-link.active .sidebar-icon { opacity: 1; color: #60a5fa; }

/* Footer / signed-in user */
.sidebar-footer {
  padding: 0.85rem 0.9rem 1.1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}
.sidebar-user-avatar {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; color: #fff; font-size: 0.9rem;
  background: linear-gradient(135deg, #334155, #475569);
}
.sidebar-user-meta { min-width: 0; }
.sidebar-user-name { color: #e2e8f0; font-size: 0.82rem; font-weight: 600; line-height: 1.15; }
.sidebar-user-role { color: #64748b; font-size: 0.72rem; }

.portal-card {
  border: 0;
  border-radius: 1rem;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

/* ===== Unified page header (see PageHeaderTagHelper) ===== */
.page-header h1,
.page-header .h3 {
  margin-bottom: 0.25rem;
}
.page-header-text { min-width: 0; }
.page-header-eyebrow {
  color: var(--k-text-muted);
  font-size: var(--k-fs-eyebrow, 0.72rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.15rem;
}
.page-header-title {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
  color: var(--k-text);
}
.page-header-subtitle {
  color: var(--k-text-muted);
  font-size: 0.95rem;
  margin: 0.3rem 0 0;
  max-width: 65ch;
}
.page-header-actions { flex: 0 0 auto; }

/* ===== Inline icon system (see IconTagHelper / IconLibrary) ===== */
.k-icon {
  flex: 0 0 auto;
  vertical-align: -0.18em;
}
/* Size comes from the width/height attributes the tag helper / iconSvg emit;
   fall back to 18px only when a caller renders an icon without them. */
.k-icon:not([width]) {
  width: 18px;
  height: 18px;
}
.btn .k-icon { vertical-align: -0.18em; }
/* Icon-only buttons: square, centred glyph */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.btn-icon.btn-square { padding-left: 0.5rem; padding-right: 0.5rem; }

.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  background: linear-gradient(180deg, var(--k-primary) 0%, #3b82f6 100%);
  content: "";
  inset: 0 auto 0 0;
  position: absolute;
  width: 5px;
}

.stat-label {
  color: #64748b;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  margin: 0.35rem 0;
}

.empty-state {
  background: var(--k-surface-2);
  border: 1px dashed var(--k-border-strong);
  border-radius: 0.85rem;
  color: var(--k-text-muted);
  padding: 2.25rem 2rem;
  text-align: center;
}

/* ============================================================
   Status badge system — one consistent pill for every status
   across the console. Use with human labels (never raw enum names).
   Variants: online / recording / idle / error / offline /
   success / warning / danger / info / neutral.
   ============================================================ */
.k-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.2rem 0.6rem;
  border-radius: var(--k-radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.k-badge::before {
  content: "";
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
  flex: 0 0 auto;
}
.k-badge--dotless::before { display: none; }

.k-badge--success,
.k-badge--online   { background: var(--k-success-bg); color: var(--k-success-fg); }
.k-badge--danger,
.k-badge--recording{ background: var(--k-danger-bg);  color: var(--k-danger-fg); }
.k-badge--warning,
.k-badge--error    { background: var(--k-warning-bg); color: var(--k-warning-fg); }
.k-badge--info     { background: var(--k-info-bg);    color: var(--k-info-fg); }
.k-badge--idle,
.k-badge--offline,
.k-badge--neutral  { background: var(--k-neutral-bg); color: var(--k-neutral-fg); }

/* Recording pulse for the "recording" state */
.k-badge--recording::before { animation: k-pulse 1.4s ease-in-out infinite; }
@keyframes k-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* Refined, consistent data tables: uppercase muted headers and a subtle row-hover. */
.portal-card .table > thead > tr > th {
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.portal-card .table > tbody > tr {
  transition: background-color 0.12s ease;
}
.portal-card .table:not(.table-hover) > tbody > tr:hover {
  background-color: #f8fafc;
}

.auth-page {
  align-items: center;
  background: linear-gradient(135deg, #0f172a 0%, #1d4ed8 100%);
  display: flex;
  min-height: 100vh;
}

.auth-card {
  border-radius: 1.25rem;
}

.auth-brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
}
.auth-logo { width: 202px; max-width: 72%; height: auto; display: block; margin: 0 auto 1.9rem; }
.auth-title { text-align: center; font-size: 1.2rem; font-weight: 600; color: var(--k-text); letter-spacing: -.01em; margin: 0 0 1.7rem; }
.auth-card .card-body { padding: 2.5rem 2.4rem 2.7rem; }
.auth-page .form-control-lg { font-size: .95rem; padding: .62rem .85rem; border-radius: 10px; }
.auth-page .btn-lg { padding: .68rem 1rem; font-size: .98rem; }

/* ============================================================
   Responsive — collapse the sidebar into a stacked header on
   narrow viewports (mirrors the tenant portal breakpoints).
   ============================================================ */
@media (max-width: 991.98px) {
  .admin-shell {
    flex-direction: column;
  }

  .admin-sidebar {
    width: 100%;
    flex-basis: auto;
    height: auto;
    position: static;
  }
  .sidebar-nav {
    overflow-y: visible;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }
  .sidebar-section { width: 100%; }

  .admin-content {
    padding: 1.5rem;
  }
}

@media (max-width: 575.98px) {
  .admin-content {
    padding: 1rem;
  }
}
