/* Shared admin components. Consumes variables from _layout.css. */

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-body);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.card-sub {
  font-size: 12px;
  color: var(--text-muted);
}
.card--accent-orange { border-left: 4px solid #ff8a3c; }
.card--accent-purple { border-left: 4px solid var(--accent-purple); }
.card--accent-green { border-left: 4px solid var(--accent-green); }
.card--accent-red { border-left: 4px solid var(--accent-red); }
.card--flush { padding: 0; }
.card--flush .card-head { padding: 16px 20px 12px; margin: 0; }
.card--flush .card-body { padding: 0 20px 16px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  --btn-bg: #f1f3f7;
  --btn-fg: var(--text-body);
  --btn-bd: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  cursor: pointer;
  transition: filter .12s, background .12s, color .12s, border-color .12s;
  text-decoration: none;
  line-height: 1.1;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(0.96); }
.btn:active:not(:disabled) { filter: brightness(0.92); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible {
  outline: 2px solid var(--accent-green);
  outline-offset: 2px;
}

.btn-primary {
  --btn-bg: var(--accent-green);
  --btn-fg: #08130a;
  --btn-bd: var(--accent-green);
}
.btn-primary:hover:not(:disabled) { --btn-bg: var(--accent-green-dark); filter: none; color: #fff; }

.btn-outline {
  --btn-bg: transparent;
  --btn-fg: var(--text-body);
  --btn-bd: var(--border);
}
.btn-outline:hover:not(:disabled) { --btn-bg: #f6f8fb; filter: none; }

.btn-red {
  --btn-bg: var(--accent-red);
  --btn-fg: #fff;
  --btn-bd: var(--accent-red);
}
.btn-blue {
  --btn-bg: var(--accent-blue);
  --btn-fg: #fff;
  --btn-bd: var(--accent-blue);
}
.btn-ghost {
  --btn-bg: transparent;
  --btn-bd: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) { color: var(--text-body); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 20px; font-size: 14px; }
.btn-block { width: 100%; }

/* ── Inputs ──────────────────────────────────────────────── */
.input,
.select,
.textarea {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-body);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent-green);
  box-shadow: 0 0 0 3px var(--accent-green-dim);
}
.input::placeholder { color: var(--text-muted); }
.textarea { min-height: 96px; resize: vertical; }
.field { display: block; margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-body);
  margin-bottom: 6px;
}
.field-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  background: #fafbfd;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-body);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #fafbfd; }
.table .row-actions { display: inline-flex; gap: 6px; }

/* ── Status pills ────────────────────────────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef0f4;
  color: var(--text-body);
  line-height: 1.4;
}
.status-pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .85;
}
.status-pill.is-available { background: rgba(76,175,80,.14); color: #1f7a23; }
.status-pill.is-sold      { background: rgba(255,68,68,.14); color: #c1262a; }
.status-pill.is-booked    { background: rgba(243,231,149,.45); color: #8a6d10; }
.status-pill.is-builder   { background: rgba(186,186,186,.35); color: #4d4d4d; }
.status-pill.is-new       { background: var(--accent-blue-dim); color: #1d56b3; }
.status-pill.is-contacted { background: rgba(139,92,246,.16); color: #5b32c2; }
.status-pill.is-interested{ background: rgba(243,231,149,.45); color: #8a6d10; }
.status-pill.is-converted { background: rgba(76,175,80,.14); color: #1f7a23; }
.status-pill.is-closed    { background: #eef0f4; color: var(--text-muted); }

/* ── KPI tiles ───────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}
.kpi-tile {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  border-top: 3px solid var(--text-dim);
}
.kpi-tile .kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.kpi-tile .kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-body);
  line-height: 1.1;
}
.kpi-tile .kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
}
.kpi-tile .kpi-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px; height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: #f1f3f7;
}
.kpi-tile.is-green   { border-top-color: var(--accent-green); }
.kpi-tile.is-green   .kpi-icon { background: var(--accent-green-dim); color: var(--accent-green); }
.kpi-tile.is-red     { border-top-color: var(--accent-red); }
.kpi-tile.is-red     .kpi-icon { background: var(--accent-red-dim); color: var(--accent-red); }
.kpi-tile.is-blue    { border-top-color: var(--accent-blue); }
.kpi-tile.is-blue    .kpi-icon { background: var(--accent-blue-dim); color: var(--accent-blue); }
.kpi-tile.is-yellow  { border-top-color: #d6b62a; }
.kpi-tile.is-yellow  .kpi-icon { background: rgba(243,231,149,.5); color: #8a6d10; }
.kpi-tile.is-purple  { border-top-color: var(--accent-purple); }
.kpi-tile.is-purple  .kpi-icon { background: rgba(139,92,246,.16); color: var(--accent-purple); }

/* ── Filter chips ────────────────────────────────────────── */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 999px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text-body);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  font-family: inherit;
  line-height: 1.3;
}
.filter-chip .chip-count {
  background: #eef0f4;
  color: var(--text-muted);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.filter-chip:hover { background: #f6f8fb; }
.filter-chip.is-active {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: #08130a;
}
.filter-chip.is-active .chip-count { background: rgba(8,19,10,.18); color: #08130a; }
.filter-chip.is-available.is-active { background: var(--status-available); border-color: var(--status-available); color: #08130a; }
.filter-chip.is-sold.is-active      { background: var(--status-sold); border-color: var(--status-sold); color: #fff; }
.filter-chip.is-sold.is-active .chip-count { background: rgba(255,255,255,.22); color: #fff; }
.filter-chip.is-booked.is-active    { background: var(--status-booked); border-color: #d6b62a; color: #5e4b0e; }
.filter-chip.is-builder.is-active   { background: var(--status-builder); border-color: #8a8a8a; color: #1a1a1a; }

/* ── Tab bar ─────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
}
.tab-bar a,
.tab-bar button {
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: color .12s, border-color .12s;
}
.tab-bar a:hover,
.tab-bar button:hover { color: var(--text-body); }
.tab-bar a.is-active,
.tab-bar button.is-active {
  color: var(--accent-green);
  border-bottom-color: var(--accent-green);
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-backdrop.is-open { display: flex; }
.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-elev);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-in .15s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-title { font-size: 16px; font-weight: 600; margin: 0; }
.modal-close {
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
}
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: #fafbfd;
}

/* Big choice grid used inside modals (status selector / lead lifecycle) */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}
.choice-tile {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  padding: 14px 12px;
  font-weight: 600;
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  color: var(--text-body);
  transition: border-color .12s, background .12s;
  font-family: inherit;
}
.choice-tile:hover { border-color: var(--accent-green); }
.choice-tile.is-selected {
  border-color: var(--accent-green);
  background: var(--accent-green-dim);
  color: #1f7a23;
}

/* Misc helpers used across pages */
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-right { text-align: right; }
/* utility must beat the `.table thead th { text-align:left }` rule above */
.table thead th.text-right { text-align: right; }
.divider { height: 1px; background: var(--border); border: none; margin: 14px 0; }

.search {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 260px;
  max-width: 100%;
}
.search .input { padding-left: 32px; }
.search::before {
  content: "🔍";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  opacity: .55;
  pointer-events: none;
}
