/* ============================================================
   PEAKFLOW CRM PORTAL — Stylesheet
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

:root {
  --navy:        #08244A;
  --navy-deep:   #051833;
  --blue:        #1E73BE;
  --orange:      #F47B20;
  --orange-dark: #d96a10;
  --silver:      #B0B8C1;
  --gray:        #6B7280;
  --light:       #F4F6F9;
  --white:       #FFFFFF;
  --text:        #1a2535;
  --border:      #DDE1E7;

  --font-h: 'Barlow Condensed', sans-serif;
  --font-b: 'Source Sans 3', sans-serif;

  --radius:    4px;
  --radius-lg: 8px;
  --shadow-sm: 0 2px 12px rgba(8,36,74,0.07);
  --shadow-md: 0 8px 32px rgba(8,36,74,0.12);
}

body { font-family: var(--font-b); font-size: 1rem; line-height: 1.6; color: var(--text); background: var(--light); }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ---- Utilities ---- */
.hidden { display: none !important; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.25rem; border-radius: var(--radius);
  font-family: var(--font-h); font-size: 1rem; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary  { background: var(--orange); color: #fff; }
.btn-primary:hover  { background: var(--orange-dark); }
.btn-secondary { background: var(--navy); color: #fff; }
.btn-secondary:hover { background: var(--navy-deep); }
.btn-ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--border); }
.btn-ghost:hover { border-color: var(--navy); }
.btn-sm   { padding: .35rem .85rem; font-size: .875rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Form fields ---- */
.field { display: flex; flex-direction: column; gap: .35rem; }
.field label { font-size: .875rem; font-weight: 600; color: var(--navy); }
.field input, .field select, .field textarea {
  padding: .6rem .85rem; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-family: var(--font-b); font-size: .95rem;
  background: #fff; color: var(--text); transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--blue);
}

/* ---- Status badges ---- */
.badge {
  display: inline-block; padding: .2rem .65rem; border-radius: 99px;
  font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
}
.badge-new       { background: #dbeafe; color: #1d4ed8; }
.badge-inspected { background: #fef9c3; color: #854d0e; }
.badge-quoted    { background: #ede9fe; color: #6d28d9; }
.badge-won       { background: #dcfce7; color: #166534; }
.badge-lost      { background: #fee2e2; color: #991b1b; }

/* ---- Login page ---- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--navy-deep);
}
.login-card {
  background: #fff; border-radius: var(--radius-lg); padding: 2.5rem 2rem;
  width: 100%; max-width: 380px; box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; gap: 1.75rem;
}
.login-logo { text-align: center; }
.logo-text { font-family: var(--font-h); font-size: 2rem; font-weight: 800; letter-spacing: 2px; color: var(--navy); }
.logo-accent { color: var(--orange); }
.logo-sub { display: block; font-size: .8rem; letter-spacing: 2px; text-transform: uppercase; color: var(--gray); margin-top: .25rem; }
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.login-error { font-size: .875rem; color: #dc2626; }

/* ---- App shell ---- */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--navy); color: #fff; height: 60px;
  display: flex; align-items: center; padding: 0 1.5rem; gap: 1rem;
}
.header-logo { font-family: var(--font-h); font-size: 1.4rem; font-weight: 800; letter-spacing: 1px; }
.header-logo span { color: var(--orange); }
.header-spacer { flex: 1; }
.header-user { font-size: .875rem; color: var(--silver); }
.header-logout { font-size: .8rem; color: var(--silver); text-decoration: underline; cursor: pointer; }
.header-logout:hover { color: #fff; }

.app-content { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
@media (min-width: 768px) { .app-content { padding: 2rem; } }

/* ---- Toolbar ---- */
.toolbar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.toolbar-title { font-family: var(--font-h); font-size: 1.5rem; font-weight: 700; color: var(--navy); flex: 1; }
.search-input {
  padding: .5rem .85rem; border: 1.5px solid var(--border); border-radius: var(--radius);
  font-family: var(--font-b); font-size: .9rem; width: 220px;
}
.search-input:focus { outline: none; border-color: var(--blue); }

/* ---- Filter tabs ---- */
.filter-tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filter-tab {
  padding: .35rem .9rem; border-radius: 99px; font-size: .85rem; font-weight: 600;
  border: 1.5px solid var(--border); color: var(--gray); cursor: pointer; transition: all .15s;
}
.filter-tab:hover { border-color: var(--navy); color: var(--navy); }
.filter-tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---- Leads table ---- */
.leads-table-wrap { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--light); padding: .75rem 1rem; text-align: left; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--gray); }
td { padding: .85rem 1rem; border-top: 1px solid var(--border); font-size: .9rem; }
tr:hover td { background: #f8fafc; cursor: pointer; }
.leads-empty { text-align: center; padding: 3rem; color: var(--gray); font-size: .95rem; }

/* Mobile: cards instead of table */
@media (max-width: 640px) {
  .leads-table-wrap table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tr { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .75rem; padding: .75rem 1rem; background: #fff; }
  td { border: none; padding: .25rem 0; font-size: .9rem; }
  td::before { content: attr(data-label); font-weight: 700; font-size: .75rem; text-transform: uppercase; color: var(--gray); margin-right: .5rem; }
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5,24,51,.5); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal {
  background: #fff; border-radius: var(--radius-lg); padding: 2rem;
  width: 100%; max-width: 480px; box-shadow: var(--shadow-md);
  max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.modal-title { font-family: var(--font-h); font-size: 1.4rem; font-weight: 700; color: var(--navy); }
.modal-close { font-size: 1.4rem; color: var(--gray); cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-form { display: flex; flex-direction: column; gap: 1rem; }
.modal-footer { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }

/* ---- Detail panel ---- */
.panel-overlay {
  position: fixed; inset: 0; background: rgba(5,24,51,.4); z-index: 200;
  display: flex; justify-content: flex-end;
}
.panel {
  background: #fff; width: 100%; max-width: 500px; height: 100%;
  overflow-y: auto; padding: 2rem 1.5rem; box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; gap: 1.5rem;
}
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; }
.panel-name { font-family: var(--font-h); font-size: 1.6rem; font-weight: 700; color: var(--navy); }
.panel-close { font-size: 1.5rem; color: var(--gray); cursor: pointer; }
.panel-close:hover { color: var(--text); }
.panel-section { display: flex; flex-direction: column; gap: .75rem; }
.panel-section-title { font-family: var(--font-h); font-size: 1rem; font-weight: 700; color: var(--gray); text-transform: uppercase; letter-spacing: .5px; }
.info-row { display: flex; gap: .5rem; font-size: .9rem; }
.info-label { font-weight: 600; color: var(--gray); min-width: 100px; }

/* ---- Quote calculator ---- */
.quote-calc { background: var(--light); border-radius: var(--radius); padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.quote-total { font-family: var(--font-h); font-size: 1.75rem; font-weight: 800; color: var(--navy); text-align: right; }
.quote-total span { color: var(--orange); }

/* ---- Quote history ---- */
.quote-history-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: .6rem 0; border-bottom: 1px solid var(--border); font-size: .875rem;
}
.quote-history-item:last-child { border-bottom: none; }

/* ---- Loading spinner ---- */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Toast notifications ---- */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 999;
  background: var(--navy); color: #fff; padding: .85rem 1.25rem; border-radius: var(--radius);
  font-size: .9rem; box-shadow: var(--shadow-md); animation: fadeIn .2s ease;
}
.toast.success { background: #166534; }
.toast.error   { background: #991b1b; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
