/* =========================================================
   Crystal Clear CM — admin dashboard
   Layered on top of style.css; reuses the same tokens.
   ========================================================= */

.admin {
  background: var(--surface-2);
  color: var(--text);
}

.admin-container {
  width: min(100% - 2rem, 1180px);
  margin-inline: auto;
}

/* ---------------------------------------------------------
   Buttons — variants the public site does not need
   --------------------------------------------------------- */

.btn--sm { padding: 0.5rem 1rem; font-size: var(--step-xs); }
.btn--block { width: 100%; }

.admin .btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-muted);
}
.admin .btn--ghost:hover { background: #fff; border-color: var(--text-muted); color: var(--text); }

.btn--danger {
  background: transparent;
  border-color: rgb(191 60 60 / 0.35);
  color: #bf3c3c;
}
.btn--danger:hover { background: #bf3c3c; border-color: #bf3c3c; color: #fff; }

/* ---------------------------------------------------------
   Top bar
   --------------------------------------------------------- */

.admin-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  padding: 0.85rem clamp(1rem, 3vw, 2rem);
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
}

.admin-bar__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: #fff;
  text-decoration: none;
  font-family: var(--font-heading);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: var(--step-xs);
}
.admin-bar__brand img { width: 46px; height: auto; }

.admin-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.admin-nav a {
  display: block;
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  color: var(--text-invert-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--step-sm);
}
.admin-nav a:hover { background: var(--line-dark); color: #fff; }
.admin-nav a[aria-current="page"] { background: var(--rose); color: #fff; }

.admin-bar__user {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
  font-size: var(--step-sm);
  color: var(--text-invert-muted);
}
.admin-bar__user strong { color: #fff; display: block; line-height: 1.3; }
.admin-bar__actions { display: flex; align-items: center; gap: .5rem; }
.admin .admin-bar__user .btn--outline { border-color: var(--line-dark); color: #fff; }
.admin .admin-bar__user .btn--outline:hover { background: #fff; color: var(--ink); }

/* ---------------------------------------------------------
   Page shell
   --------------------------------------------------------- */

.admin-main { padding: clamp(1.5rem, 4vw, 3rem) 0 4rem; }

.admin-head { margin-bottom: 1.75rem; }
.admin-head h1 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: var(--step-3);
  color: var(--ink);
  line-height: 1.15;
}
.admin-head p { margin: 0.4rem 0 0; color: var(--text-muted); }

.admin-foot {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--step-xs);
}

.back-link { color: var(--text-muted); text-decoration: none; font-size: var(--step-sm); }
.back-link:hover { color: var(--rose); }

/* ---------------------------------------------------------
   Cards, stats, detail lists
   --------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(1.25rem, 3vw, 2rem);
  margin-bottom: 1.5rem;
  box-shadow: 0 8px 24px rgb(20 22 31 / 0.04);
}
.card--narrow { max-width: 34rem; }
.card h2 {
  margin: 0 0 1rem;
  font-family: var(--font-heading);
  font-size: var(--step-1);
  color: var(--ink);
}
.card h2 + h2, .card .field-grid + h2 { margin-top: 2rem; }
.card p { margin: 0 0 1rem; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1rem;
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}
.stat__value {
  display: block;
  font-family: var(--font-heading);
  font-size: var(--step-3);
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
}
.stat__label {
  font-size: var(--step-xs);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.detail-list { margin: 0; display: grid; gap: 0.75rem; }
.detail-list > div {
  display: grid;
  grid-template-columns: minmax(7rem, 12rem) 1fr;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt { font-weight: 600; color: var(--ink); }
.detail-list dd { margin: 0; color: var(--text-muted); }
.detail-list--compact { margin-top: 1.5rem; font-size: var(--step-sm); }

/* ---------------------------------------------------------
   Pills, tags
   (.alert lives in style.css — the contact page uses it too)
   --------------------------------------------------------- */

.role-pill {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: var(--step-xs);
  font-style: normal;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.role-pill--owner    { background: var(--blush-soft); color: var(--rose-deep); }
.role-pill--employee { background: var(--teal-soft);  color: var(--teal-deep); }
.role-pill--customer { background: #eceef5;           color: var(--text-muted); }

.tag {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: var(--step-xs);
  font-weight: 600;
}
.tag--on   { background: var(--teal-soft); color: var(--teal-deep); }
.tag--warn { background: #fff3d9;          color: #8a6414; }
.tag--off  { background: #eceef5;          color: var(--text-muted); }

.muted { display: block; color: var(--text-muted); font-size: var(--step-xs); }
.empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}

/* ---------------------------------------------------------
   Forms — the primitives (.field, .check, .form-actions) live in
   style.css so the contact form can share them. Layout only here.
   --------------------------------------------------------- */

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0 1.25rem;
}
.field--wide { grid-column: 1 / -1; }

/* ---------------------------------------------------------
   Toolbar + table
   --------------------------------------------------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.toolbar__filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-right: auto;
}
.toolbar__filters input { min-width: 16rem; }

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.table { width: 100%; border-collapse: collapse; font-size: var(--step-sm); }
.table th {
  text-align: left;
  padding: 0.9rem 1rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-heading);
  font-size: var(--step-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  white-space: nowrap;
}
.table td { padding: 0.9rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table a { color: var(--ink); font-weight: 600; }
.table a:hover { color: var(--rose); }
.table__actions { white-space: nowrap; }
.table__actions form { display: inline; }
.table__actions > * { margin-right: 0.25rem; }

.toolbar__note { margin: 0 auto 0 0; color: var(--text-muted); font-size: var(--step-sm); }
.toolbar__note a { color: var(--rose); }

/* ---------------------------------------------------------
   Service list
   --------------------------------------------------------- */

.service-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.75rem; }

.service-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: start;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.service-row--hidden { background: var(--surface-2); opacity: 0.75; }

.service-row__icon {
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  background: var(--blush-soft);
  color: var(--rose-deep);
}
.service-row__icon svg { width: 1.3rem; height: 1.3rem; }

.service-row__body h2 {
  margin: 0 0 0.25rem;
  font-size: var(--step-0);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.service-row__body h2 a { color: var(--ink); text-decoration: none; }
.service-row__body h2 a:hover { color: var(--rose); }
.service-row__body p { margin: 0; font-size: var(--step-sm); color: var(--text-muted); }

.service-row__order { display: grid; gap: 0.25rem; }
.icon-btn {
  width: 2rem;
  height: 1.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}
.icon-btn:hover:not(:disabled) { border-color: var(--rose); color: var(--rose); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }

.service-row__actions { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }

/* Icon picker */
.icon-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4rem, 1fr));
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.icon-picker input { position: absolute; opacity: 0; pointer-events: none; }
.icon-picker__tile {
  display: grid;
  place-items: center;
  height: 3.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.icon-picker__tile svg { width: 1.5rem; height: 1.5rem; }
.icon-picker__tile:hover { border-color: var(--rose); color: var(--rose); }
.icon-picker input:checked + .icon-picker__tile {
  border-color: var(--rose);
  background: var(--blush-soft);
  color: var(--rose-deep);
}
.icon-picker input:focus-visible + .icon-picker__tile { outline: 2px solid var(--rose); outline-offset: 2px; }

/* Card preview reuses the public styles, which expect a dark backdrop. */
.services--preview {
  background: var(--ink);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  grid-template-columns: minmax(0, 22rem);
}

/* ---------------------------------------------------------
   Sign-in screen
   --------------------------------------------------------- */

.admin--auth { background: var(--ink); }

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}
.auth__card {
  width: min(100%, 26rem);
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: clamp(1.75rem, 5vw, 2.75rem);
  box-shadow: var(--shadow-lg);
  text-align: left;
}
.auth__logo { display: block; width: 120px; height: auto; margin: 0 auto 1.25rem; }
.auth h1 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: var(--step-2);
  color: var(--ink);
  text-align: center;
}
.auth__lead { margin: 0.35rem 0 1.5rem; text-align: center; color: var(--text-muted); font-size: var(--step-sm); }
.auth__note { margin: 1.5rem 0 0; font-size: var(--step-xs); color: var(--text-muted); text-align: center; }
.auth__note a { display: block; margin-top: 0.5rem; color: var(--rose); }

/* ---------------------------------------------------------
   Messages
   --------------------------------------------------------- */

.nav-badge {
  display: inline-block;
  min-width: 1.35rem;
  margin-left: 0.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--rose);
  color: #fff;
  font-size: var(--step-xs);
  font-weight: 700;
  line-height: 1.35rem;
  text-align: center;
}
.admin-nav a[aria-current="page"] .nav-badge { background: #fff; color: var(--rose); }

.stat--alert { border-color: var(--rose); }
.stat--alert .stat__value { color: var(--rose); }

.tabs { display: flex; gap: 0.35rem; margin-right: auto; }
.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: var(--step-sm);
  font-weight: 600;
}
.tabs a:hover { background: var(--surface); color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--ink); color: #fff; }
.tabs__count {
  padding: 0 0.45rem;
  border-radius: 999px;
  background: var(--line);
  color: var(--text-muted);
  font-size: var(--step-xs);
}
.tabs a[aria-current="page"] .tabs__count { background: var(--line-dark); color: #fff; }

.message-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.75rem; }

.message {
  padding: 1.25rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--radius-lg);
}
.message--unread { border-left-color: var(--rose); background: #fffdfd; }

.message__head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  align-items: baseline;
  justify-content: space-between;
}
.message__head h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--step-1);
  color: var(--ink);
}
.message__head time { color: var(--text-muted); font-size: var(--step-xs); white-space: nowrap; }

.message__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin: 0.5rem 0 0;
  font-size: var(--step-sm);
}
.message__meta li { display: flex; align-items: center; gap: 0.4rem; }
.message__meta svg { width: 0.95rem; height: 0.95rem; color: var(--rose); flex: none; }
.message__meta a { color: var(--text-muted); }
.message__meta a:hover { color: var(--rose); }

.message__body {
  margin: 1rem 0 0;
  padding: 0.9rem 1.1rem;
  background: var(--surface-2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--step-sm);
  overflow-wrap: anywhere;
}

.message__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-top: 1rem;
}

@media (max-width: 640px) {
  .admin-bar { justify-content: center; }
  .admin-bar__user { margin-left: 0; width: 100%; justify-content: space-between; }
  .toolbar__filters input { min-width: 0; flex: 1 1 12rem; }
  .tabs { width: 100%; }
}
