/* ==========================================================================
   Project: Vanilla PHP CRM - A Modern, Framework-Free Design System
   ========================================================================== */

/* 1) Tokens & Theming ---------------------------------------------------- */
:root {
  /* Colors */
  --brand-500: #4f46e5; --brand-600: #4338ca; --brand-700: #3730a3;
  --ink-50: #f8fafc; --ink-100: #f1f5f9; --ink-200: #e2e8f0; --ink-300: #cbd5e1;
  --ink-400: #94a3b8; --ink-500: #64748b; --ink-600: #475569; --ink-700: #334155;
  --ink-800: #1e293b; --ink-900: #0f172a;
  --green-50: #f0fdf4; --green-500: #22c55e; --green-700: #15803d;
  --amber-50: #fffbeb; --amber-500: #f59e0b; --amber-700: #b45309;
  --red-50: #fef2f2; --red-500: #ef4444; --red-700: #b91c1c;
  --slate-50: #f8fafc; --slate-500: #64748b; --slate-700: #334155;

  /* Light Theme */
  --bg: var(--ink-50);
  --surface: #ffffff;
  --border: var(--ink-200);
  --text: var(--ink-800);
  --muted: var(--ink-500);
  --link: var(--brand-600);
  --accent: var(--brand-600);
  --accent-contrast: #ffffff;

  /* Spacing & Radii */
  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem;
  --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem; --space-12: 3rem;
  --r-sm: .25rem; --r-md: .5rem; --r-lg: .75rem; --r-xl: 1rem; --r-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: .75rem; --fs-sm: .875rem; --fs-base: 1rem; --fs-lg: 1.125rem;
  --fs-xl: 1.25rem; --fs-2xl: 1.5rem; --fs-3xl: 1.875rem; --fs-4xl: 2.25rem;
  --fw-normal: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700;

  /* Transitions */
  --transition: all .2s cubic-bezier(.4,0,.2,1);
}

/* 2) Base & Reset -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font-sans); line-height: 1.6; background-color: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { line-height: 1.2; font-weight: var(--fw-bold); margin-bottom: var(--space-4); }
h1 { font-size: var(--fs-4xl); } h2 { font-size: var(--fs-3xl); } h3 { font-size: var(--fs-2xl); }
p { margin-bottom: var(--space-4); }
a { color: var(--link); text-decoration: none; transition: var(--transition); }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; display: block; }

/* 3) Layout -------------------------------------------------------------- */
.container { max-width: 1280px; margin-left: auto; margin-right: auto; padding-left: var(--space-6); padding-right: var(--space-6); }
.section { padding-top: var(--space-12); padding-bottom: var(--space-12); }

/* 4) Components ---------------------------------------------------------- */

/* Navbar */
.navbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: var(--space-4) 0; box-shadow: var(--shadow-sm); }
.navbar .inner { display: flex; justify-content: space-between; align-items: center; }
.navbar .brand { font-weight: var(--fw-bold); font-size: var(--fs-lg); }
.navbar .nav a { color: var(--muted); font-weight: var(--fw-medium); margin-left: var(--space-4); }
.navbar .nav a:hover { color: var(--text); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; font-weight: var(--fw-semibold); font-size: var(--fs-sm); padding: .6rem 1.2rem; border-radius: var(--r-md); border: 1px solid transparent; cursor: pointer; transition: var(--transition); }
.btn.primary { background: var(--accent); color: var(--accent-contrast); }
.btn.primary:hover { background: var(--brand-700); }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn.ghost:hover { background: var(--ink-50); color: var(--text); }
.btn.sm { padding: .4rem .8rem; font-size: var(--fs-xs); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: var(--space-6); box-shadow: var(--shadow-md); }

/* Forms */
.form .field { margin-bottom: var(--space-4); }
.form label { display: block; font-weight: var(--fw-medium); font-size: var(--fs-sm); margin-bottom: var(--space-2); }
.form .input, .form textarea, .form select { width: 100%; padding: .6rem 1rem; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); transition: var(--transition); }
.form .input:focus, .form textarea:focus, .form select:focus { outline: 2px solid transparent; outline-offset: 2px; border-color: var(--brand-500); box-shadow: 0 0 0 2px var(--brand-500); }
.form textarea { min-height: 120px; resize: vertical; }

/* Tables */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.table th, .table td { padding: var(--space-3) var(--space-4); text-align: left; }
.table thead { border-bottom: 2px solid var(--border); }
.table th { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: var(--fw-semibold); }
.table tbody tr { border-bottom: 1px solid var(--border); }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr:hover { background-color: var(--ink-50); }

/* Alerts */
.alert { padding: var(--space-4); border-radius: var(--r-md); border: 1px solid; margin-bottom: var(--space-4); }
.alert.success { background: var(--green-50); border-color: var(--green-500); color: var(--green-700); }

/* Badges / Pills */
.badge { display: inline-block; padding: .2rem .6rem; font-size: var(--fs-xs); font-weight: var(--fw-semibold); border-radius: var(--r-full); }
.badge.green { background: var(--green-50); color: var(--green-700); }
.badge.amber { background: var(--amber-50); color: var(--amber-700); }
.badge.red { background: var(--red-50); color: var(--red-700); }
.badge.slate { background: var(--slate-50); color: var(--slate-700); }

/* 5) Page-Specific Styles ------------------------------------------------ */

/* Admin Layout */
.admin-layout { display: flex; }
.admin-sidebar { width: 260px; background: var(--surface); border-right: 1px solid var(--border); padding: var(--space-6); height: 100vh; position: fixed; }
.admin-sidebar .brand { font-size: var(--fs-xl); font-weight: var(--fw-bold); margin-bottom: var(--space-8); }
.admin-sidebar nav a { display: block; color: var(--muted); padding: var(--space-2) 0; font-weight: var(--fw-medium); }
.admin-sidebar nav a:hover { color: var(--text); }
.admin-main { margin-left: 260px; padding: var(--space-8); width: calc(100% - 260px); }

/* Leads Inbox */
.leads-inbox .table-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-4); }
.leads-inbox .sla-ok {}
.leads-inbox .sla-warning { background-color: var(--amber-50); }
.leads-inbox .sla-overdue { background-color: var(--red-50); }

/* 6) Utilities ----------------------------------------------------------- */
.mt-4 { margin-top: var(--space-4); }
.text-sm { font-size: var(--fs-sm); }
.text-center { text-align: center; }
.muted { color: var(--muted); }
.d-flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Chapter 5 Additions */
.stack { display: grid; gap: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }

.alert.danger { background: var(--red-50); border-color: var(--red-500); color: var(--red-700); }

.note { padding: var(--space-3); border-left: 4px solid var(--border); }
.note p:last-child { margin-bottom: 0; }

.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--space-6); margin-top: var(--space-8); }