/* ==========================================================================
   RankSecure CRM — Unified Design System v5.0
   Single source of truth for tokens, typography, spacing & components
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800;0,14..32,900;1,14..32,400;1,14..32,500&display=swap');

:root {
  /* ── Brand: Chocolate Brown primary / Caramel-Honey accent ─────────── */
  --brand-50:  #FBF6EE;
  --brand-100: #F3E7D4;
  --brand-200: #E6CFAA;
  --brand-300: #D5AE76;
  --brand-400: #B9854A;
  --brand-500: #7A4E24;
  --brand-600: #6B421E;
  --brand-700: #573619;
  --brand-800: #432913;
  --brand-900: #2E1C0C;

  /* Golden Honey accent (used sparingly) */
  --gold-300: #F2D9A6;
  --gold-400: #EAC684;
  --gold-500: #E0AC55;
  --gold-600: #C98F3E;
  --gold-700: #A8732E;
  --gold-tint: rgba(224, 172, 85, 0.14);
  --gold-glow: rgba(224, 172, 85, 0.24);
  --gold-amber: #D99A2B;

  --primary: #7A4E24;
  --primary-hover: #6B421E;
  --primary-soft: rgba(122, 78, 36, 0.10);
  --primary-light: rgba(122, 78, 36, 0.08);
  --accent: #C98F3E;
  --accent-hover: #A8732E;
  --accent-soft: rgba(201, 143, 62, 0.16);

  /* Legacy aliases (chocolate, not maroon) */
  --maroon-500: #7A4E24;
  --maroon-600: #6B421E;
  --maroon-700: #573619;
  --maroon-900: #2E1C0C;

  /* ── Accent story (warm organic) ───────────────────────────────────── */
  --raspberry: #A8405A;
  --raspberry-soft: rgba(168, 64, 90, 0.12);
  --green-fresh: #5F7E4C;
  --green-fresh-soft: rgba(95, 126, 76, 0.12);
  --berry-purple: #7C5C7F;
  --berry-purple-soft: rgba(124, 92, 127, 0.12);

  /* ── Neutrals (warm-toned) ─────────────────────────────────────────── */
  --gray-50:  #FDFBF7;
  --gray-100: #F7F1E7;
  --gray-200: #EFE6D7;
  --gray-300: #DDCFB8;
  --gray-400: #B3A68D;
  --gray-500: #8A7C63;
  --gray-600: #5F5440;
  --gray-700: #463D2E;
  --gray-800: #2E2920;
  --gray-900: #221E17;

  --ink-900: #2B2419;
  --ink-700: #463D2E;
  --ink-500: #6B6050;
  --ink-400: #9C907A;
  --ink-300: #CFC4AE;
  --text-main: #2B2419;
  --text-secondary: #5F5440;
  --text-muted: #9C907A;

  /* ── Surfaces (warm cream canvas) ──────────────────────────────────── */
  --bg-base:    #FBF6EE;
  --bg-surface: #FFFFFF;
  --bg-muted:   #F7F1E7;
  --bg-warm:    #F8F1E4;
  --card-bg:    #FFFFFF;
  --cream-100:  #FFFDF9;
  --cream-200:  #F8F1E4;
  --cream-300:  #F0E6D2;

  /* ── Borders ───────────────────────────────────────────────────────── */
  --line:        #EADFC9;
  --line-soft:   #F1E8D8;
  --line-strong: #D6C7AC;
  --border-color: #EADFC9;
  --border-focus: #C98F3E;

  /* ── Semantic ──────────────────────────────────────────────────────── */
  --success: #4E7A45;
  --success-soft: rgba(78, 122, 69, 0.12);
  --danger: #B4545A;
  --danger-soft: rgba(180, 84, 90, 0.12);
  --warning: #D99A2B;
  --warning-soft: rgba(217, 154, 43, 0.16);
  --info: #7C5C7F;
  --info-soft: rgba(124, 92, 127, 0.12);

  /* ── Typography scale ──────────────────────────────────────────────── */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-heading: var(--font-sans);
  --font-body: var(--font-sans);
  --font-family: var(--font-sans);

  --text-xs:   0.75rem;   /* 12px — labels */
  --text-sm:   0.8125rem; /* 13px — small text */
  --text-base: 0.875rem;  /* 14px — body */
  --text-md:   1rem;      /* 16px — card headings */
  --text-lg:   1.0625rem; /* 17px */
  --text-xl:   1.375rem;  /* 22px — section titles */
  --text-2xl:  2rem;      /* 32px — page titles */
  --text-3xl:  2.5rem;    /* 40px */

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --leading-tight:  1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.6;

  /* ── Spacing scale (4px base) ──────────────────────────────────────── */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-7:  28px;
  --space-8:  32px;
  --space-9:  40px;
  --space-10: 48px;

  /* ── Radii (soft, organic) ─────────────────────────────────────────── */
  --radius-xs:  10px;
  --radius-sm:  14px;
  --radius-md:  18px;
  --radius-lg:  22px;
  --radius-xl:  26px;
  --radius-2xl: 30px;
  --radius-3xl: 36px;
  --radius-full: 9999px;
  --radius-input: 16px;
  --radius-button: 9999px;
  --radius-card: 24px;
  --radius-pill: 50px;

  /* ── Shadows (soft, warm, layered) ─────────────────────────────────── */
  --shadow-xs: 0 1px 3px rgba(67, 41, 19, 0.05);
  --shadow-sm: 0 2px 6px rgba(67, 41, 19, 0.06);
  --shadow-md: 0 6px 18px rgba(67, 41, 19, 0.08);
  --shadow-lg: 0 12px 32px rgba(67, 41, 19, 0.10);
  --shadow-xl: 0 20px 48px rgba(67, 41, 19, 0.12);
  --shadow-gold: 0 6px 20px rgba(122, 78, 36, 0.16);
  --shadow-card: 0 6px 22px rgba(67, 41, 19, 0.06);
  --shadow-card-hover: 0 16px 40px rgba(67, 41, 19, 0.12);
  --shadow-focus: 0 0 0 3px rgba(201, 143, 62, 0.22);

  /* ── Layout ────────────────────────────────────────────────────────── */
  --sidebar-width: 236px;
  --navbar-height: 56px;
  --content-max-width: 1440px;

  /* ── Sidebar ───────────────────────────────────────────────────────── */
  --sidebar-bg: #FFFFFF;
  --sidebar-header-bg: #FFFFFF;
  --sidebar-text: #463D2E;
  --sidebar-text-muted: #9C907A;
  --sidebar-hover-bg: #F7F1E7;
  --sidebar-active-bg: rgba(201, 143, 62, 0.16);
  --sidebar-active-text: #7A4E24;
  --sidebar-border: #EFE6D7;

  /* ── Motion ────────────────────────────────────────────────────────── */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.2, 0.64, 1);
  --transition-fast: 150ms var(--ease-out);
  --transition-smooth: 220ms var(--ease-out);
  --transition-premium: 280ms var(--ease-spring);
}

/* ── Reset & Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: var(--leading-normal);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  letter-spacing: -0.006em;
}

h1, h2, h3, h4, h5, h6,
.greeting-title, .brand-title, .page-title {
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: var(--leading-tight);
  color: var(--ink-900);
}

p { margin-top: 0; margin-bottom: var(--space-3); }

/* Font Awesome must keep its own font-family */
.fa, .fas, .far, .fab, .fa-solid, .fa-regular, .fa-brands,
.fa::before, .fas::before, .far::before, .fab::before,
.fa-solid::before, .fa-regular::before, .fa-brands::before {
  font-family: 'Font Awesome 6 Free', 'Font Awesome 6 Brands', 'FontAwesome' !important;
}

/* ── Scrollbars ─────────────────────────────────────────────────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(122, 78, 36, 0.28) transparent;
}

*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(122, 78, 36, 0.20);
  border-radius: var(--radius-full);
}
*::-webkit-scrollbar-thumb:hover { background: rgba(122, 78, 36, 0.34); }

/* ── Reduced Motion ─────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   BOOTSTRAP OVERRIDES — consistent with RankSecure brand
   ========================================================================== */

.text-secondary { color: var(--text-secondary) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-dark { color: var(--ink-900) !important; }

.fw-semibold { font-weight: 600 !important; }

/* Buttons */
.btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--text-sm);
  letter-spacing: -0.01em;
  border-radius: var(--radius-button);
  padding: 0.5rem 1.125rem;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #FFFFFF;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--line-strong);
  color: var(--ink-700);
}
.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--ink-900);
}

.btn-outline-primary {
  color: var(--primary);
  border-color: rgba(122, 78, 36, 0.35);
}
.btn-outline-primary:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-sm {
  font-size: var(--text-xs);
  padding: 0.375rem 0.875rem;
  border-radius: var(--radius-sm);
}

/* Forms */
.form-control, .form-select {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--ink-900);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-input);
  padding: 0.5625rem 0.875rem;
  background-color: var(--bg-surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus, .form-select:focus {
  border-color: var(--brand-500);
  box-shadow: var(--shadow-focus);
}

.form-control::placeholder { color: var(--ink-400); }

.form-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink-700);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}

/* Tables */
.table {
  font-size: var(--text-sm);
  color: var(--ink-900);
  --bs-table-bg: transparent;
}

.table > :not(caption) > * > * {
  padding: var(--space-3) var(--space-4);
  border-bottom-color: var(--line-soft);
}

.table thead th {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--line);
}

.table-hover > tbody > tr:hover > * {
  background-color: #FBF6EE;
}

/* Cards & Modals */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
}

.modal-content {
  border: 1px solid var(--line);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
}

.modal-header {
  border-bottom-color: var(--line-soft);
  padding: var(--space-6) var(--space-7) var(--space-5);
}

.modal-body { padding: var(--space-6) var(--space-7); }
.modal-footer {
  border-top-color: var(--line-soft);
  padding: var(--space-5) var(--space-7) var(--space-6);
}

/* Badges */
.badge {
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: var(--radius-full);
  padding: 0.3em 0.65em;
}

.bg-amber-soft {
  background: var(--primary-soft) !important;
  color: var(--primary) !important;
}

/* Dropdowns */
.dropdown-menu {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
}

.dropdown-item {
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
}

.dropdown-item:hover {
  background: var(--sidebar-hover-bg);
  color: var(--ink-900);
}

/* Alerts */
.alert {
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  border: 1px solid transparent;
}

/* ==========================================================================
   SHARED COMPONENTS
   ========================================================================== */

/* Page header pattern */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.03em;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: var(--space-1) 0 0;
  max-width: 56ch;
}

/* Control bar — search + filters */
.control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-xs);
}

/* Standard search input */
.search-field {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-field .search-icon {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-400);
  font-size: var(--text-sm);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  height: 42px;
  padding: 0 var(--space-4) 0 2.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-full);
  background: var(--gray-50);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--ink-900);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.search-field input:focus {
  background: var(--bg-surface);
  border-color: var(--brand-500);
  box-shadow: var(--shadow-focus);
}

/* Primary action button */
.btn-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-5);
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-button);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.btn-brand:hover {
  background: var(--primary-hover);
  color: #FFFFFF;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-maroon-gradient {
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--text-sm);
  letter-spacing: -0.01em;
  border-radius: var(--radius-button);
  transition: all var(--transition-fast);
}

.btn-maroon-gradient:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  color: #FFFFFF;
}

/* Data card wrapper */
.data-card {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.data-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--line-soft);
}

.data-card-body { padding: var(--space-5) var(--space-6); }

/* Stat card (dashboard) */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-card);
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth), border-color var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(201, 143, 62, 0.35);
}

/* Focus visible */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}

/* Sidebar mobile overlay */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99;
  opacity: 0;
  transition: opacity var(--transition-smooth);
}

.sidebar-backdrop.show {
  display: block;
  opacity: 1;
}

/* Utility spacing helpers */
.gap-section { margin-bottom: var(--space-8); }
.gap-block { margin-bottom: var(--space-6); }
.gap-element { margin-bottom: var(--space-4); }
