/* Clearstaq — app.css */
:root {
  --green: #0f4c35;
  --green-light: #e8f5ee;
  --green-mid: #2d7a56;
  --accent: #10b981;
  --warn: #f59e0b;
  --warn-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --blue: #3b82f6;
  --blue-bg: #eff6ff;
  --text: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f9fafb;
  --white: #fff;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

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

body {
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.6;
}

/* ── BUTTONS ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text);
  text-decoration: none;
  transition: all .15s;
}
.btn:hover { background: var(--bg); border-color: #d1d5db; }
.btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn-primary:hover { background: var(--green-mid); border-color: var(--green-mid); }
.btn-danger { background: transparent; color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }
.btn-link { background: none; border: none; color: var(--text-muted); font-size: 13px; cursor: pointer; text-decoration: underline; padding: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── BADGES ──────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
}
.badge--green { background: #dcfce7; color: #166534; }
.badge--gray { background: #f3f4f6; color: #4b5563; }
.badge--yellow { background: #fef3c7; color: #92400e; }
.badge--blue { background: var(--blue-bg); color: #1d4ed8; }
.badge--red { background: var(--danger-bg); color: #991b1b; }

/* ── AUTH PAGES ──────────────────────────────────────── */
.auth-page { background: var(--green); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-wrap { width: 100%; max-width: 420px; padding: 24px; }
.auth-logo {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  margin-bottom: 24px;
  text-align: center;
}
.auth-card {
  background: var(--white);
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
}
.auth-card h1 { font-family: 'Space Grotesk', sans-serif; font-size: 24px; margin-bottom: 6px; }
.auth-sub { color: var(--text-muted); margin-bottom: 24px; font-size: 14px; }
.auth-form .field { margin-bottom: 16px; }
.auth-footer { text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 20px; }
.auth-footer a { color: var(--green); text-decoration: none; font-weight: 600; }

/* ── FORM FIELDS ─────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 500; color: #374151; }
.field input, .field select, .field textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  transition: border-color .15s;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field textarea { resize: vertical; }

/* ── ALERTS ──────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 14px; margin-bottom: 16px; }
.alert-error { background: var(--danger-bg); color: #991b1b; border: 1px solid #fca5a5; }

/* ── DASHBOARD LAYOUT ────────────────────────────────── */
.dash-body {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--green);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all .15s;
}
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.15); color: #fff; }
.nav-icon { font-size: 16px; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.user-email { color: rgba(255,255,255,.6); font-size: 12px; word-break: break-all; }

.dash-main {
  flex: 1;
  padding: 32px;
  max-width: calc(100vw - 220px);
  overflow-x: hidden;
}

/* ── DASHBOARD HEADER ────────────────────────────────── */
.dash-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}
.dash-header h1 { font-family: 'Space Grotesk', sans-serif; font-size: 26px; font-weight: 700; }
.dash-sub { color: var(--text-muted); font-size: 14px; margin-top: 2px; }

/* ── STATS GRID ──────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-card--warn { border-left: 3px solid var(--warn); background: var(--warn-bg); }
.stat-card--alert { border-left: 3px solid var(--danger); background: var(--danger-bg); }
.stat-number { font-family: 'Space Grotesk', sans-serif; font-size: 32px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ── SECTIONS ────────────────────────────────────────── */
.section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.section h2 { font-family: 'Space Grotesk', sans-serif; font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-head h2 { margin-bottom: 0; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── LIST ROWS ───────────────────────────────────────── */
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.list-row:last-child { border-bottom: none; }
.text-muted { color: var(--text-muted); font-size: 13px; }

/* ── PERMIT TABLE ────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 2px solid var(--border);
}
.data-table td { padding: 12px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.row--urgent td { background: #fef2f2; }
.data-table tr.row--warning td { background: var(--warn-bg); }
.row-actions { display: flex; gap: 6px; }

.days-left { font-weight: 600; font-size: 13px; }
.days-left--urgent { color: var(--danger); }
.days-left--warning { color: var(--warn); }

/* ── PERMIT EXPIRING ROWS ────────────────────────────── */
.permit-list { display: flex; flex-direction: column; gap: 10px; }
.permit-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--white);
}
.permit-row--urgent { border-left: 3px solid var(--danger); background: #fef2f2; }
.permit-row--warning { border-left: 3px solid var(--warn); background: var(--warn-bg); }
.permit-row--caution { border-left: 3px solid var(--blue); background: var(--blue-bg); }
.permit-info { flex: 1; font-size: 14px; }
.permit-num { color: var(--text-muted); font-size: 13px; margin-left: 6px; }
.permit-expiry { font-size: 13px; color: var(--text-muted); min-width: 160px; }

/* ── REGULATIONS ─────────────────────────────────────── */
.reg-list { display: flex; flex-direction: column; gap: 12px; }
.reg-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--white);
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.reg-card--watched { border-left: 3px solid var(--accent); }
.reg-card-body { flex: 1; }
.reg-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.reg-title { font-family: 'Space Grotesk', sans-serif; font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.reg-summary { font-size: 13px; color: #374151; line-height: 1.5; margin-bottom: 8px; }
.reg-link { font-size: 13px; color: var(--green); text-decoration: none; font-weight: 500; }
.reg-link:hover { text-decoration: underline; }

/* ── ALERTS LIST ─────────────────────────────────────── */
.alert-list { display: flex; flex-direction: column; gap: 10px; }
.alert-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  font-size: 14px;
}
.alert-row--sent { opacity: .65; }
.alert-info { flex: 1; }
.alert-date { color: var(--text-muted); font-size: 13px; min-width: 140px; }

/* ── EMPTY STATES ────────────────────────────────────── */
.empty-state { text-align: center; padding: 20px; color: var(--text-muted); }
.empty-state--full { padding: 60px 20px; }
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state h3 { font-family: 'Space Grotesk', sans-serif; font-size: 18px; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 14px; margin-bottom: 16px; }

/* ── MODAL ───────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.modal-box {
  position: relative;
  background: var(--white);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  z-index: 1;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-family: 'Space Grotesk', sans-serif; font-size: 18px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); padding: 2px; }
.modal-form { padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ── TOAST ───────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 100;
  animation: slideUp .2s ease;
}
.toast--success { background: var(--green); }
.toast--error { background: var(--danger); }
@keyframes slideUp {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ── HELP TEXT ───────────────────────────────────────── */
.help-text {
  background: var(--blue-bg);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  color: #1e40af;
}

/* ── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .sidebar { display: none; }
  .dash-main { padding: 20px; max-width: 100vw; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .field-row { grid-template-columns: 1fr; }
}
