/* Dashboard layout — reuses color/type tokens from style.css */

body.admin-body {
  background: var(--porcelain-dim);
  min-height: 100svh;
}

/* ---------------- LOGIN ---------------- */
.login-shell {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--ink);
}
.login-back-link {
  position: absolute;
  top: 1.5rem; left: 1.5rem;
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--ink-contrast-70);
}
.login-back-link:hover { color: var(--ink-contrast); }

/* The dashboard sidebar and login shell both stay a fixed dark "chrome"
   color regardless of site theme, so the toggle button on top of them
   needs the invariant ink-contrast tokens instead of the flipping
   white-14/white-70 ones it gets by default from style.css. */
.admin-sidebar .theme-toggle,
.login-shell .theme-toggle {
  position: absolute;
  top: 1.5rem; right: 1.5rem;
  border-color: var(--line-on-ink);
  color: var(--ink-contrast-70);
}
.admin-sidebar .theme-toggle { position: static; margin-left: auto; }
.admin-sidebar .theme-toggle:hover,
.login-shell .theme-toggle:hover {
  color: var(--ink-contrast);
  border-color: rgba(243, 236, 226, 0.35);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--porcelain);
  border: 1px solid var(--line-on-porcelain);
  border-radius: var(--radius);
  padding: clamp(2rem, 5vw, 3rem);
  text-align: center;
}
.login-card .brand {
  color: var(--espresso-text);
  font-size: 1.5rem;
  display: block;
  margin-bottom: 0.3rem;
}
.login-card .sub {
  font-size: 0.85rem;
  color: var(--ink-70);
  margin-bottom: 2rem;
}
.login-card form { text-align: left; }
.login-error {
  background: rgba(122, 59, 59, 0.1);
  border: 1px solid var(--rosewood);
  color: var(--rosewood);
  font-size: 0.85rem;
  padding: 0.8em 1em;
  border-radius: var(--radius);
  margin-bottom: 1.2rem;
  display: none;
}
.login-error.is-visible { display: block; }

/* ---------------- SHELL ---------------- */
.admin-shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100svh;
}

.admin-sidebar {
  background: var(--ink);
  color: var(--ink-contrast);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100svh;
}
.sidebar-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem 1.5rem;
  border-bottom: 1px solid var(--line-on-ink);
  margin-bottom: 1rem;
}
.admin-sidebar .brand {
  color: var(--ink-contrast);
  font-size: 1.15rem;
}
.admin-nav { flex: 1; display: flex; flex-direction: column; gap: 0.2rem; }
.admin-nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7em 0.85em;
  border-radius: var(--radius);
  font-size: 0.87rem;
  color: var(--ink-contrast-70);
  transition: all 0.25s var(--ease);
}
.admin-nav a:hover { background: rgba(243,238,231,0.06); color: var(--ink-contrast); }
.admin-nav a.is-active { background: var(--brass-light); color: var(--ink); font-weight: 600; }
.admin-nav .badge-count {
  margin-left: auto;
  background: rgba(243,238,231,0.15);
  font-size: 0.7rem;
  padding: 0.15em 0.55em;
  border-radius: 999px;
}
.admin-nav a.is-active .badge-count { background: rgba(27,22,19,0.2); color: var(--ink); }

.sidebar-footer {
  border-top: 1px solid var(--line-on-ink);
  padding-top: 1rem;
  margin-top: 1rem;
}
.sidebar-footer button,
.sidebar-view-site {
  display: block;
  width: 100%;
  box-sizing: border-box;
  background: none;
  border: 1px solid var(--line-on-ink);
  color: var(--ink-contrast-70);
  padding: 0.7em;
  border-radius: var(--radius);
  font-size: 0.82rem;
  text-align: center;
  margin-bottom: 0.6rem;
}
.sidebar-footer button:last-child,
.sidebar-view-site:last-child { margin-bottom: 0; }
.sidebar-footer button:hover,
.sidebar-view-site:hover { border-color: var(--brass); color: var(--brass-light); }

.admin-main { padding: clamp(1.25rem, 3vw, 2.5rem); max-width: 1200px; }

.admin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.admin-topbar h1 { font-size: 1.7rem; }
.admin-topbar .sub { color: var(--ink-70); font-size: 0.9rem; margin-top: 0.2rem; }

.mobile-topbar { display: none; }

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar {
    position: fixed;
    inset: 0 30% 0 0;
    z-index: 300;
    transform: translateX(-105%);
    transition: transform 0.35s var(--ease);
    width: 260px;
  }
  .admin-sidebar.is-open { transform: translateX(0); }
  .sidebar-scrim {
    display: none;
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 290;
  }
  .sidebar-scrim.is-open { display: block; }
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--ink);
    color: var(--ink-contrast);
    position: sticky;
    top: 0;
    z-index: 100;
  }
  .mobile-topbar button {
    background: none; border: none; color: var(--ink-contrast); font-size: 1.4rem;
  }
}

/* ---------------- STAT CARDS ---------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2.5rem;
}
.stat-card {
  background: var(--porcelain);
  border: 1px solid var(--line-on-porcelain);
  border-radius: var(--radius);
  padding: 1.4rem;
  border-top: 2px solid var(--brass);
}
.stat-card .num { font-family: var(--font-display); font-size: 2.1rem; color: var(--rosewood); }
.stat-card .label { font-size: 0.76rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-70); margin-top: 0.3rem; }

.panel {
  background: var(--porcelain);
  border: 1px solid var(--line-on-porcelain);
  border-radius: var(--radius);
  padding: clamp(1.2rem, 3vw, 1.8rem);
  margin-bottom: 1.5rem;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.panel-head h2 { font-size: 1.2rem; }

/* ---------------- TABLE ---------------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th {
  text-align: left;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-70);
  padding: 0.7em 0.8em;
  border-bottom: 1px solid var(--line-on-porcelain);
}
.data-table td {
  padding: 0.85em 0.8em;
  border-bottom: 1px solid var(--line-on-porcelain);
  vertical-align: middle;
}
.data-table tr:hover td { background: rgba(176,141,87,0.05); }
.data-table tr.is-clickable { cursor: pointer; }

@media (max-width: 760px) {
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { border: 1px solid var(--line-on-porcelain); border-radius: var(--radius); margin-bottom: 0.8rem; padding: 0.5rem 0.8rem; }
  .data-table td { border: none; display: flex; justify-content: space-between; gap: 1rem; padding: 0.4em 0; }
  .data-table td::before { content: attr(data-label); font-size: 0.68rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-70); }
}

/* ---------------- BADGES ---------------- */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.3em 0.7em;
  border-radius: 999px;
}
.badge-new, .badge-pending { background: rgba(176,141,87,0.18); color: #8a6a34; }
.badge-contacted { background: rgba(90,120,150,0.18); color: #3d5c74; }
.badge-converted, .badge-confirmed { background: rgba(75,130,95,0.18); color: #3a6b4a; }
.badge-rejected, .badge-cancelled, .badge-no-show { background: rgba(122,59,59,0.14); color: var(--rosewood); }
.badge-archived, .badge-completed { background: rgba(42,33,25,0.1); color: var(--ink-70); }

/* ---------------- FILTER CHIPS ---------------- */
.chip-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line-on-porcelain);
  background: var(--porcelain);
  font-size: 0.76rem;
  padding: 0.4em 0.9em;
  border-radius: 999px;
  color: var(--ink-70);
}
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--ink-contrast); }

/* ---------------- EMPTY / LOADING ---------------- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--ink-70);
}
.empty-state .icon { font-size: 1.8rem; margin-bottom: 0.6rem; }
.skeleton-row { height: 44px; background: linear-gradient(90deg, var(--porcelain-dim), var(--porcelain), var(--porcelain-dim)); background-size: 200% 100%; animation: skeleton 1.4s infinite; border-radius: var(--radius); margin-bottom: 0.5rem; }
@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------------- MODAL / DRAWER ---------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(27,22,19,0.55);
  display: flex; align-items: flex-start; justify-content: flex-end;
  z-index: 400; opacity: 0; visibility: hidden; transition: opacity 0.3s var(--ease), visibility 0.3s;
}
.modal-overlay.is-open { opacity: 1; visibility: visible; }
.modal-panel {
  background: var(--porcelain); width: min(440px, 92vw); height: 100%;
  overflow-y: auto; padding: 1.75rem;
  transform: translateX(30px); transition: transform 0.35s var(--ease);
}
.modal-overlay.is-open .modal-panel { transform: translateX(0); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1.4rem; }
.modal-close { background: none; border: none; font-size: 1.4rem; color: var(--ink-70); line-height: 1; }
.modal-section { margin-bottom: 1.3rem; }
.modal-section .k { font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-70); margin-bottom: 0.3rem; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.5rem; }
.modal-actions .btn { flex: 1; min-width: 120px; }

/* ---------------- TOAST ---------------- */
.toast-stack {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 600;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.toast {
  background: var(--ink); color: var(--ink-contrast);
  padding: 0.9em 1.3em; border-radius: var(--radius);
  border-left: 3px solid var(--brass);
  font-size: 0.85rem; box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: toast-in 0.3s var(--ease);
}
.toast.is-error { border-left-color: var(--rosewood); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------- IMAGE FIELD (upload or paste a URL) ---------------- */
.field-hint { font-size: 0.76rem; color: var(--ink-70); margin-top: 0.4rem; }
.image-field-preview {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
  border: 1px solid var(--line-on-porcelain);
}
.image-field-row { display: flex; gap: 0.6rem; align-items: stretch; }
.image-field-row input[type="url"] { flex: 1; }
.image-field-upload-btn {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 0 1.1em;
  border: 1px solid var(--line-on-porcelain);
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--espresso-text);
  transition: border-color 0.25s var(--ease), color 0.25s var(--ease);
}
.image-field-upload-btn:hover { border-color: var(--brass); color: var(--brass); }

/* ---------------- COMING SOON PLACEHOLDER SECTIONS ---------------- */
.coming-soon {
  border: 1px dashed var(--line-on-porcelain);
  border-radius: var(--radius);
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--ink-70);
}
.coming-soon h3 { color: var(--espresso-text); margin-bottom: 0.5rem; }

/* small utility */
.text-right { text-align: right; }
.mt-1 { margin-top: 1rem; }