/* BJPC Leads CRM — styles */

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e4e6eb;
  --text: #1c1f23;
  --muted: #6b7280;
  --brand: #0b3d91;
  --brand-hi: #15539e;
  --accent: #f4c430;

  --new: #2563eb;
  --contacted: #d97706;
  --resolved: #16a34a;
  --spam: #6b7280;

  --call: #16a34a;
  --wa:   #25d366;
  --mail: #2563eb;

  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 1px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono  { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.nowrap { white-space: nowrap; }

/* ----- Topbar ----- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar .brand {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.topbar-logo {
  height: 32px;
  width: auto;
  display: block;
  background: #fff;
  border-radius: 4px;
  padding: 2px;
}
.topbar .back {
  color: #fff;
  opacity: 0.85;
  font-size: 13px;
}
.topbar .back:hover { opacity: 1; text-decoration: none; }
.topbar .topbar-link {
  margin-left: auto;
  color: #fff;
  opacity: 0.85;
  font-size: 13px;
}
.topbar .topbar-link:hover { opacity: 1; text-decoration: none; }
.topbar .signout {
  color: #fff;
  opacity: 0.85;
  font-size: 13px;
}
.topbar .signout:hover { opacity: 1; text-decoration: none; }

.password-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 360px;
}
.password-form label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  gap: 4px;
}
.password-form input[type="password"] {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}
.password-form input[type="password"]:focus {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
  border-color: var(--brand);
}
.password-form .btn-primary { align-self: flex-start; }

/* ----- Status tabs ----- */
.status-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 20px 0;
  flex-wrap: wrap;
}
.status-tabs a {
  padding: 8px 14px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  border: 1px solid transparent;
  border-bottom: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.status-tabs a:hover { background: rgba(0,0,0,0.04); text-decoration: none; }
.status-tabs a.active {
  background: var(--card);
  border-color: var(--border);
  color: var(--brand);
}
.status-tabs .count {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0,0,0,0.08);
  color: var(--text);
  text-align: center;
}
.status-tabs a.active .count { background: var(--brand); color: #fff; }

/* ----- Filters ----- */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 12px 20px;
  background: var(--card);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.filters select,
.filters input[type="search"] {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font: inherit;
  color: var(--text);
}
.filters input[type="search"] { min-width: 260px; flex: 1 1 260px; }
.filters button {
  padding: 7px 14px;
  border: none;
  background: var(--brand);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}
.filters button:hover { background: var(--brand-hi); }
.filters .link-reset { font-size: 13px; color: var(--muted); }

/* ----- Flash ----- */
.flash {
  margin: 12px 20px 0;
  padding: 8px 14px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  font-size: 13px;
}

/* ----- Table ----- */
.table-wrap { padding: 12px 20px; overflow-x: auto; }
table.leads {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
table.leads th,
table.leads td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.leads thead th {
  background: #f9fafb;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
table.leads tbody tr:hover { background: #f9fafb; }
table.leads tbody tr.row-link { cursor: pointer; }
table.leads tbody tr:last-child td { border-bottom: none; }
.lead-name { font-weight: 600; color: var(--text); }
.lead-name:hover { color: var(--brand); text-decoration: none; }
.empty { text-align: center; padding: 32px; color: var(--muted); }
.col-status  { width: 130px; }
.col-actions { width: 220px; }

/* ----- Status pills & selects ----- */
.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.6;
  color: #fff;
}
.pill-new       { background: var(--new); }
.pill-contacted { background: var(--contacted); }
.pill-resolved  { background: var(--resolved); }
.pill-spam      { background: var(--spam); }

.status-form { margin: 0; }
.status-select {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 4px 24px 4px 10px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  color: #fff;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23ffffff' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.status-select.pill-new       { background-color: var(--new);       border-color: var(--new); }
.status-select.pill-contacted { background-color: var(--contacted); border-color: var(--contacted); }
.status-select.pill-resolved  { background-color: var(--resolved);  border-color: var(--resolved); }
.status-select.pill-spam      { background-color: var(--spam);      border-color: var(--spam); }
.status-select option { background: #fff; color: var(--text); font-weight: 500; }

/* ----- Action buttons ----- */
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #fff !important;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { opacity: 0.9; text-decoration: none; }
.btn .icon { font-size: 13px; line-height: 1; }
.btn-call { background: var(--call); }
.btn-wa   { background: var(--wa); }
.btn-mail { background: var(--mail); }
.actions-large .btn {
  padding: 9px 16px;
  font-size: 14px;
}

/* ----- Pagination ----- */
.pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  padding: 16px;
  flex-wrap: wrap;
}
.pagination a {
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
}
.pagination a:hover { background: #f3f4f6; text-decoration: none; }
.pagination a.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ----- Footer ----- */
.footer {
  text-align: center;
  padding: 16px;
  color: var(--muted);
  font-size: 12px;
}

/* ----- Detail view ----- */
.detail {
  max-width: 880px;
  margin: 0 auto;
  padding: 20px;
}
.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.detail-head h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}
.detail-sub {
  margin-top: 6px;
  font-size: 13px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 12px; font-size: 14px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.05em; }

.status-update {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}
.status-update label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  gap: 4px;
}
.status-update .btn-primary {
  padding: 7px 16px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
}
.status-update .btn-primary:hover { background: var(--brand-hi); }

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 16px;
  margin: 0;
}
.kv dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; padding-top: 2px; }
.kv dd { margin: 0; word-break: break-word; }
.kv dd.message { white-space: pre-wrap; background: #f9fafb; padding: 10px; border-radius: 6px; border: 1px solid var(--border); }

/* ----- Login page ----- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}
.login-logo {
  display: block;
  margin: 0 auto 16px;
  height: 64px;
  width: auto;
}
.login-card h1 {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 22px;
  text-align: center;
}
.login-card > .muted { text-align: center; }
.login-card form {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  gap: 4px;
}
.login-card input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}
.login-card input:focus {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
  border-color: var(--brand);
}
.btn-primary {
  padding: 10px 16px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: var(--brand-hi); }
.alert {
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-top: 16px;
}
.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* ----- Responsive ----- */
@media (max-width: 768px) {
  table.leads thead { display: none; }
  table.leads, table.leads tbody, table.leads tr, table.leads td { display: block; width: 100%; }
  table.leads tr {
    background: var(--card);
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
  }
  table.leads td {
    border: none;
    padding: 4px 0;
  }
  table.leads td.col-status { margin-bottom: 8px; }
  table.leads td.col-actions { margin-top: 8px; }
  .col-actions { width: auto; }
  .actions .btn .label { display: inline; }

  .detail-head { flex-direction: column; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { padding-top: 8px; }
  .kv dt:first-child { padding-top: 0; }

  .filters { flex-direction: column; align-items: stretch; }
  .filters input[type="search"] { min-width: 0; }
}
