/* PlumbLine AI — Stylesheet */

:root {
  --blue:       #1e40af;
  --blue-light: #3b82f6;
  --red:        #dc2626;
  --red-light:  #fee2e2;
  --amber:      #d97706;
  --amber-light:#fef3c7;
  --green:      #16a34a;
  --green-light:#dcfce7;
  --gray-50:    #f9fafb;
  --gray-100:   #f3f4f6;
  --gray-200:   #e5e7eb;
  --gray-400:   #9ca3af;
  --gray-600:   #4b5563;
  --gray-800:   #1f2937;
  --white:      #ffffff;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Login ── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--blue);
}

.login-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.logo-icon { font-size: 32px; }

.login-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-800);
  margin-top: 8px;
}

.login-logo p {
  color: var(--gray-400);
  font-size: 13px;
  margin-top: 2px;
}

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--gray-600);
  font-size: 13px;
}
.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus { border-color: var(--blue-light); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--blue); color: var(--white); }
.btn-outline {
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.4);
}
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ── Alerts ── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}
.alert-error { background: var(--red-light); color: var(--red); }

/* ── Topbar ── */
.topbar {
  background: var(--blue);
  color: var(--white);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-title { font-size: 16px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-subtitle { font-size: 12px; opacity: 0.7; }

/* ── Layout ── */
.container { max-width: 1280px; margin: 0 auto; padding: 24px 20px; }

/* ── Stats ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  text-align: center;
}
.stat-card.stat-emergency { border-top: 3px solid var(--red); }
.stat-number { font-size: 32px; font-weight: 700; color: var(--blue); }
.stat-card.stat-emergency .stat-number { color: var(--red); }
.stat-label { font-size: 12px; color: var(--gray-400); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Sections ── */
.section { margin-bottom: 32px; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
}

/* ── Cost Cards ── */
.cost-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.cost-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--green);
}
.cost-card.cost-warning { border-left-color: var(--amber); }
.cost-card.cost-exceeded { border-left-color: var(--red); }
.cost-business { font-weight: 600; margin-bottom: 10px; }
.cost-bar-wrap {
  background: var(--gray-100);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}
.cost-bar {
  height: 100%;
  background: var(--green);
  border-radius: 4px;
  transition: width 0.3s;
}
.cost-card.cost-warning .cost-bar { background: var(--amber); }
.cost-card.cost-exceeded .cost-bar { background: var(--red); }
.cost-numbers {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--gray-600);
}

/* ── Filter Tabs ── */
.filter-tabs { display: flex; gap: 8px; }
.filter-tab {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--gray-200);
  background: var(--white);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
  transition: all 0.15s;
}
.filter-tab.active {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--white);
}

/* ── Leads Table ── */
.leads-table-wrap {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.leads-table {
  width: 100%;
  border-collapse: collapse;
}
.leads-table thead tr {
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
}
.leads-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.leads-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}
.leads-table tbody tr:last-child td { border-bottom: none; }
.leads-table tbody tr:hover { background: var(--gray-50); }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-emergency { background: var(--red-light); color: var(--red); }
.badge-scheduled { background: var(--green-light); color: var(--green); }

/* ── Table Helpers ── */
.mono { font-family: "SF Mono", "Fira Code", monospace; font-size: 12px; }
.nowrap { white-space: nowrap; }
.issue-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sms-sent { color: var(--green); font-weight: 700; }
.sms-failed { color: var(--red); }

/* ── Empty State ── */
.empty-state {
  background: var(--white);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  color: var(--gray-400);
  box-shadow: var(--shadow);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .section-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .topbar-subtitle { display: none; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .container { padding: 16px 12px; }
}
