/* ============================================================
   ArenaCRM Design System — Premium SaaS Layer
   Extends ui-kit.css. No overriding of layout-sidebar.css.
   ============================================================ */

:root {
  --ds-font-sans:    var(--font-sans, 'Inter', system-ui, sans-serif);
  --ds-radius-sm:    var(--radius-sm,  6px);
  --ds-radius-md:    var(--radius-md,  10px);
  --ds-radius-lg:    var(--radius-lg,  14px);

  --ds-shadow-sm:    var(--shadow-sm);
  --ds-shadow-md:    var(--shadow-md);
  --ds-shadow-lg:    var(--shadow-lg);

  --ds-brand:        var(--color-primary,     #0C4DA2);
  --ds-brand-600:    var(--color-primary-dark, #094190);
  --ds-accent:       var(--color-accent,       #E63946);

  --ds-bg:           var(--color-bg,      #F5F7FB);
  --ds-surface:      var(--color-surface, #FFFFFF);
  --ds-muted:        var(--color-text-muted,  #6B7280);
  --ds-border:       var(--color-border,       #E4E8EF);
  --ds-text:         var(--color-text,         #111827);

  --ds-success:      var(--color-success, #16A34A);
  --ds-warning:      var(--color-warning, #D97706);
  --ds-danger:       var(--color-danger,  #DC2626);
  --ds-info:         var(--color-info,    #2563EB);
}

/* ── BASE ───────────────────────────────────────────────────── */
html, body { background: var(--ds-bg); color: var(--ds-text); font-family: var(--ds-font-sans); }

/* ── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
  background: var(--ds-surface);
  border-bottom: 1px solid var(--ds-border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.navbar .nav-link { font-weight: 600; color: var(--ds-muted); }
.navbar .nav-link.active, .navbar .nav-link:hover { color: var(--ds-text); }

/* ── CARDS ──────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  box-shadow: var(--ds-shadow-sm);
  overflow: hidden;
  background: var(--ds-surface);
  transition: box-shadow 180ms ease, transform 180ms ease;
}
.card:hover { box-shadow: var(--ds-shadow-md); }
.card-header { background: transparent; border-bottom: 1px solid var(--ds-border); font-weight: 600; padding: 14px 20px; }
.card-body   { padding: 18px 20px; }
.card-footer { background: var(--ds-bg); border-top: 1px solid var(--ds-border); padding: 10px 20px; }
.ui-card { border-radius: var(--ds-radius-lg); box-shadow: var(--ds-shadow-sm); }

/* ── KPI CARDS ──────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.card-kpi {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  padding: 18px 20px;
  box-shadow: var(--ds-shadow-sm);
  position: relative;
  overflow: hidden;
  transition: box-shadow 180ms ease, transform 180ms ease;
}
.card-kpi:hover { box-shadow: var(--ds-shadow-md); transform: translateY(-1px); }

/* Subtle tinted top border per card type */
.card-kpi::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--ds-brand);
  border-radius: var(--ds-radius-lg) var(--ds-radius-lg) 0 0;
  opacity: 0.7;
}
.card-kpi.kpi-success::before  { background: var(--ds-success); }
.card-kpi.kpi-warning::before  { background: var(--ds-warning); }
.card-kpi.kpi-danger::before   { background: var(--ds-danger); }
.card-kpi.kpi-info::before     { background: var(--ds-info); }

.card-kpi .label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ds-muted);
  margin-bottom: 8px;
  display: block;
}
.card-kpi .value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--ds-text);
  line-height: 1;
}
.card-kpi .kpi-sub {
  font-size: 11px;
  color: var(--ds-muted);
  margin-top: 6px;
}

/* Accounting KPI grid (4-column fixed) */
.kpi-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  padding: 18px 20px;
  border-radius: var(--ds-radius-md);
  box-shadow: var(--ds-shadow-sm);
}
.kpi-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ds-muted);
  margin-bottom: 8px;
}
.kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -0.4px; }

/* ── TABLES ─────────────────────────────────────────────────── */
.table.ui-table { border-color: var(--ds-border); }
.table.ui-table thead th {
  background: var(--ds-bg);
  border-bottom: 1.5px solid var(--ds-border);
  color: var(--ds-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 10px 12px;
}
.table.ui-table tbody tr { transition: background 120ms ease; }
.table.ui-table tbody tr:hover { background: rgba(12,77,162,0.035); }
.table.ui-table td, .table.ui-table th { vertical-align: middle; }

/* Accounting table */
.accounting-table { width: 100%; border-collapse: collapse; background: var(--ds-surface); }
.accounting-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ds-muted);
  padding: 10px 14px;
  border-bottom: 1.5px solid var(--ds-border);
  background: var(--ds-bg);
}
.accounting-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--ds-border);
  font-size: 13px;
  vertical-align: middle;
}
.accounting-table tbody tr:last-child td { border-bottom: none; }
.accounting-table tbody tr { transition: background 120ms ease; }
.accounting-table tbody tr:hover { background: rgba(12,77,162,0.03); }
.money { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── FORMS ──────────────────────────────────────────────────── */
.form-control, .form-select {
  border-radius: var(--ds-radius-md);
  border-color: var(--ds-border);
  font-size: 13px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--ds-brand);
  box-shadow: 0 0 0 3px rgba(12,77,162,0.12);
}
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ds-muted);
  margin-bottom: 5px;
}

/* ── BUTTONS ────────────────────────────────────────────────── */
.btn {
  border-radius: var(--ds-radius-md);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.1px;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.btn:hover  { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary  { background: var(--ds-brand);   border-color: var(--ds-brand); }
.btn-primary:hover  { background: var(--ds-brand-600); border-color: var(--ds-brand-600); }
.btn-outline-secondary { color: var(--ds-text); border-color: var(--ds-border); }
.btn-outline-secondary:hover { background: var(--ds-bg); }
.btn-warning { color: #1F2937; }

/* ── STATUS BADGES (Accounting) ─────────────────────────────── */
.badge {
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  letter-spacing: 0.2px;
}
.badge-paid    { background: #DCFCE7; color: #166534; }
.badge-due     { background: #DBEAFE; color: #1E40AF; }
.badge-overdue { background: #FEE2E2; color: #991B1B; }
.badge-void    { background: #F3F4F6; color: #4B5563; }

/* ── INVOICE ────────────────────────────────────────────────── */
.invoice-total {
  font-size: 22px;
  font-weight: 700;
  text-align: right;
  margin-top: 20px;
  color: var(--ds-text);
}
.row-danger { background: #FFF5F5; }

/* ── ADMIN TOASTS ───────────────────────────────────────────── */
.admin-toast-container {
  position: fixed; top: 1rem; right: 1rem;
  z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
  max-width: 360px; width: 100%;
}
.admin-toast {
  background: var(--ds-surface);
  color: var(--ds-text);
  padding: 14px 16px;
  border-radius: var(--ds-radius-md);
  box-shadow: var(--ds-shadow-lg);
  border: 1px solid var(--ds-border);
  animation: toastSlide 220ms cubic-bezier(0.16,1,0.3,1);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
@keyframes toastSlide {
  from { opacity: 0; transform: translateX(24px) scale(.97); }
  to   { opacity: 1; transform: translateX(0)    scale(1); }
}
.admin-toast .title { font-weight: 700; color: var(--ds-text); }
.admin-toast .time  { color: var(--ds-muted); font-size: 11px; }

/* ── PAGE HEADER ────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.page-header h3, .page-header h2 { margin: 0; }

/* ── FILTER BAR ─────────────────────────────────────────────── */
.filter-bar {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  padding: 14px 18px;
  margin-bottom: 16px;
  box-shadow: var(--ds-shadow-sm);
}

/* ── DATA TABLE WRAPPER ─────────────────────────────────────── */
.data-table-card {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  box-shadow: var(--ds-shadow-sm);
  overflow: hidden;
}
.data-table-card .table thead th:first-child { padding-left: 20px; }
.data-table-card .table tbody td:first-child  { padding-left: 20px; }

/* ── CHIPS ──────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.2px;
  box-shadow: none;
}

/* ── UTILITIES ──────────────────────────────────────────────── */
.muted  { color: var(--ds-muted); }
.nowrap { white-space: nowrap; }
.shadow-sm { box-shadow: var(--ds-shadow-sm) !important; }
.shadow-md { box-shadow: var(--ds-shadow-md) !important; }
.shadow-lg { box-shadow: var(--ds-shadow-lg) !important; }

/* Subtle interactive lift for interactive elements */
.btn, .card-kpi { transition: transform 120ms ease, box-shadow 150ms ease; }
.card-kpi:active { transform: translateY(0); box-shadow: var(--ds-shadow-sm); }
