/* =====================================================================
   Design tokens — Ironsafe Solutions
   Layout, spacing, radius, shadows, and component patterns adopted from
   TailAdmin's design system (white sidebar, rounded-2xl cards, pill
   badges, Outfit typeface). Brand accent colors (teal/indigo) stay
   Ironsafe's own — pulled from the actual logo — rather than swapping
   in TailAdmin's generic demo blue.
   ===================================================================== */
:root {
  /* Grayscale (TailAdmin's gray scale) */
  --gray-25:  #fcfcfd;
  --gray-50:  #f9fafb;
  --gray-100: #f2f4f7;
  --gray-200: #e4e7ec;
  --gray-300: #d0d5dd;
  --gray-400: #98a2b3;
  --gray-500: #667085;
  --gray-600: #475467;
  --gray-700: #344054;
  --gray-800: #1d2939;
  --gray-900: #101828;

  --ink:        var(--gray-900);
  --ink-soft:   var(--gray-500);
  --canvas:     var(--gray-50);
  --surface:    #ffffff;
  --surface-alt:var(--gray-50);
  --border:     var(--gray-200);

  /* Brand accent — Ironsafe's own teal/indigo, not TailAdmin's demo blue */
  --teal:       #1B93A8;
  --teal-dark:  #146F80;
  --teal-soft:  #ECF3FF; /* TailAdmin's brand-50 tint, reused for the "active" wash */
  --indigo:     #4A3789;
  --indigo-dark:#392A6B;
  --indigo-soft:#ECE7F7;

  /* Semantic colors — adopted straight from TailAdmin's palette */
  --forest:     #12B76A; /* success-500 */
  --forest-soft:#ECFDF3; /* success-50 */
  --brick:      #F04438; /* error-500 — decorative use only (icons, soft badge fills); fails WCAG AA (3.76:1) for text or white-on-color, see --brick-dark */
  --brick-dark: #B42318; /* WCAG AA-passing red — 6.57:1 with white text, 6.57:1 for text on white. Use this, not --brick, for error text, danger buttons, and danger badge backgrounds. */
  --brick-soft: #FEF3F2; /* error-50 */
  --amber:      #F79009; /* warning-500 */
  --amber-soft: #FFFAEB; /* warning-50 */

  --charcoal:      var(--gray-900);
  --charcoal-dark: var(--gray-900);

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;

  --shadow-sm: 0px 1px 2px 0px rgba(16,24,40,.05);
  --shadow:    0px 4px 8px -2px rgba(16,24,40,.10), 0px 2px 4px -2px rgba(16,24,40,.06);

  --font-display: 'Outfit', -apple-system, sans-serif;
  --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --sidebar-width: 260px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---------------------------------------------------------------------
   Base
   --------------------------------------------------------------------- */
html { scroll-behavior: smooth; }

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

h1, h2 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
}
h3, h4, h5, h6 { font-family: var(--font-body); font-weight: 600; color: var(--ink); }

a { color: var(--teal-dark); }
a:hover { text-decoration: underline; }

::selection { background: var(--teal-soft); color: var(--indigo-dark); }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, .btn:focus-visible, .nav-link:focus-visible {
  outline: 2px solid var(--teal-dark);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------
   Accessibility — skip link and minimum touch target size (WCAG 2.2 AA,
   2.5.8). Icon-only buttons under 24x24 CSS px are hard to hit precisely
   for anyone with a tremor, low dexterity, or on a touchscreen; this
   floor applies globally rather than needing a fix on every individual
   small button across the app.
   --------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 8px;
  z-index: 2000;
  background: var(--teal-dark);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  transition: top .15s;
}
.skip-link:focus {
  top: 8px;
  color: #fff;
}

.btn-sm:not(.dropdown-toggle-split) {
  min-width: 32px;
  min-height: 32px;
}
/* An icon-only button (no visible text node, just an <i> icon) still
   needs a real click/tap target even at btn-sm size. */
.btn-sm > i:only-child {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 12px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 .2rem rgba(27,147,168,.14);
}

.app-wrapper { display: flex; min-height: 100vh; }

/* ---------------------------------------------------------------------
   Sidebar — light, per TailAdmin (was dark charcoal)
   --------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  color: var(--gray-700);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  z-index: 1030;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.sidebar-brand img { height: 30px; width: auto; display: block; }
.sidebar-brand .brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.sidebar-brand .brand-text .name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: .01em;
  color: var(--ink);
}
.sidebar-brand .brand-text .sub {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: .58rem;
  letter-spacing: .18em;
  color: var(--gray-500);
}

.sidebar .nav-link {
  color: var(--gray-700);
  padding: 9px 14px;
  margin: 1px 12px;
  font-size: .89rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 2px;
}
.sidebar .nav-link i { width: 22px; display: inline-block; font-size: 1rem; color: var(--gray-500); }
.sidebar .nav-link:hover { background: var(--gray-100); color: var(--ink); }
.sidebar .nav-link.active {
  background: var(--teal-soft);
  color: var(--teal-dark);
}
.sidebar .nav-link.active i { color: var(--teal-dark); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16,24,40,.45);
  z-index: 1020;
}
.sidebar-backdrop.show { display: block; }

.main-content { margin-left: var(--sidebar-width); flex: 1; min-width: 0; }

/* ---------------------------------------------------------------------
   Topbar
   --------------------------------------------------------------------- */
.topbar {
  background: var(--surface);
  padding: 14px 26px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 900;
}
.topbar h5 { margin: 0; font-weight: 600; letter-spacing: -.01em; }

.content-body { padding: 24px; }

/* ---------------------------------------------------------------------
   Stat cards — TailAdmin's icon-badge metric card pattern
   --------------------------------------------------------------------- */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  height: 100%;
  position: relative;
}
.stat-card .stat-icon-badge {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: var(--gray-100);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 1.3rem;
  color: var(--gray-800);
}
.stat-card .stat-label { font-size: .82rem; color: var(--ink-soft); font-weight: 500; }
.stat-card .stat-value {
  font-family: var(--font-body);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.stat-card .stat-icon { font-size: 1.4rem; color: var(--gray-800); }

/* ---------------------------------------------------------------------
   Cards, tables, forms
   --------------------------------------------------------------------- */
.card { border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: none; }
.card-header { background: var(--surface); border-bottom: 1px solid var(--border); font-weight: 600; color: var(--ink); border-top-left-radius: var(--radius-lg); border-top-right-radius: var(--radius-lg); }

table.table thead th {
  font-size: .76rem;
  text-transform: none;
  letter-spacing: .01em;
  color: var(--ink-soft);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
table.table td, table.table th { vertical-align: middle; }
.table-hover tbody tr:hover { background-color: var(--surface-alt); }
.table-light { background-color: var(--surface-alt) !important; }

/* Pill-shaped status badges, matching TailAdmin's trend-badge style */
.badge-status { font-size: .72rem; padding: 5px 10px; border-radius: 999px; font-weight: 500; }
.badge { border-radius: 999px; font-weight: 500; }

.form-label { font-weight: 500; color: var(--ink); font-size: .89rem; }
.form-control, .form-select { border-color: var(--border); border-radius: var(--radius-sm); }
.form-control::placeholder { color: var(--gray-500); }

.list-group-item { border-color: var(--border); }
.list-group-item-action:hover, .list-group-item-action:focus { background: var(--surface-alt); }
.list-group-item.active, .list-group-item-action.active { background: var(--teal-dark); border-color: var(--teal-dark); }

.progress { background-color: var(--gray-100); border-radius: 999px; }
.progress-bar { border-radius: 999px; }
.dropdown-menu { border-color: var(--border); box-shadow: var(--shadow); border-radius: var(--radius); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-alt); }
.dropdown-item.active, .dropdown-item:active { background: var(--teal-dark); }

.nav-pills .nav-link { color: var(--ink-soft); font-weight: 500; }
.nav-pills .nav-link.active { background-color: var(--teal-dark); color: #fff; }

.member-panel { max-width: 720px; }
.member-panel-wide { max-width: 960px; }
.form-panel { max-width: 820px; }

/* ---------------------------------------------------------------------
   Buttons — teal is the primary action color, matching Ironsafe brand
   --------------------------------------------------------------------- */
.btn { border-radius: var(--radius-sm); font-weight: 500; }

.btn-primary {
  --bs-btn-bg: var(--teal-dark);
  --bs-btn-border-color: var(--teal-dark);
  --bs-btn-hover-bg: var(--teal);
  --bs-btn-hover-border-color: var(--teal);
  --bs-btn-active-bg: var(--teal-dark);
  --bs-btn-active-border-color: var(--teal-dark);
  --bs-btn-color: #fff;
  --bs-btn-disabled-bg: var(--teal-dark);
  --bs-btn-disabled-border-color: var(--teal-dark);
}
.btn-outline-primary {
  --bs-btn-color: var(--teal-dark);
  --bs-btn-border-color: var(--teal);
  --bs-btn-hover-bg: var(--teal-dark);
  --bs-btn-hover-border-color: var(--teal-dark);
  --bs-btn-active-bg: var(--teal-dark);
  --bs-btn-active-border-color: var(--teal-dark);
}
.btn-secondary, .btn-outline-secondary {
  --bs-btn-color: var(--gray-600);
  --bs-btn-border-color: var(--gray-300);
  --bs-btn-hover-bg: var(--gray-600);
  --bs-btn-hover-border-color: var(--gray-600);
  --bs-btn-active-bg: var(--gray-600);
}
.btn-success { --bs-btn-bg: var(--forest); --bs-btn-border-color: var(--forest); --bs-btn-hover-bg: #039855; --bs-btn-hover-border-color: #039855; }
.btn-outline-danger { --bs-btn-color: var(--brick-dark); --bs-btn-border-color: var(--brick-dark); --bs-btn-hover-bg: var(--brick-dark); --bs-btn-hover-border-color: var(--brick-dark); }
.btn-warning { --bs-btn-bg: var(--amber); --bs-btn-border-color: var(--amber); --bs-btn-color: #fff; }
.btn-light { --bs-btn-bg: var(--gray-100); --bs-btn-border-color: var(--border); --bs-btn-color: var(--ink); }

/* ---------------------------------------------------------------------
   Badges & alerts
   --------------------------------------------------------------------- */
.bg-primary   { background-color: var(--teal-dark) !important; }
.bg-success   { background-color: var(--forest) !important; }
.bg-danger    { background-color: var(--brick-dark) !important; }
.bg-warning   { background-color: var(--amber) !important; color: #fff !important; }
.bg-info      { background-color: var(--indigo) !important; }
.bg-secondary { background-color: var(--gray-500) !important; }
.bg-dark      { background-color: var(--gray-900) !important; }

.text-primary { color: var(--teal-dark) !important; }
.text-success { color: var(--forest) !important; }
.text-danger  { color: var(--brick-dark) !important; }
.text-warning { color: #B54708 !important; }
.text-info    { color: var(--indigo) !important; }

.alert { border-radius: var(--radius); border: 1px solid transparent; }
.alert-success { background: var(--forest-soft); border-color: #ABEFC6; color: #05603A; }
.alert-danger  { background: var(--brick-soft); border-color: #FECDCA; color: #912018; }
.alert-warning { background: var(--amber-soft); border-color: #FEDF89; color: #93370D; }
.alert-info    { background: var(--indigo-soft); border-color: #D1C6EA; color: #362757; }

/* ---------------------------------------------------------------------
   Receipts
   --------------------------------------------------------------------- */
.receipt-box {
  max-width: 480px;
  margin: 20px auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  background: var(--surface);
  font-family: var(--font-body);
  box-shadow: var(--shadow);
}
.receipt-box img.receipt-logo { height: 34px; margin-bottom: 8px; }

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 767px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .content-body { padding: 14px; }
  .stat-value { font-size: 1.2rem !important; }
  .topbar { padding: 12px 16px; }
}

@media print {
  .sidebar, .topbar, .no-print, .sidebar-backdrop { display: none !important; }
  .main-content { margin-left: 0 !important; }
  body { background: #fff; }
}
