/* ==========================================================================
   BOURGIGROUP — STRIPE-LEVEL DESIGN SYSTEM
   Architecture: Bootstrap 5 base → CSS var overrides → custom layer
   Palette: Indigo primary · Slate text · Blue-gray page · Orange accent
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. BOOTSTRAP 5 CSS VARIABLE OVERRIDES
   These propagate automatically to all Bootstrap components.
   -------------------------------------------------------------------------- */
:root {
  /* Core palette */
  --bs-primary: #4f46e5;
  --bs-primary-rgb: 79, 70, 229;
  --bs-link-color: #4f46e5;
  --bs-link-hover-color: #4338ca;

  /* Body */
  --bs-body-font-family:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bs-body-font-size: 0.875rem;
  --bs-body-line-height: 1.6;
  --bs-body-color: #1e293b;
  --bs-body-bg: #f6f9fc;

  /* Borders */
  --bs-border-color: #e2e8f0;
  --bs-border-radius: 8px;
  --bs-border-radius-sm: 6px;
  --bs-border-radius-lg: 12px;
  --bs-border-radius-xl: 16px;
  --bs-border-radius-pill: 9999px;

  /* Shadows — Stripe's layered, barely-there shadow system */
  --bs-box-shadow-sm:
    0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --bs-box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.04);
  --bs-box-shadow-lg:
    0 10px 15px rgba(0, 0, 0, 0.06), 0 4px 6px rgba(0, 0, 0, 0.04);

  /* Cards */
  --bs-card-border-color: #e2e8f0;
  --bs-card-border-radius: 12px;
  --bs-card-cap-bg: #f8fafc;

  /* Table */
  --bs-table-hover-bg: rgba(248, 250, 252, 0.8);
  --bs-table-border-color: #e2e8f0;

  /* Form */
  --bs-input-bg: #ffffff;
  --bs-input-border-color: #e2e8f0;
  --bs-input-focus-border-color: #a5b4fc;
  --bs-input-focus-box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);

  /* Pagination */
  --bs-pagination-border-color: #e2e8f0;
  --bs-pagination-hover-bg: #eef2ff;
  --bs-pagination-hover-border-color: #c7d2fe;
  --bs-pagination-hover-color: #4f46e5;
  --bs-pagination-active-bg: #4f46e5;
  --bs-pagination-active-border-color: #4f46e5;

  /* Success / Danger */
  --bs-success: #16a34a;
  --bs-success-rgb: 22, 163, 74;
  --bs-danger: #dc2626;
  --bs-danger-rgb: 220, 38, 38;
}

/* --------------------------------------------------------------------------
   2. CUSTOM DESIGN TOKENS
   Used by custom components (gallery, cart badge, shop grid, etc.)
   -------------------------------------------------------------------------- */
:root {
  /* Primary */
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --primary-border: #c7d2fe;

  /* Accent (prices, CTAs) */
  --accent: #f97316;
  --accent-dark: #ea580c;
  --accent-light: #fff7ed;

  /* Semantic */
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #86efac;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fca5a5;
  --warning: #d97706;

  /* Text scale — slate-based, Stripe-inspired */
  --text-1: #0f172a; /* headings */
  --text-2: #1e293b; /* body */
  --text-3: #475569; /* secondary */
  --text-4: #94a3b8; /* muted / placeholder */

  /* Surfaces */
  --page-bg: #f6f9fc;
  --surface: #ffffff;
  --surface-1: #f8fafc;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;

  /* Borders */
  --border: #e2e8f0;
  --border-soft: #f1f5f9;
  --border-focus: #a5b4fc;

  /* Shadows — layered for depth without weight */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.06), 0 4px 6px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.08), 0 8px 10px rgba(0, 0, 0, 0.04);

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-full: 9999px;

  /* Spacing (8px grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Typography */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --text-xs: 0.6875rem; /* 11px */
  --text-sm: 0.75rem; /* 12px */
  --text-base: 0.875rem; /* 14px */
  --text-md: 1rem; /* 16px */
  --text-lg: 1.125rem; /* 18px */
  --text-xl: 1.375rem; /* 22px */
  --text-2xl: 1.75rem; /* 28px */

  /* Transitions */
  --ease: 0.15s ease;
  --ease-md: 0.2s ease;

  /* Layout */
  --navbar-h: 60px;
  --content-max: 1360px;
}

/* --------------------------------------------------------------------------
   3. BASE
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--page-bg);
  color: var(--text-2);
  min-height: 100vh;
}

img,
video {
  display: block;
  max-width: 100%;
}

a {
  color: var(--primary);
  transition: color var(--ease);
}
a:hover {
  color: var(--primary-dark);
}

/* --------------------------------------------------------------------------
   4. NAVBAR
   Bootstrap handles collapse animation — we only style visuals.
   Sticky is on <header> not .navbar to avoid wrapping issues.
   -------------------------------------------------------------------------- */
header {
  position: sticky;
  top: 0;
  z-index: 1000;
}

.navbar {
  background: rgba(255, 255, 255, 0.97) !important;
  border-bottom: 1px solid var(--border) !important;
  box-shadow:
    0 1px 0 var(--border),
    var(--shadow-xs);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding-inline: var(--sp-6) !important;
}

.navbar-brand {
  font-size: var(--text-md) !important;
  font-weight: 700 !important;
  color: var(--primary) !important;
  letter-spacing: -0.5px;
  padding: 0 !important;
}

.navbar-toggler {
  border: 1px solid var(--border) !important;
  border-radius: var(--r-sm) !important;
  padding: 6px 8px !important;
  color: var(--text-3) !important;
  box-shadow: none !important;
  transition:
    background var(--ease),
    border-color var(--ease);
}
.navbar-toggler:hover {
  background: var(--surface-2) !important;
  border-color: var(--border-focus) !important;
}
.navbar-toggler:focus {
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12) !important;
}

.nav-link {
  font-size: var(--text-base) !important;
  font-weight: 500 !important;
  color: var(--text-3) !important;
  padding: 6px 12px !important;
  border-radius: var(--r-sm);
  transition:
    background var(--ease),
    color var(--ease);
}
.nav-link:hover {
  color: var(--primary) !important;
  background: var(--primary-light);
}

/* Cart icon */
.cart-nav-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  text-decoration: none;
  color: var(--text-3);
  transition:
    background var(--ease),
    color var(--ease);
}
.cart-nav-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* Cart badge — tight floating pill */
.cart-badge {
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(30%, -30%);
  background: var(--accent);
  color: #fff;
  font-size: 0.5rem;
  font-weight: 800;
  min-width: 15px;
  height: 15px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 2px solid var(--surface);
  line-height: 1;
}

/* --------------------------------------------------------------------------
   5. BUTTONS — Stripe-level precision
   -------------------------------------------------------------------------- */
.btn {
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: 600;
  border-radius: var(--r-sm);
  transition: all var(--ease);
  letter-spacing: 0;
  min-height: 36px;
}
.btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2) !important;
  outline: none;
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}
.btn-primary:active {
  transform: scale(0.99);
}

.btn-outline-secondary {
  border-color: var(--border);
  color: var(--text-3);
  background: transparent;
}
.btn-outline-secondary:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-1);
}

.btn-outline-danger {
  border-color: var(--danger-border);
  color: var(--danger);
}
.btn-outline-danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-sm {
  min-height: 30px;
  font-size: var(--text-sm);
  padding: 4px 12px;
}

/* --------------------------------------------------------------------------
   6. FORM CONTROLS
   -------------------------------------------------------------------------- */
.form-control,
.form-select {
  font-family: var(--font);
  font-size: var(--text-base);
  color: var(--text-1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition:
    border-color var(--ease),
    box-shadow var(--ease);
  min-height: 36px;
}
.form-control::placeholder {
  color: var(--text-4);
}
.form-control:focus,
.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
  outline: none;
  background: var(--surface);
}

.form-control-sm,
.form-select-sm {
  min-height: 32px;
  font-size: var(--text-sm);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: 6px;
}

/* --------------------------------------------------------------------------
   7. CARDS
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow-sm);
}
.card-body {
  padding: var(--sp-5) var(--sp-6);
}
.card-header,
.card-footer {
  background: var(--surface-1);
  border-color: var(--border);
  padding: var(--sp-3) var(--sp-5);
}

/* table-card: overflow hidden clips the thead top-radius */
.table-card {
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   8. TABLE — Stripe dashboard style
   No outer border on table itself — card provides container.
   Clean horizontal row separators only.
   -------------------------------------------------------------------------- */
.table {
  font-size: var(--text-base);
  color: var(--text-2);
  margin: 0;
}

.table > thead > tr > th {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-4);
  background: var(--surface-1);
  border-bottom: 1px solid var(--border) !important;
  border-top: none;
  padding: 10px 16px;
  white-space: nowrap;
  user-select: none;
  vertical-align: middle;
}

.table > thead > tr > th.sortable {
  cursor: pointer;
}
.table > thead > tr > th.sortable:hover {
  background: var(--surface-2);
  color: var(--text-2);
}

.table > tbody > tr > td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft) !important;
  vertical-align: middle;
  color: var(--text-2);
}

.table > tbody > tr:last-child > td {
  border-bottom: none !important;
}

.table-hover > tbody > tr:hover > td {
  background: var(--surface-1);
}

/* Sort indicator */
.sort-icon {
  display: inline-block;
  width: 10px;
  margin-left: 4px;
  color: var(--primary);
  font-size: 9px;
  vertical-align: middle;
  opacity: 0.8;
}

/* Article image cell */
.td-image {
  width: 52px;
  min-width: 52px;
  padding: 8px 10px !important;
}
.td-image img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   9. BADGES
   -------------------------------------------------------------------------- */
.badge {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--r-full);
  letter-spacing: 0.02em;
}
.badge.bg-secondary {
  background: var(--surface-2) !important;
  color: var(--text-3) !important;
  border: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   10. ALERTS
   -------------------------------------------------------------------------- */
.alert {
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  border: none;
  padding: 10px 14px;
}
.alert-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}
.alert-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

/* --------------------------------------------------------------------------
   11. PAGINATION
   -------------------------------------------------------------------------- */
.pagination {
  gap: 3px;
}
.page-link {
  border-radius: var(--r-sm) !important;
  border: 1px solid var(--border);
  color: var(--text-3);
  font-size: var(--text-sm);
  font-weight: 500;
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--sp-2);
  transition: all var(--ease);
  line-height: 1;
}
.page-link:hover {
  background: var(--primary-light);
  border-color: var(--primary-border);
  color: var(--primary);
}
.page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.page-item.disabled .page-link {
  color: var(--text-4);
  pointer-events: none;
  background: var(--surface-2);
}

/* --------------------------------------------------------------------------
   12. SEARCH WITH ICON
   -------------------------------------------------------------------------- */
.search-icon-wrap {
  position: relative;
}
.search-icon-wrap .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-4);
  font-size: var(--text-sm);
  pointer-events: none;
  line-height: 1;
}
.search-icon-wrap .form-control {
  padding-left: 30px;
}

/* --------------------------------------------------------------------------
   13. FETCH STATE UTILITIES
   -------------------------------------------------------------------------- */
.fetch-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-10) var(--sp-4);
  color: var(--text-4);
  font-size: var(--text-sm);
}
.fetch-loading::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.fetch-error {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-8) var(--sp-4);
  color: var(--danger);
  font-size: var(--text-sm);
  font-weight: 500;
}
.fetch-error::before {
  content: "⚠";
  flex-shrink: 0;
}

.fetch-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-10) var(--sp-4);
  color: var(--text-4);
  font-size: var(--text-sm);
}

/* Inline error banner */
.error-banner {
  display: none;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  border-radius: var(--r-sm);
  font-size: var(--text-sm);
  font-weight: 500;
}
.error-banner.visible {
  display: flex;
}
.error-banner::before {
  content: "⚠";
  flex-shrink: 0;
}

.btn-loading {
  opacity: 0.65;
  cursor: not-allowed;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   14. RESPONSIVE
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  :root {
    --navbar-h: 54px;
  }
  .navbar {
    padding-inline: var(--sp-4) !important;
  }
  main {
    padding: var(--sp-4) var(--sp-3) var(--sp-8);
  }
}

@media (max-width: 480px) {
  .table > thead > tr > th,
  .table > tbody > tr > td {
    padding: 10px 12px;
  }
  .td-image {
    width: 44px;
    min-width: 44px;
    padding: 6px 8px !important;
  }
  .td-image img {
    width: 30px;
    height: 30px;
  }
  .page-link {
    min-width: 28px;
    height: 28px;
    font-size: var(--text-xs);
  }
}
