/* Frontline AI Dashboard Styles */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --ink: #0a0a0f;
  --chalk: #fafaf9;
  --accent: #e85d26;
  --accent-glow: rgba(232, 93, 38, 0.12);
  --accent-hover: #d14e1c;
  --muted: #6b6b76;
  --surface: #f4f3f0;
  --border: #e2e1dc;
  --green: #16a34a;
  --green-bg: rgba(22, 163, 74, 0.08);
  --red: #dc2626;
  --red-bg: rgba(220, 38, 38, 0.08);
  --yellow: #ca8a04;
  --yellow-bg: rgba(202, 138, 4, 0.08);
  --blue: #2563eb;
  --blue-bg: rgba(37, 99, 235, 0.08);
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--chalk);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
  line-height: 1.15;
}

/* ─── LAYOUT ─── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--ink);
  color: var(--chalk);
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.03em;
  padding: 0 1.5rem;
  margin-bottom: 2rem;
}
.sidebar-logo span { color: var(--accent); }

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.35);
  padding: 1.2rem 1.5rem 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.5rem;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  color: var(--chalk);
  background: rgba(255,255,255,0.06);
}
.nav-item.active {
  color: var(--chalk);
  background: rgba(232, 93, 38, 0.15);
  border-right: 2px solid var(--accent);
}
.nav-item .nav-icon { font-size: 1.1rem; width: 24px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 100px;
}

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 2rem;
  max-width: 1200px;
}

/* ─── HEADER ─── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}
.page-title {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.page-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* ─── STAT CARDS ─── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
}
.stat-card-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-card-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: 0.25rem;
}
.stat-card-value.accent { color: var(--accent); }
.stat-card-value.green { color: var(--green); }

/* ─── TABLE ─── */
.table-container {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 2rem;
}
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.table-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
}
.table-filters {
  display: flex;
  gap: 0.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}
th {
  text-align: left;
  padding: 0.75rem 1.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
td {
  padding: 0.85rem 1.5rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,0,0,0.01); }

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--muted);
}
.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}
.empty-state-text { font-size: 0.95rem; }

/* ─── BADGES ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-draft { background: var(--surface); color: var(--muted); }
.badge-sent, .badge-pending { background: var(--blue-bg); color: var(--blue); }
.badge-accepted, .badge-paid, .badge-completed { background: var(--green-bg); color: var(--green); }
.badge-rejected, .badge-cancelled, .badge-overdue { background: var(--red-bg); color: var(--red); }
.badge-scheduled, .badge-new { background: var(--yellow-bg); color: var(--yellow); }
.badge-in_progress { background: var(--accent-glow); color: var(--accent); }
.badge-expired, .badge-contacted, .badge-quoted { background: var(--surface); color: var(--muted); }
.badge-emergency { background: var(--red-bg); color: var(--red); }
.badge-urgent { background: var(--yellow-bg); color: var(--yellow); }
.badge-normal { background: var(--blue-bg); color: var(--blue); }
.badge-low { background: var(--surface); color: var(--muted); }
.badge-converted { background: var(--green-bg); color: var(--green); }
.badge-closed { background: var(--surface); color: var(--muted); }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: white;
  color: var(--ink);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--muted); }
.btn-ghost {
  background: none;
  color: var(--muted);
  padding: 0.4rem 0.7rem;
}
.btn-ghost:hover { color: var(--ink); background: var(--surface); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-danger { background: none; color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }

/* ─── MODALS ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: white;
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 48px rgba(0,0,0,0.15);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem;
}
.modal-body { padding: 1.5rem; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* ─── FORMS ─── */
.form-group {
  margin-bottom: 1.25rem;
}
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 0.35rem;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: 'DM Sans', sans-serif;
  color: var(--ink);
  background: white;
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ─── DETAIL VIEW ─── */
.detail-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--muted); font-size: 0.85rem; }
.detail-value { font-weight: 500; }

.actions-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
  cursor: pointer;
  margin-bottom: 1rem;
}
.back-link:hover { color: var(--ink); }

/* ─── INQUIRY FORM (PUBLIC) ─── */
.inquiry-form-container {
  max-width: 600px;
  margin: 2rem auto;
  padding: 2rem;
}
.inquiry-form-container h2 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}
.inquiry-form-container .form-desc {
  color: var(--muted);
  margin-bottom: 2rem;
}

/* ─── TOAST ─── */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  background: var(--ink);
  color: var(--chalk);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: slideIn 0.3s ease-out;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 1rem; }
}

/* ─── LINE ITEMS ─── */
.line-items-table { margin: 1rem 0; }
.line-item-add {
  display: flex;
  gap: 0.5rem;
  align-items: end;
  padding: 1rem 0;
}
.line-item-add .form-group { margin-bottom: 0; }

/* ─── AMOUNT DISPLAY ─── */
.amount { font-family: 'Space Grotesk', sans-serif; font-weight: 600; }
.amount-lg { font-size: 1.5rem; }

/* ─── TOTALS ─── */
.totals-box {
  background: var(--surface);
  border-radius: 8px;
  padding: 1rem 1.5rem;
  margin-top: 1rem;
}
.totals-row {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.9rem;
}
.totals-row.total {
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  font-weight: 700;
  font-size: 1.1rem;
}

/* ─── ACTIVITY FEED ─── */
.activity-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.activity-icon.quote { background: var(--blue-bg); }
.activity-icon.job { background: var(--yellow-bg); }
.activity-icon.invoice { background: var(--green-bg); }
.activity-text { font-size: 0.85rem; flex: 1; }
.activity-time { font-size: 0.75rem; color: var(--muted); }

/* Page sections visible/hidden */
.page-section { display: none; }
.page-section.active { display: block; }
