/* ═══════════════════════════════════════════════════════
   CSFSM — Codesaint Field Service Management
   Design system aligned with SaintPost / CRM
   Brand: #FD6602
   ═══════════════════════════════════════════════════════ */

:root {
  --primary: #1e293b;
  --primary-light: #334155;
  --primary-subtle: #64748b;

  --accent: #FD6602;
  --accent-hover: #d65302;
  --accent-light: rgba(253, 102, 2, 0.08);
  --accent-medium: rgba(253, 102, 2, 0.15);
  --accent-glow: rgba(253, 102, 2, 0.3);
  --accent-gradient: linear-gradient(135deg, #FD6602 0%, #ff8a3d 50%, #ffb070 100%);
  --accent-gradient-btn: linear-gradient(135deg, #FD6602 0%, #d65302 100%);

  --success: #22c55e;
  --success-light: rgba(34, 197, 94, 0.10);
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.10);
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.10);
  --info: #3b82f6;
  --info-light: rgba(59, 130, 246, 0.10);
  --violet: #8b5cf6;
  --violet-light: rgba(139, 92, 246, 0.10);

  --sidebar-width: 256px;
  --topbar-height: 60px;

  --bg: #f5f5f7;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-secondary: #5f6577;
  --text-muted: #9297a4;
  --border: #e2e4ea;
  --border-light: #eef0f4;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 12px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.03);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-accent: 0 4px 16px rgba(253,102,2,0.20);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Poppins', sans-serif;
  color: var(--text);
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin: 0;
}

a { text-decoration: none; color: inherit; }
[x-cloak] { display: none !important; }

::selection { background: var(--accent-medium); color: var(--accent); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Login / Public ───────────────────────── */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}
.auth-hero {
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #fff;
  background:
    radial-gradient(800px 400px at 0% 100%, rgba(253,102,2,0.18), transparent 60%),
    radial-gradient(600px 300px at 100% 0%, rgba(14,165,233,0.10), transparent 60%);
  position: relative;
  overflow: hidden;
}
.auth-hero h1 {
  font-family: 'Poppins', sans-serif;
  font-size: 3rem;
  line-height: 1.05;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.03em;
}
.auth-hero h1 span { color: var(--accent); }
.auth-hero p { font-size: 1rem; color: #cbd5e1; max-width: 420px; line-height: 1.65; }
.auth-hero .feature-list { list-style: none; padding: 0; margin: 24px 0 0; display: flex; flex-direction: column; gap: 10px; color: #cbd5e1; }
.auth-hero .feature-list li { display: flex; gap: 12px; align-items: center; font-size: 0.95rem; }
.auth-hero .feature-list i { color: var(--accent); font-size: 1.2rem; }
.auth-hero .copyright { font-size: 0.78rem; color: #64748b; }

.auth-card-wrap {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 32px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 36px;
}
.auth-card .brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-card .brand-row img { height: 36px; }
.auth-card h2 { font-size: 1.5rem; font-weight: 700; }
.auth-card .sub { color: var(--text-muted); font-size: 0.92rem; margin-top: 4px; margin-bottom: 24px; }
.auth-card .form-label { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary); margin-bottom: 6px; }

/* ── Sidebar ─────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: #fff;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.3s var(--ease);
  overflow-y: auto;
  border-right: 1px solid #e5e7eb;
}
.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 20px 12px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 8px;
}
.sidebar-brand img { height: 38px; width: auto; }
.brand-name {
  font-family: 'Poppins', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text);
  text-align: center;
}
.sidebar-section-label {
  padding: 16px 20px 6px;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #94a3b8;
}
.sidebar-nav { flex: 1; padding: 0 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #64748b;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  border-left: 3px solid transparent;
  padding-left: 9px;
}
.nav-item:hover { background: #f1f5f9; color: var(--text); }
.nav-item.active { background: rgba(253,102,2,0.08); color: var(--accent); border-left-color: var(--accent); }
.nav-item i { font-size: 1.15rem; width: 20px; text-align: center; color: inherit; }
.nav-item .nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 0.65rem; padding: 2px 6px; border-radius: 999px; font-weight: 700; }

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid #f1f5f9;
  margin-top: auto;
  background: #fafafa;
}
.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 34px; height: 34px;
  background: var(--accent-gradient);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 0.8rem;
  font-family: 'Poppins', sans-serif;
  flex-shrink: 0;
}
.user-details { flex: 1; overflow: hidden; }
.user-name { font-weight: 600; font-size: 0.85rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); background: #fff; cursor: pointer;
  transition: all 0.15s var(--ease);
}
.logout-btn:hover { color: var(--danger); border-color: var(--danger); }

/* ── Layout ──────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.5); z-index: 999; }
  .sidebar-overlay.open { display: block; }
}
.topbar {
  height: var(--topbar-height);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-title {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  flex: 1;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative;
  transition: all 0.15s var(--ease);
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent-medium); }
.icon-btn .badge-dot {
  position: absolute; top: -3px; right: -3px;
  background: var(--danger); color: #fff;
  border-radius: 999px; font-size: 0.62rem; font-weight: 700;
  padding: 2px 5px; min-width: 16px; text-align: center;
}

.content-area { padding: 28px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-bottom: 22px; }
.page-header h1 { font-size: 1.75rem; font-weight: 700; }
.page-header .sub { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }

/* ── Cards + grids ───────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: all 0.2s var(--ease);
}
.card-hover:hover { box-shadow: var(--shadow); border-color: var(--border); cursor: pointer; }
.card-body { padding: 20px; }
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-light);
  padding: 16px 20px;
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  display: flex; align-items: center; gap: 10px;
}

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .stat-grid { grid-template-columns: 1fr; } }
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-xs);
  transition: all 0.2s var(--ease);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border); }
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  transition: transform 0.2s var(--ease-spring);
}
.stat-card:hover .stat-icon { transform: scale(1.08); }
.stat-icon.orange { background: var(--accent-light); color: var(--accent); }
.stat-icon.blue   { background: var(--info-light); color: var(--info); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.red    { background: var(--danger-light); color: var(--danger); }
.stat-icon.violet { background: var(--violet-light); color: var(--violet); }
.stat-icon.amber  { background: var(--warning-light); color: var(--warning); }
.stat-value {
  font-family: 'Poppins', sans-serif;
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  letter-spacing: -0.03em;
}
.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-top: 4px;
}

/* ── Buttons ─────────────────────────────── */
.btn {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  letter-spacing: 0.01em;
  padding: 8px 16px;
  transition: all 0.15s var(--ease);
}
.btn-primary {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
  box-shadow: 0 1px 3px rgba(253,102,2,0.20);
}
.btn-primary:hover { background: var(--accent-hover) !important; border-color: var(--accent-hover) !important; box-shadow: var(--shadow-accent) !important; transform: translateY(-1px); }
.btn-outline-primary {
  border: 1px solid var(--accent) !important;
  color: var(--accent) !important;
  background: transparent !important;
}
.btn-outline-primary:hover { background: var(--accent-light) !important; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); padding: 6px 12px; border-radius: 6px; font-size: 0.82rem; cursor: pointer; }
.btn-ghost:hover { background: #f1f5f9; color: var(--text); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ── Inputs ─────────────────────────────── */
.form-control, .form-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 0.88rem;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  outline: none;
}

/* ── Pills ──────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: capitalize;
  border: 1px solid transparent;
}
.pill-pending     { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.pill-assigned    { background: var(--info-light); color: var(--info); border-color: rgba(59,130,246,0.2); }
.pill-in_progress, .pill-scheduled { background: var(--warning-light); color: var(--warning); border-color: rgba(245,158,11,0.2); }
.pill-completed   { background: var(--success-light); color: #15803d; border-color: rgba(34,197,94,0.2); }
.pill-cancelled   { background: var(--danger-light); color: #b91c1c; border-color: rgba(239,68,68,0.2); }
.pill-new         { background: var(--violet-light); color: #6d28d9; border-color: rgba(139,92,246,0.2); }
.pill-on_hold     { background: var(--warning-light); color: var(--warning); }

.pill-low      { background: #f1f5f9; color: #475569; }
.pill-medium   { background: var(--info-light); color: var(--info); }
.pill-high     { background: var(--warning-light); color: var(--warning); }
.pill-urgent, .pill-critical { background: var(--danger-light); color: var(--danger); }

/* ── Lists ──────────────────────────────── */
.list-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s var(--ease);
  cursor: pointer;
}
.list-row:hover { background: #f8fafc; }
.list-row:last-child { border-bottom: none; }
.list-row .lead { flex: 1; min-width: 0; }
.list-row .lead .title { font-weight: 600; color: var(--text); margin-bottom: 2px; }
.list-row .lead .meta { font-size: 0.78rem; color: var(--text-muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.list-row .actions { display: flex; gap: 6px; }

/* ── Modal ──────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,0.5); backdrop-filter: blur(4px); z-index: 1050; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-card { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto; }
.modal-card .modal-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 22px 24px 14px; border-bottom: 1px solid var(--border-light); }
.modal-card .modal-head h2 { font-size: 1.25rem; font-weight: 700; }
.modal-card .modal-head .close { background: transparent; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; }
.modal-card .modal-body { padding: 22px 24px; }
.modal-card .modal-foot { padding: 14px 24px; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Sections ───────────────────────────── */
.section-card { background: var(--card-bg); border: 1px solid var(--border-light); border-radius: var(--radius); margin-bottom: 18px; overflow: hidden; }
.section-card .section-head { padding: 14px 20px; border-bottom: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.section-card .section-head h3 { font-size: 1rem; font-weight: 600; }
.section-card .section-body { padding: 4px 0; }

/* ── Empty ──────────────────────────────── */
.empty-state { padding: 48px 24px; text-align: center; color: var(--text-muted); }
.empty-state i { font-size: 3rem; color: #cbd5e1; margin-bottom: 8px; }
.empty-state .title { font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }

/* ── Map ────────────────────────────────── */
#route-map { width: 100%; height: 360px; border-radius: var(--radius); }

/* ── Misc ───────────────────────────────── */
.divider { height: 1px; background: var(--border-light); margin: 14px 0; }
.text-muted-2 { color: var(--text-muted); }
.kbd { font-family: monospace; font-size: 0.75rem; background: #f1f5f9; padding: 1px 6px; border-radius: 4px; color: var(--text-secondary); border: 1px solid var(--border); }
