/* ============================================================
   EDGE ADMIN CSS
   Built from EDGE public style system
   Clean, simple, dashboard-ready
   ============================================================ */

/* ============================================================
   1. Core Variables And Theme
   ============================================================ */
:root {
  --primary: #6467F2;
  --primary-hover: #4e51d1;

  --accent: #E7FAB5;
  --success: #10b981;
  --warning: #f59e0b;
  --info: #3b82f6;
  --danger: #ef4444;

  --text: #080808;
  --text-strong: #18181b;
  --text-muted: #71717a;
  --text-white: #fafafa;

  --bg: #ffffff;
  --bg-muted: #fbfbfc;
  --card-bg: #ffffff;
  --border: #e4e4e7;

  --bg-primary-10: #ebebfa;
  --bg-primary-50: #f7f7fe;

  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.08);
  --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.12);
  --shadow-colored: 0 4px 12px rgba(100, 103, 242, 0.16);

  --radius: 0.75rem;
  --radius-sm: 0.5rem;

  --transition: all 0.2s ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #080808;
    --bg-muted: #111111;
    --card-bg: #111111;
    --text: #f9fafb;
    --text-strong: #ffffff;
    --text-muted: #94a3b8;
    --border: #262626;
    --bg-primary-10: rgba(100, 103, 242, 0.14);
    --bg-primary-50: rgba(100, 103, 242, 0.08);
  }
}

/* ============================================================
   2. Global Reset
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  line-height: 1.5;
  scroll-behavior: smooth;
  font-family: Arial, Helvetica, sans-serif;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 100%;
}

table {
  border-collapse: collapse;
}

/* ============================================================
   3. Typography
   ============================================================ */
h1,
h2,
h3,
h4 {
  color: var(--text-strong);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin: 0;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1.05rem;
}

h4 {
  font-size: 0.95rem;
}

p {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  text-decoration: underline;
}

/* ============================================================
   4. Layout
   ============================================================ */
.admin-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.admin-main {
  min-width: 0;
  background: var(--bg);
}

.admin-content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header-copy {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.section {
  margin-top: 1.5rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* ============================================================
   5. Sidebar
   ============================================================ */
.sidebar {
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.5rem 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.sidebar-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
}

.sidebar-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 600;
  transition: var(--transition);
}

.nav-link:hover {
  background: var(--bg-primary-10);
  color: var(--primary);
  text-decoration: none;
}

.nav-link.active {
  background: var(--bg-primary-10);
  color: var(--primary);
}

/* ============================================================
   6. Topbar / Filters
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-strong);
}

.topbar-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ============================================================
   7. Cards
   ============================================================ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: var(--transition);
}

.card:hover {
  border-color: rgba(100, 103, 242, 0.25);
  box-shadow: var(--shadow);
}

.card-sm {
  padding: 1rem;
}

.card-lg {
  padding: 1.5rem;
}

.card-muted {
  background: var(--bg-muted);
}

.card-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}

.stat-value {
  font-size: 1.8rem;
  line-height: 1;
  font-weight: 800;
  color: var(--text-strong);
}

.stat-help {
  margin-top: 0.45rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================================
   8. Utilities
   ============================================================ */
.flex {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.flex-col {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.flex-wrap {
  flex-wrap: wrap;
}

.grid {
  display: grid;
  gap: 1rem;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.w-full {
  width: 100%;
}

.hidden {
  display: none !important;
}

.text-muted {
  color: var(--text-muted);
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

/* ============================================================
   9. Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--primary);
  border: 1px solid var(--primary);
  color: var(--text-white);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--text-white);
  text-decoration: none;
  box-shadow: var(--shadow-colored);
}

.btn-outline {
  background: transparent;
  border-color: var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background: var(--bg-primary-10);
  color: var(--primary);
}

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: #059669;
  border-color: #059669;
}

.btn-warn {
  background: var(--warning);
  border-color: var(--warning);
  color: #000;
}

.btn-warn:hover {
  background: #d97706;
  border-color: #d97706;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

.btn-sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
}

/* ============================================================
   10. Badges / Status
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--border);
  color: var(--text-muted);
}

.badge-primary {
  background: var(--bg-primary-10);
  color: var(--primary);
}

/* Status Badge */
.badge-active,
.badge-paid,
.badge-success {
  background: #e8f7e8;
  color: #1f6b2a;
  border: 1px solid #b9e2bf;
}

.badge-warn,
.badge-trial,
.badge-pending {
  background: #fff7e6;
  color: #8a5a00;
  border: 1px solid #f2d28b;
}

.badge-danger,
.badge-cancelled,
.badge-expired,
.badge-refunded,
.badge-failed {
  background: #fdecec;
  color: #8b1e1e;
  border: 1px solid #efc2c2;
}

.badge-unknown {
  background: #f3f4f6;
  color: #4b5563;
  border: 1px solid #d1d5db;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.success {
  background: var(--success);
}

.status-dot.warn {
  background: var(--warning);
}

.status-dot.danger {
  background: var(--danger);
}

.status-dot.info {
  background: var(--info);
}

.status-live,
.status-active,
.status-completed {
  color: var(--success);
}

.status-pending,
.status-review,
.status-paused {
  color: var(--warning);
}

.status-failed,
.status-error,
.status-inactive {
  color: var(--danger);
}

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
}

.status-active {
  background: rgba(34, 197, 94, 0.12);
  color: #166534;
  border-color: rgba(34, 197, 94, 0.25);
}

.status-trial {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  border-color: rgba(59, 130, 246, 0.25);
}

.status-grace {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.25);
}

.status-cancelled,
.status-expired {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.25);
}

.status-neutral {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
  border-color: rgba(100, 116, 139, 0.25);
}

/* Canonical entitlement_status badge variants (task #40) */
.status-trialing {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  border-color: rgba(59, 130, 246, 0.25);
}

.status-pending {
  background: rgba(148, 163, 184, 0.12);
  color: #475569;
  border-color: rgba(148, 163, 184, 0.25);
}

.status-paused,
.status-suspended {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.25);
}

.status-refunded {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.25);
}

/* ============================================================
   11. Tables
   ============================================================ */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
}

table {
  width: 100%;
  min-width: 760px;
  font-size: 0.875rem;
  background: var(--card-bg);
}

th,
td {
  padding: 0.85rem 0.95rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: var(--bg-primary-50);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tbody tr:hover td {
  background: rgba(100, 103, 242, 0.02);
}

/* ============================================================
   12. Forms
   ============================================================ */
form {
  display: grid;
  gap: 1rem;
}

.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(100, 103, 242, 0.1);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ============================================================
   13. Search / Toolbar Inputs
   ============================================================ */
.search-box {
  position: relative;
}

.search-input {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.9rem 0.55rem 2rem;
  font-size: 0.875rem;
  width: 240px;
  transition: var(--transition);
  color: var(--text);
}

.search-input:focus {
  width: 300px;
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(100, 103, 242, 0.1);
}

.search-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 2;
}

/* ============================================================
   14. Panels / Empty States / Logs
   ============================================================ */
.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-title {
  font-weight: 700;
  color: var(--text-strong);
  margin-bottom: 0.5rem;
}

.empty-desc {
  font-size: 0.875rem;
  max-width: 320px;
}

.job-log {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  line-height: 1.6;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
}

/* ============================================================
   15. Responsive
   ============================================================ */
.mobile-toggle {
  display: none;
}

@media (max-width: 1024px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .topbar {
    position: static;
  }

  .search-input,
  .search-input:focus {
    width: 100%;
  }
}

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

  .page-header,
  .section-header,
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }
}

.customer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Admin Header */
.customer-header .page-header-copy {
  min-width: 0;
  flex: 1 1 420px;
}

.customer-header .page-header-copy h1 {
  margin: 0 0 0.35rem 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.customer-header .page-header-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
}


.inline-details summary {
  list-style: none;
  cursor: pointer;
}

.inline-details summary::-webkit-details-marker {
  display: none;
}

.inline-details[open] {
  min-width: 420px;
}

.entitlement-edit-form {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

/* ============================================================
NIKA ADMIN COMPONENTS — 2026-06-13 (mirrors accounts.css quality;
SEPARATE sheet by design — customer pages must never load admin.css)
============================================================ */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 8px 0; }
.metric-card { background: #fff; border: 1px solid #e6e3dd; border-radius: 8px; padding: 14px 16px; }
.metric-label { font-size: 12px; color: #76726b; margin: 0 0 4px; }
.metric-value { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; color: #211f1d; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { text-align: left; font-size: 12px; letter-spacing: 0.02em; text-transform: uppercase; color: #76726b; background: #f4f2ee; padding: 10px 14px; border-bottom: 1px solid #e6e3dd; }
.data-table td { padding: 10px 14px; border-bottom: 1px solid #e6e3dd; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f7f5f1; }
.button-primary { display: inline-block; background: #6467f2; color: #fff; font-weight: 600; font-size: 14px; padding: 9px 16px; border: 0; border-radius: 8px; cursor: pointer; text-decoration: none; }
.button-primary:hover { background: #4e51d1; color: #fff; }
.button-ghost { display: inline-block; background: #fff; color: #211f1d; font-weight: 600; font-size: 14px; padding: 8px 14px; border: 1px solid #e6e3dd; border-radius: 8px; cursor: pointer; text-decoration: none; }
.button-ghost:hover { background: #f4f2ee; }
.alert { border: 1px solid #e6e3dd; border-left: 3px solid #6467f2; background: #fff; border-radius: 8px; padding: 12px 16px; margin: 10px 0; }
.alert-danger { border-left-color: #b2433f; background: #fbeded; color: #7a302d; }
.status-success { display: inline-block; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: #eef6ef; color: #3f7d52; }
