/* ============================================================
   Skyluxe CRM — admin UI
   Brand: royal blue (matching skyluxeconstruction.com logo)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter+Tight:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:           #f4f6fb;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --line:         #e2e8f0;
  --line-strong:  #cbd5e1;

  --ink:          #0f172a;
  --ink-2:        #1e293b;
  --ink-muted:    #64748b;
  --ink-subtle:   #94a3b8;

  /* Royal blue brand — matches skyluxeconstruction.com */
  --brand:        #2563eb;
  --brand-2:      #1d4ed8;
  --brand-3:      #1e40af;
  --accent:       #2563eb;
  --accent-2:     #60a5fa;
  --accent-soft:  #dbeafe;

  --success:      #16a34a;
  --success-soft: #dcfce7;
  --danger:       #dc2626;
  --danger-soft:  #fee2e2;
  --warn:         #ca8a04;
  --warn-soft:    #fef9c3;
  --info:         #0284c7;
  --info-soft:    #e0f2fe;

  --radius:       10px;
  --radius-sm:    6px;
  --shadow-sm:    0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md:    0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg:    0 20px 60px -20px rgba(30, 64, 175, 0.30);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter Tight', system-ui, -apple-system, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent); }
.link { color: var(--accent); font-weight: 500; }
.link:hover { text-decoration: underline; }
code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.92em; background: #eef2ff; color: var(--brand-3); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--ink-muted); }

/* ---------- App shell ---------- */
.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-3) 100%);
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; margin-bottom: 28px; }
.brand:hover { color: #fff; }
.brand-mark { display: inline-flex; }
.brand-text strong { display: block; font-size: 17px; letter-spacing: -0.01em; font-weight: 700; color: #fff; }
.brand-text small { display: block; font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(255, 255, 255, 0.7); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: block;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.75);
  font-weight: 500;
  font-size: 14px;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
body[data-section="dashboard"]    .nav-item[data-match="dashboard"],
body[data-section="customers"]    .nav-item[data-match="customers"],
body[data-section="appointments"] .nav-item[data-match="appointments"],
body[data-section="campaigns"]    .nav-item[data-match="campaigns"],
body[data-section="api"]          .nav-item[data-match="api"],
body[data-section="activity"]     .nav-item[data-match="activity"] {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  box-shadow: inset 2px 0 0 #fff;
}

.sidebar-foot { margin-top: 18px; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, 0.12); }
.who { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.18); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.who-meta strong { display: block; color: #fff; font-size: 13.5px; }
.who-meta small { color: rgba(255, 255, 255, 0.65); text-transform: capitalize; font-size: 11px; }
.signout { display: block; font-size: 12.5px; color: rgba(255, 255, 255, 0.7); }
.signout:hover { color: #fff; }

.content { padding: 32px 40px; max-width: 1280px; width: 100%; }

/* ---------- Headings ---------- */
h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -0.015em; font-weight: 700; color: var(--ink); }
h2 { font-size: 17px; margin: 0; letter-spacing: -0.005em; font-weight: 600; color: var(--ink); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .muted { margin: 2px 0 0; font-size: 14px; }
.page-head-actions { display: flex; gap: 10px; }
.back { display: inline-block; font-size: 13px; color: var(--ink-muted); margin-bottom: 6px; }
.back:hover { color: var(--accent); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }

/* ---------- Stat grid ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.stat-label { font-size: 12px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.stat-value { display: block; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; color: var(--ink); }
.stat-sub { font-size: 12.5px; color: var(--ink-muted); margin-top: 4px; display: block; }
.stat-accent {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-3) 100%);
  color: #fff;
  border: none;
  box-shadow: 0 8px 24px -10px rgba(37, 99, 235, 0.5);
}
.stat-accent .stat-label { color: rgba(255, 255, 255, 0.8); }
.stat-accent .stat-value { color: #fff; }
.stat-accent .stat-sub   { color: rgba(255, 255, 255, 0.75); }
.stat-cta { display: inline-block; margin-top: 6px; color: #fff; font-weight: 600; font-size: 16px; text-decoration: underline; text-underline-offset: 3px; }
.stat-cta:hover { color: #fff; opacity: 0.9; }

/* ---------- Tables ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th { text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.data-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tr:hover td { background: var(--surface-2); }
.data-table tr:last-child td { border-bottom: none; }
.cell-addr { color: var(--ink-muted); font-size: 12.5px; max-width: 220px; }
.row-actions { text-align: right; white-space: nowrap; }

/* ---------- Forms ---------- */
.form-stack label, .form-wide label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], input[type="datetime-local"], input:not([type]), textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  margin-top: 4px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
textarea { resize: vertical; line-height: 1.5; }
textarea.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; }
@media (max-width: 700px) {
  .row-2, .row-3 { grid-template-columns: 1fr; }
}

fieldset { border: none; padding: 0; margin: 0 0 18px; }
fieldset legend { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); font-weight: 700; margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); width: 100%; }

.checkbox { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox input { width: auto; margin: 0; }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.06s, box-shadow 0.12s;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 2px 6px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover { background: var(--brand-2); color: #fff; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 4px 12px rgba(37, 99, 235, 0.35); }
.btn-ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--brand-3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-link { background: transparent; color: var(--accent); padding: 4px 8px; font-weight: 500; }
.btn-link:hover { background: var(--accent-soft); }
.btn-danger-link { color: var(--danger); }
.btn-danger-link:hover { background: var(--danger-soft); }
.btn-block { width: 100%; }

/* ---------- Pills ---------- */
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; background: #e2e8f0; color: var(--ink-2); }
.pill-draft   { background: #e2e8f0; color: #475569; }
.pill-sending { background: var(--info-soft);    color: var(--info); }
.pill-sent    { background: var(--success-soft); color: var(--success); }
.pill-failed  { background: var(--danger-soft);  color: var(--danger); }
.pill-queued  { background: var(--warn-soft);    color: var(--warn); }
.pill-skipped { background: #f1f5f9; color: var(--ink-subtle); }

/* ---------- Flash ---------- */
.flash { padding: 11px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13.5px; border: 1px solid; }
.flash-success { background: var(--success-soft); color: #166534; border-color: #bbf7d0; }
.flash-error   { background: var(--danger-soft);  color: #991b1b; border-color: #fecaca; }
.flash-info    { background: var(--accent-soft);  color: var(--brand-3); border-color: #bfdbfe; }

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--surface); padding: 12px 16px;
  border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px;
}
.filter-bar input[type="search"], .filter-bar input[type="text"] { width: auto; flex: 1; min-width: 180px; margin: 0; }

/* ---------- Pager ---------- */
.pager { display: flex; gap: 4px; padding: 14px 0 4px; }
.pager-link { padding: 5px 10px; border-radius: var(--radius-sm); font-size: 13px; border: 1px solid var(--line); }
.pager-link:hover { background: var(--surface-2); border-color: var(--accent); }
.pager-link.is-current { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- Empty state ---------- */
.empty { color: var(--ink-muted); padding: 30px 0; text-align: center; }

/* ---------- Auth pages ---------- */
.auth-body { background: linear-gradient(160deg, #eef4ff 0%, #c7d9fb 100%); min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 36px 32px; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-brand strong { display: block; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; color: var(--brand-3); }
.auth-brand small { display: block; color: var(--ink-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; }
.auth-foot { margin-top: 24px; text-align: center; font-size: 12px; }
.key-box { background: var(--accent-soft); border: 1px dashed var(--accent); border-radius: var(--radius-sm); padding: 12px; margin: 10px 0; }
.key-box label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--brand-3); display: block; margin-bottom: 4px; font-weight: 600; }
.key-box code { font-size: 13px; word-break: break-all; background: transparent; padding: 0; color: var(--brand-3); }

/* ---------- Email preview ---------- */
.email-preview { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.email-meta { background: var(--surface-2); padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 13px; }
.email-frame { width: 100%; height: 480px; border: none; background: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; align-items: center; padding: 14px 20px; flex-wrap: wrap; }
  .brand { margin-bottom: 0; margin-right: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 4px; flex: 1; }
  .nav-item { padding: 7px 12px; font-size: 13px; }
  .sidebar-foot { margin-top: 0; padding-top: 0; border: none; display: flex; align-items: center; gap: 14px; }
  .content { padding: 22px 20px; }
}
