/* FSM — Field Service Management — shared application styles */
/* =========================================================== */

/* CSS Variables */
:root {
  --fl:      #16a34a;
  --fl-d:    #15803d;
  --fl-l:    #dcfce7;
  --fl-text: #14532d;
  --sidebar-w: 234px;
  --topbar-h:  54px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  background: #f8fafc;
  margin: 0;
  color: #0f172a;
}

/* ── Sidebar ─────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: #fff;
  border-right: 1px solid #e8edf2;
  position: fixed; top: 0; left: 0; z-index: 100;
  display: flex; flex-direction: column;
  transition: transform .25s ease;
}
.sb-brand {
  padding: 16px 14px 13px;
  border-bottom: 1px solid #f1f5f9;
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
}
.sb-brand-name { font-size: 15px; font-weight: 700; color: #0f172a; letter-spacing: -.2px; }
.sb-brand-sub  { font-size: 9.5px; color: #94a3b8; letter-spacing: .4px; font-weight: 500; margin-top: 1px; }
.sb-nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.nav-sec {
  font-size: 9.5px; font-weight: 600; color: #cbd5e1;
  text-transform: uppercase; letter-spacing: .6px;
  padding: 10px 8px 4px; margin-top: 2px;
}
.nav-sec:first-child { margin-top: 0; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: 7px;
  color: #475569; font-size: 13px; font-weight: 500;
  text-decoration: none; margin-bottom: 1px;
  transition: background .12s, color .12s;
}
.nav-item i { font-size: 14px; width: 17px; text-align: center; flex-shrink: 0; }
.nav-item:hover   { background: #f8fafc; color: #0f172a; }
.nav-item.active  { background: #f0fdf4; color: var(--fl); font-weight: 600; }
.nav-item .badge  { margin-left: auto; font-size: 10px; padding: 2px 6px; }
.sb-user {
  padding: 11px 13px; border-top: 1px solid #f1f5f9;
  display: flex; align-items: center; gap: 9px;
}
.u-av {
  width: 30px; height: 30px; border-radius: 50%;
  background: #f0fdf4; color: var(--fl);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; flex-shrink: 0;
  border: 1.5px solid #dcfce7;
}
.u-name { font-size: 12px; font-weight: 600; color: #0f172a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-role { font-size: 10px; color: #94a3b8; text-transform: capitalize; }

/* ── Main content ────────────────────────────────── */
#main { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar {
  height: var(--topbar-h);
  background: #fff; border-bottom: 1px solid #e8edf2;
  display: flex; align-items: center; padding: 0 22px;
  position: sticky; top: 0; z-index: 50; gap: 12px;
}
.topbar-title { font-size: 14px; font-weight: 600; color: #0f172a; flex: 1; }
.page-body { padding: 24px 28px; }

/* ── Cards ───────────────────────────────────────── */
.card {
  background: #fff; border: 1px solid #e8edf2;
  border-radius: 12px; overflow: hidden;
}
.card-header {
  padding: 13px 18px; border-bottom: 1px solid #f1f5f9;
  display: flex; align-items: center; gap: 10px;
  background: #fff;
}
.card-header-title { font-size: 13px; font-weight: 600; color: #0f172a; flex: 1; }
.card-body { padding: 18px; }

/* ── Stat cards ──────────────────────────────────── */
.stat-card {
  background: #fff; border: 1px solid #e8edf2;
  border-radius: 12px; padding: 18px 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-label { font-size: 11px; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: .5px; }
.stat-val   { font-size: 26px; font-weight: 700; color: #0f172a; line-height: 1.1; }
.stat-sub   { font-size: 12px; color: #64748b; }
.stat-icon  {
  width: 38px; height: 38px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; margin-bottom: 8px;
}

/* ── Tables ──────────────────────────────────────── */
.fl-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fl-table thead th {
  padding: 9px 14px; font-size: 10px; font-weight: 600;
  color: #94a3b8; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid #f1f5f9; white-space: nowrap; background: #fff;
}
.fl-table tbody td { padding: 12px 14px; border-bottom: 1px solid #f8fafc; vertical-align: middle; color: #334155; }
.fl-table tbody tr:hover td { background: #fafbfc; }
.fl-table tbody tr:last-child td { border-bottom: none; }

/* ── Status badges ───────────────────────────────── */
.status-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-new        { background: #dbeafe; color: #1d4ed8; }
.badge-pending    { background: #fef9c3; color: #854d0e; }
.badge-contacted  { background: #fef9c3; color: #854d0e; }
.badge-converted  { background: #dcfce7; color: #15803d; }
.badge-accepted   { background: #dcfce7; color: #15803d; }
.badge-active     { background: #dcfce7; color: #15803d; }
.badge-signed     { background: #dcfce7; color: #15803d; }
.badge-completed  { background: #d1fae5; color: #065f46; }
.badge-lost       { background: #fee2e2; color: #b91c1c; }
.badge-cancelled  { background: #fee2e2; color: #b91c1c; }
.badge-declined   { background: #fee2e2; color: #b91c1c; }
.badge-inactive   { background: #f1f5f9; color: #64748b; }
.badge-draft      { background: #f1f5f9; color: #64748b; }
.badge-planned    { background: #ede9fe; color: #5b21b6; }
.badge-scheduled  { background: #ede9fe; color: #5b21b6; }
.badge-in_progress{ background: #fef3c7; color: #92400e; }
.badge-trial      { background: #f1f5f9; color: #64748b; }
.badge-starter    { background: #dbeafe; color: #1d4ed8; }
.badge-pro        { background: #dcfce7; color: #15803d; }
.badge-sent       { background: #dbeafe; color: #1d4ed8; }

/* ── Forms ───────────────────────────────────────── */
.form-label { font-size: 12px; font-weight: 600; color: #374151; margin-bottom: 4px; }
.form-control, .form-select {
  font-size: 13px; border-radius: 8px;
  padding: 9px 12px; border: 1px solid #e2e8f0;
  transition: border-color .15s, box-shadow .15s;
  color: #0f172a;
}
.form-control:focus, .form-select:focus {
  border-color: var(--fl);
  box-shadow: 0 0 0 3px rgba(22,163,74,.1);
  outline: none;
}
.form-text { font-size: 11px; color: #64748b; }
textarea.form-control { resize: vertical; }

/* ── Buttons ─────────────────────────────────────── */
.btn-fl {
  background: var(--fl); color: #fff; border: none;
  border-radius: 8px; padding: 9px 18px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s; display: inline-flex;
  align-items: center; gap: 6px; text-decoration: none;
}
.btn-fl:hover { background: var(--fl-d); color: #fff; }
.btn-fl-sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn-fl-outline {
  background: transparent; color: var(--fl);
  border: 1.5px solid var(--fl); border-radius: 8px;
  padding: 8px 18px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s; display: inline-flex;
  align-items: center; gap: 6px; text-decoration: none;
}
.btn-fl-outline:hover { background: var(--fl); color: #fff; }

/* ── Alerts ──────────────────────────────────────── */
.alert { border-radius: 9px; font-size: 13px; border: none; padding: 10px 14px; }
.alert-success { background: #f0fdf4; color: #15803d; border-left: 3px solid var(--fl); }
.alert-danger  { background: #fff5f5; color: #b91c1c; border-left: 3px solid #ef4444; }
.alert-info    { background: #eff6ff; color: #1d4ed8; border-left: 3px solid #3b82f6; }
.alert-warning { background: #fffbeb; color: #92400e; border-left: 3px solid #f59e0b; }

/* ── Mobile sidebar overlay ──────────────────────── */
#sb-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 99;
}
@media (max-width: 767px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #sb-overlay.show { display: block; }
  #main { margin-left: 0; }
  .page-body { padding: 16px; }
  .topbar { padding: 0 14px; }
}

/* ── Misc utilities ──────────────────────────────── */
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--fl-l); color: var(--fl);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; flex-shrink: 0;
}
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }
.section-title { font-size: 16px; font-weight: 600; color: #0f172a; margin-bottom: 4px; }
.section-sub   { font-size: 13px; color: #64748b; }
.empty-state {
  text-align: center; padding: 48px 24px;
  color: #94a3b8;
}
.empty-state i { font-size: 38px; display: block; margin-bottom: 12px; }
.empty-state p { font-size: 13px; margin: 0; }
.divider { height: 1px; background: #f1f5f9; margin: 16px 0; }

/* ── Rating stars ────────────────────────────────── */
.stars { color: #f59e0b; font-size: 13px; }
.stars-input { display: flex; gap: 4px; }
.stars-input input[type=radio] { display: none; }
.stars-input label { font-size: 24px; color: #e2e8f0; cursor: pointer; transition: color .1s; }
.stars-input label:hover,
.stars-input label.active { color: #f59e0b; }

/* ── Service line items (quote/contract builder) ── */
.service-line {
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 9px; padding: 10px 12px; margin-bottom: 6px;
}
.sl-header {
  display: flex; gap: 8px; padding: 0 6px 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: #9ca3af; letter-spacing: .5px;
}
.sl-header .slh-svc   { flex: 1 1 0; min-width: 0; }
.sl-header .slh-price { width: 120px; flex-shrink: 0; }
.sl-header .slh-freq  { width: 130px; flex-shrink: 0; }
.sl-header .slh-qty   { width: 62px; flex-shrink: 0; text-align: center; }
.sl-header .slh-del   { width: 30px; flex-shrink: 0; }
.sl-row { display: flex; gap: 8px; align-items: center; }
.sl-svc   { flex: 1 1 0; min-width: 0; }
.sl-price { width: 120px; flex-shrink: 0; }
.sl-freq  { width: 130px; flex-shrink: 0; }
.sl-qty   { width: 62px; flex-shrink: 0; }
.sl-del   { width: 30px; flex-shrink: 0; text-align: center; }
.sl-del button { background: none; border: none; color: #94a3b8; font-size: 18px; cursor: pointer; padding: 0; line-height: 1; }
.sl-del button:hover { color: #ef4444; }
.price-group { display: flex; border: 1px solid #dee2e6; border-radius: 8px; overflow: hidden; }
.price-group .price-prefix {
  padding: 0 8px; background: #f1f5f9; font-size: 13px; font-weight: 600;
  color: #6b7280; display: flex; align-items: center; border-right: 1px solid #dee2e6;
}
.price-group input {
  flex: 1; border: none; padding: 6px 8px; font-size: 13px;
  min-width: 0; outline: none; background: #fff;
}
.price-group input:focus { background: #f0fdf4; }
.sl-note-toggle {
  margin-top: 6px; padding-left: 2px;
  font-size: 11px; font-weight: 600; color: #9ca3af;
  background: none; border: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.sl-note-toggle:hover { color: var(--fl); }
.sl-note-input { margin-top: 6px; }

/* ── Signature pad ───────────────────────────────── */
.sig-container {
  border: 1.5px dashed #e2e8f0; border-radius: 10px;
  overflow: hidden; position: relative;
  background: #fafafa;
}
.sig-container canvas { display: block; width: 100%; cursor: crosshair; }
.sig-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ── Map container ───────────────────────────────── */
#map { width: 100%; height: 420px; border-radius: 10px; overflow: hidden; }
@media (max-width: 767px) { #map { height: 260px; } }

/* ── Timeline (job history) ──────────────────────── */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline-item { display: flex; gap: 14px; padding-bottom: 20px; position: relative; }
.timeline-item::before {
  content: ''; position: absolute; left: 14px; top: 28px;
  width: 2px; bottom: 0; background: #f1f5f9;
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--fl-l); color: var(--fl);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0; z-index: 1;
}
.timeline-body { flex: 1; }
.timeline-title { font-size: 13px; font-weight: 600; color: #0f172a; }
.timeline-time  { font-size: 11px; color: #94a3b8; }

/* ── Stepper (quote→contract→job flow) ──────────── */
.stepper { display: flex; align-items: center; gap: 0; margin-bottom: 24px; overflow-x: auto; }
.step { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.step-num {
  width: 26px; height: 26px; border-radius: 50%; background: #e8edf2;
  color: #94a3b8; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.step.done  .step-num { background: var(--fl-l); color: var(--fl); }
.step.active .step-num { background: var(--fl); color: #fff; }
.step-label { font-size: 12px; font-weight: 600; color: #94a3b8; white-space: nowrap; }
.step.done  .step-label { color: var(--fl); }
.step.active .step-label { color: #0f172a; }
.step-line { flex: 1; height: 2px; background: #e8edf2; min-width: 24px; }
.step.done + .step-line { background: var(--fl); }

/* ── Customer portal specific ────────────────────── */
.portal-body { background: #f8fafc; min-height: 100vh; }
.portal-nav {
  background: #fff; border-bottom: 1px solid #e8edf2;
  padding: 0 20px; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.portal-nav-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.portal-content { max-width: 760px; margin: 0 auto; padding: 24px 16px; }
.portal-card {
  background: #fff; border: 1px solid #e8edf2;
  border-radius: 12px; overflow: hidden; margin-bottom: 16px;
}
.portal-card-header { padding: 13px 18px; border-bottom: 1px solid #f1f5f9; }
.portal-card-body   { padding: 16px 18px; }
.portal-card-title  { font-size: 14px; font-weight: 600; color: #0f172a; }
.visit-card {
  border: 1px solid #e8edf2; border-radius: 10px;
  padding: 14px; margin-bottom: 10px;
  background: #fff; transition: box-shadow .15s;
}
.visit-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,.05); }
.visit-date { font-size: 22px; font-weight: 700; color: var(--fl); line-height: 1; }
.visit-month { font-size: 11px; color: #64748b; font-weight: 600; text-transform: uppercase; }

/* ── Technician portal ───────────────────────────── */
.tech-body { background: #0f172a; color: #f8fafc; min-height: 100vh; }
.tech-header {
  background: #1e293b; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50; border-bottom: 1px solid #334155;
}
.tech-content { padding: 16px; max-width: 560px; margin: 0 auto; }
.job-card {
  background: #1e293b; border: 1px solid #334155;
  border-radius: 12px; padding: 16px; margin-bottom: 12px;
  cursor: pointer; transition: all .15s;
}
.job-card:hover  { border-color: var(--fl); }
.job-card.active { border-color: var(--fl); background: #0f2d1a; }
.job-num   { font-size: 11px; color: #64748b; font-weight: 600; }
.job-cust  { font-size: 15px; font-weight: 600; color: #f1f5f9; margin: 2px 0; }
.job-addr  { font-size: 12px; color: #94a3b8; }
.job-time  { font-size: 12px; color: #16a34a; font-weight: 600; }
.tech-btn {
  display: block; width: 100%; padding: 13px;
  border-radius: 10px; border: none; font-size: 14px;
  font-weight: 600; cursor: pointer; transition: all .15s;
  text-align: center; text-decoration: none;
}
.tech-btn-green { background: #16a34a; color: #fff; }
.tech-btn-green:hover { background: #15803d; color: #fff; }
.tech-btn-outline { background: transparent; color: #94a3b8; border: 1px solid #334155; }
.tech-btn-outline:hover { border-color: #94a3b8; color: #f1f5f9; }
.tech-btn-white { background: #fff; color: #15803d; }
.tech-btn-white:hover { background: #f0fdf4; color: #15803d; }
.tech-btn-white-outline { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 10px; display: flex; align-items: center; justify-content: center; text-decoration: none; }
.tech-btn-white-outline:hover { background: rgba(255,255,255,.22); color: #fff; }

/* ── Marketing site ──────────────────────────────── */
.mkt-body { background: #fff; }
.mkt-nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,.97); backdrop-filter: blur(12px);
  border-bottom: 1px solid #f1f5f9; height: 64px;
  display: flex; align-items: center; padding: 0 5%;
  box-shadow: 0 1px 0 #f1f3f5;
}
.mkt-nav-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.mkt-nav-brand .logo-icon {
  width: 36px; height: 36px; background: var(--fl);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
}
.mkt-nav-links { display: flex; align-items: center; gap: 28px; margin-left: auto; }
.mkt-nav-links a { font-size: 14px; font-weight: 500; color: #374151; text-decoration: none; transition: color .15s; }
.mkt-nav-links a:hover { color: var(--fl); }
.mkt-section { padding: 80px 5%; }
.mkt-section-title {
  font-size: clamp(24px, 3vw, 38px); font-weight: 700; color: #0f172a;
  text-align: center; margin-bottom: 12px; line-height: 1.2;
}
.mkt-section-sub {
  font-size: 15px; color: #64748b; text-align: center;
  max-width: 560px; margin: 0 auto 52px; line-height: 1.7;
}
.mkt-footer {
  background: #0f172a; color: #94a3b8; padding: 48px 5% 28px;
}
.mkt-footer-grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px; margin-bottom: 40px;
}
.mkt-footer h4 { font-size: 12px; font-weight: 600; color: #f1f5f9; margin-bottom: 14px; text-transform: uppercase; letter-spacing: .5px; }
.mkt-footer a  { display: block; font-size: 13px; color: #64748b; text-decoration: none; margin-bottom: 8px; transition: color .15s; }
.mkt-footer a:hover { color: #a7f3d0; }
.mkt-footer-bottom { border-top: 1px solid #1e293b; padding-top: 20px; font-size: 12px; color: #475569; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
@media (max-width: 768px) {
  .mkt-nav-links { display: none; }
  .mkt-footer-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Responsive tweaks ───────────────────────────── */
@media (max-width: 575px) {
  .stat-val { font-size: 22px; }
  .fl-table { font-size: 12px; }
  .fl-table thead th, .fl-table tbody td { padding: 8px 10px; }
}
