:root {
  /* Palette inspired by the Metronic admin-theme design language: soft light-gray canvas,
     bordered (not heavy-shadow) white cards, and a vivid primary blue with "light" tinted
     variants used throughout badges/buttons. Colors are tokenized so the dark-mode blocks
     below only need to override the tokens, not every rule that uses them. */
  --brand: #009ef7;
  --brand-dark: #0077c2;
  --brand-light: #f1faff;
  --accent: #50cd89;
  --accent-light: #e8fff3;
  --accent-text: #2b9e5f;
  --danger: #f1416c;
  --danger-light: #fff5f8;
  --warning: #ffc700;
  --warning-light: #fff8dd;
  --warning-text: #a16207;
  --purple: #7239ea;
  --purple-light: #f8f5ff;

  --gray-900: #181c32;
  --gray-700: #3f4254;
  --gray-600: #7e8299;
  --gray-300: #e4e6ef;
  --gray-100: #f5f8fa;

  --surface: #ffffff;
  --bg: #f5f8fa;

  --card-border: var(--gray-300);
  --text-muted: var(--gray-600);

  color-scheme: light;
}

/* Dark palette: same token names, different values. Bootstrap 5.3's own components already
   theme themselves off [data-bs-theme="dark"] on the root; our custom classes below key off
   the same attribute so both systems flip together with one toggle.
   Note: --bg (page) and --surface (cards/sidebar) are independent of --gray-100 here — in
   dark mode the page should be darkest, cards a step lighter, and --gray-100 is reused below
   purely as a "subtle fill" tone (hover states, light badges), so it must sit between the two. */
[data-bs-theme='dark'] {
  --brand: #2fb4ff;
  --brand-dark: #62c6ff;
  --brand-light: #123047;
  --accent: #4fd694;
  --accent-light: #123626;
  --accent-text: #6fe0a4;
  --danger: #f76a94;
  --danger-light: #3a1424;
  --warning: #ffd85e;
  --warning-light: #3a2f0d;
  --warning-text: #ffd85e;
  --purple: #a17bf0;
  --purple-light: #241c3d;

  --gray-900: #f1f1f4;
  --gray-700: #b5b5c3;
  --gray-600: #82828f;
  --gray-300: #2b2f3a;
  --gray-100: #262a34;

  --surface: #1c1f27;
  --bg: #15171c;

  color-scheme: dark;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--gray-700);
}

a { text-decoration: none; }

h1, h2, h3, h4, h5, h6 { color: var(--gray-900); }

/* Bootstrap's own .text-dark is a fixed color, not theme-aware — use this instead
   wherever a heading-weight color needs to flip with dark mode. */
.text-heading { color: var(--gray-900) !important; }
.bg-subtle { background: var(--gray-100) !important; }
.bg-surface { background: var(--surface) !important; }

.navbar-brand {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--purple));
  color: #fff;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: -0.02em;
  margin-right: 8px;
}

/* Landing page */
.hero-section {
  background: linear-gradient(180deg, var(--surface) 0%, var(--brand-light) 100%);
  border-bottom: 1px solid var(--card-border);
}

.hero-badge {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: 999px;
  display: inline-block;
}

.feature-card {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 28px;
  height: 100%;
  background: var(--surface);
  transition: border-color 0.15s ease;
}

.feature-card:hover {
  border-color: var(--brand);
}

.feature-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-light);
  color: var(--brand);
  font-size: 1.3rem;
  margin-bottom: 16px;
}

/* App shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--card-border);
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .nav-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-600);
  padding: 0 14px;
  margin: 18px 0 8px;
}

/* Shared between the desktop sidebar and the mobile offcanvas drawer, which reuse the
   same partials/sidebar_nav.html markup. */
.sidebar .nav-link, .offcanvas-body .nav-link {
  color: var(--gray-700);
  font-weight: 500;
  font-size: 0.925rem;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar .nav-link i, .offcanvas-body .nav-link i { font-size: 1.1rem; width: 20px; text-align: center; color: var(--gray-600); }

.sidebar .nav-link.active, .offcanvas-body .nav-link.active {
  background: var(--brand-light);
  color: var(--brand);
  font-weight: 600;
}

.sidebar .nav-link.active i, .offcanvas-body .nav-link.active i { color: var(--brand); }

.sidebar .nav-link:hover:not(.active), .offcanvas-body .nav-link:hover:not(.active) {
  background: var(--gray-100);
}

.offcanvas, .offcanvas-header {
  background: var(--surface);
  color: var(--gray-700);
}

.offcanvas-header { border-bottom: 1px solid var(--card-border); }

.main-content {
  flex: 1;
  min-width: 0;
  padding: 0 32px 60px;
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 68px;
  border-bottom: 1px solid var(--card-border);
  margin: 0 -32px 28px;
  padding: 0 32px;
  background: var(--surface);
}

.user-menu-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.user-menu-toggle:hover { background: var(--gray-100); }

.theme-toggle-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--card-border);
  background: var(--surface);
  color: var(--gray-600);
  cursor: pointer;
  flex-shrink: 0;
}

.theme-toggle-btn:hover { background: var(--gray-100); color: var(--brand); }

.theme-toggle-fixed { position: fixed; top: 20px; right: 20px; z-index: 1050; }

/* Bootstrap has no responsive button-size utility, so this reverts a .btn-sm back to
   normal padding/font-size once there's room (used on the landing page navbar, which
   would otherwise overflow a phone-width viewport). */
@media (min-width: 576px) {
  .btn-md-normal {
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    border-radius: 8px;
  }
}

.var-row-label { width: 44px; flex-shrink: 0; }
.var-row-field { flex: 1 1 180px; max-width: 220px; }

@media (max-width: 480px) {
  .var-row-field { max-width: none; flex-basis: 100%; }
}

.symbol {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-light);
  color: var(--brand);
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 28px;
  padding-bottom: 20px;
  margin-bottom: 8px;
  border-bottom: 1px dashed var(--card-border);
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
  color: var(--gray-900);
}

.card {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: none;
}

.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--card-border);
  font-weight: 600;
  color: var(--gray-900);
  padding: 16px 20px;
}

.card-body { padding: 20px; }

.card-soft { box-shadow: none; }

.stat-card {
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--surface);
  padding: 22px;
}

.stat-card .stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--gray-900);
}

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

.btn { border-radius: 8px; font-weight: 500; }

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

.btn-brand:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}

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

.btn-whatsapp:hover {
  background: #3cb873;
  border-color: #3cb873;
  color: #fff;
}

/* "Light" tinted buttons — a signature Metronic pattern: soft background, colored text,
   solidifying only on hover. Used for secondary/icon actions instead of plain outlines. */
.btn-light-primary { background: var(--brand-light); border-color: transparent; color: var(--brand); }
.btn-light-primary:hover { background: var(--brand); color: #fff; }

.btn-light-secondary { background: var(--gray-100); border-color: transparent; color: var(--gray-700); }
.btn-light-secondary:hover { background: var(--gray-300); color: var(--gray-900); }

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

/* "Light" badges — tinted background + colored text instead of solid fills. */
.badge { font-weight: 600; padding: 0.45em 0.85em; border-radius: 6px; font-size: 0.75rem; }
.badge-light-primary { background: var(--brand-light); color: var(--brand); }
.badge-light-success { background: var(--accent-light); color: var(--accent-text); }
.badge-light-danger { background: var(--danger-light); color: var(--danger); }
.badge-light-warning { background: var(--warning-light); color: var(--warning-text); }
.badge-light-secondary { background: var(--gray-100); color: var(--gray-600); }
.badge-light-purple { background: var(--purple-light); color: var(--purple); }

.badge-status-draft { background: var(--gray-100); color: var(--gray-600); }
.badge-status-sent { background: var(--accent-light); color: var(--accent-text); }
.badge-status-failed { background: var(--danger-light); color: var(--danger); }

.offer-photo-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 8px;
  background: var(--gray-100);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 2.4rem;
  color: var(--gray-300);
  margin-bottom: 12px;
  display: block;
}

/* Dashed-row tables — another signature Metronic pattern, replacing solid horizontal
   borders with light dashed rules and uppercase, letter-spaced header labels. */
.table-metronic { margin-bottom: 0; }
.table-metronic thead th {
  border-bottom: 1px dashed var(--card-border);
  border-top: none;
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--gray-600);
  background: transparent;
  padding: 12px 16px;
}
.table-metronic tbody td {
  border-bottom: 1px dashed var(--card-border);
  padding: 14px 16px;
  vertical-align: middle;
}
.table-metronic tbody tr:last-child td { border-bottom: none; }

.table > :not(caption) > * > * {
  padding: 12px 14px;
}

.form-control, .form-select {
  border-radius: 8px;
  border-color: var(--card-border);
}

.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 0.2rem rgba(0, 158, 247, 0.12);
}

.form-label { font-weight: 500; color: var(--gray-700); font-size: 0.9rem; }

.auth-card {
  max-width: 440px;
  margin: 60px auto;
  border-radius: 12px;
}

/* Sidebar visibility itself is handled by Bootstrap's d-none/d-lg-flex utilities on the
   element (see app_base.html) so it hides in lockstep with when the mobile drawer's
   hamburger trigger appears - this block only covers spacing/sizing adjustments. */
@media (max-width: 991.98px) {
  .main-content { padding: 0 16px 32px; }
  .header-bar { margin: 0 -16px 16px; padding: 0 16px; height: 60px; }
  .topbar { padding-top: 20px; padding-bottom: 16px; flex-wrap: wrap; gap: 12px; }
  .page-title { font-size: 1.2rem; }
}

@media (max-width: 575.98px) {
  .main-content { padding: 0 12px 28px; }
  .header-bar { margin: 0 -12px 14px; padding: 0 12px; }
  .card-body { padding: 16px; }
  .card-header { padding: 14px 16px; }
  .stat-card { padding: 16px; }
  .stat-card .stat-value { font-size: 1.5rem; }
}
