@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=Sora:wght@500;700;800&display=swap");

:root {
  --forest: #2d6a4f;
  --forest-deep: #1d4634;
  --moss: #a3b18a;
  --bark: #6b3f2a;
  --cream: #f5f0e8;
  --paper: #fffdf9;
  --mist: #edf2e7;
  --charcoal: #213027;
  --danger: #9f3e2d;
  --border: rgba(45, 106, 79, 0.14);
  --shadow: 0 20px 50px rgba(20, 34, 28, 0.12);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--charcoal);
  background:
    linear-gradient(135deg, rgba(163, 177, 138, 0.16), transparent 40%),
    linear-gradient(180deg, #f6f2ea 0%, #eef4ed 100%);
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.eyebrow {
  margin: 0 0 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--forest);
}

.intro-text,
.inline-status {
  color: rgba(33, 48, 39, 0.75);
}

.login-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-card {
  width: min(100%, 460px);
  padding: 2.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.94)),
    var(--paper);
  box-shadow: var(--shadow);
}

.login-card h1,
.page-header h1,
.panel-heading h2,
.admin-header .header-brand-title {
  margin-top: 0;
  font-family: "Sora", sans-serif;
}

.auth-form,
.stack-form {
  display: grid;
  gap: 1rem;
}

.auth-form label,
.stack-form label,
.filter-control {
  display: grid;
  gap: 0.45rem;
  font-weight: 600;
}

.auth-form input,
.stack-form input,
.stack-form textarea,
.filter-control select {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.9);
}

.stack-form textarea {
  resize: vertical;
  font-family: inherit;
  font-size: inherit;
  line-height: 1.5;
}

.admin-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-header {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0 1.5rem;
  color: #f7f4ee;
  background:
    radial-gradient(circle at top left, rgba(163, 177, 138, 0.22), transparent 40%),
    linear-gradient(135deg, var(--forest-deep), #173629);
}

.header-brand {
  flex-shrink: 0;
  padding: 1rem 0;
}

.header-brand .eyebrow {
  color: rgba(247, 244, 238, 0.65);
}

.header-brand-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #f7f4ee;
}

.admin-nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.admin-nav a {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: rgba(247, 244, 238, 0.78);
  transition: background-color 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}

body[data-nav="dashboard"] .admin-nav a[data-nav-link="dashboard"],
body[data-nav="bookings"] .admin-nav a[data-nav-link="bookings"],
body[data-nav="availability"] .admin-nav a[data-nav-link="availability"],
body[data-nav="settings"] .admin-nav a[data-nav-link="settings"],
.admin-nav a:hover {
  color: #173629;
  background: rgba(245, 240, 232, 0.9);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
  padding: 0.75rem 0;
  margin-left: auto;
}

.header-user p {
  margin: 0;
  font-size: 0.9rem;
  color: rgba(247, 244, 238, 0.78);
  white-space: nowrap;
}

.admin-main {
  flex: 1;
  padding: 1.5rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.status-pill {
  padding: 0.8rem 1rem;
  border-radius: 999px;
  background: rgba(163, 177, 138, 0.18);
  color: var(--forest-deep);
}

.metric-grid,
.content-grid {
  display: grid;
  gap: 1rem;
}

.metric-grid {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 1rem;
}

.content-grid {
  grid-template-columns: repeat(2, 1fr);
}

.panel-card {
  padding: 1.4rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.narrow-panel {
  width: min(100%, 620px);
}

.metric-card span {
  display: block;
  margin-bottom: 0.75rem;
  color: rgba(33, 48, 39, 0.68);
}

.metric-card strong {
  font-family: "Sora", sans-serif;
  font-size: clamp(2rem, 4vw, 3rem);
}

.panel-heading,
.pagination-row,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.panel-heading {
  margin-bottom: 1rem;
}

.stack-list {
  display: grid;
  gap: 0.85rem;
}

.availability-slots-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.availability-slots-list {
  min-height: 0;
  max-height: min(60vh, 34rem);
  overflow-y: auto;
  padding-right: 0.35rem;
}

.availability-slots-list::-webkit-scrollbar {
  width: 0.65rem;
}

.availability-slots-list::-webkit-scrollbar-thumb {
  border: 2px solid rgba(255, 255, 255, 0);
  border-radius: 999px;
  background: rgba(45, 106, 79, 0.28);
  background-clip: padding-box;
}

.availability-slots-list::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(45, 106, 79, 0.08);
}

.stack-item {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(245, 240, 232, 0.52);
}

.stack-item h3,
.stack-item p {
  margin: 0;
}

.stack-item p + p {
  margin-top: 0.35rem;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.9rem 0.75rem;
  border-bottom: 1px solid rgba(45, 106, 79, 0.12);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(33, 48, 39, 0.66);
}

.data-table tbody tr:hover {
  background: rgba(163, 177, 138, 0.08);
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1rem;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}

.action-button-primary {
  color: #ffffff;
  background: linear-gradient(135deg, var(--forest), var(--forest-deep));
}

.action-button-secondary {
  color: var(--forest-deep);
  background: rgba(163, 177, 138, 0.2);
}

.action-button-danger {
  color: #ffffff;
  background: linear-gradient(135deg, #b24a35, var(--danger));
}

.admin-modal[hidden] {
  display: none;
}

.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(23, 54, 41, 0.42);
  backdrop-filter: blur(10px);
}

.admin-modal__dialog {
  width: min(100%, 32rem);
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  padding: 1.6rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(45, 106, 79, 0.18);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.98)),
    var(--paper);
  box-shadow: 0 24px 60px rgba(20, 34, 28, 0.2);
  outline: none;
}

.admin-modal__eyebrow {
  margin-bottom: 0.75rem;
}

.admin-modal__title {
  margin: 0 0 0.65rem;
  font-family: "Sora", sans-serif;
  font-size: clamp(1.25rem, 2.6vw, 1.65rem);
}

.admin-modal__message {
  margin: 0;
  line-height: 1.65;
  color: rgba(33, 48, 39, 0.78);
}

.admin-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.35rem;
}

.admin-modal__actions .action-button {
  min-width: 8.75rem;
}

.text-link {
  color: var(--forest-deep);
  font-weight: 700;
}

.inline-status {
  min-height: 1.4rem;
  margin: 0 0 1rem;
}

.inline-status.is-error {
  color: var(--danger);
}

.inline-status.is-success {
  color: var(--forest);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-pending {
  background: rgba(163, 177, 138, 0.18);
  color: var(--forest-deep);
}

.status-confirmed {
  background: rgba(45, 106, 79, 0.14);
  color: var(--forest);
}

.status-cancelled {
  background: rgba(159, 62, 45, 0.12);
  color: var(--danger);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.detail-card {
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(245, 240, 232, 0.5);
}

.detail-card strong {
  display: block;
  margin-bottom: 0.45rem;
  color: rgba(33, 48, 39, 0.72);
}

.detail-panel-heading {
  margin-top: 1.5rem;
}

.detail-panel-heading p {
  margin: 0.35rem 0 0;
  color: rgba(33, 48, 39, 0.68);
}

.detail-session-form {
  margin-top: 1rem;
}

.detail-session-form textarea {
  min-height: 10rem;
}

.empty-state {
  margin: 0;
  color: rgba(33, 48, 39, 0.68);
}

.pagination-row,
.action-row {
  margin-top: 1rem;
}

/* ── Availability week grid ────────────────────────────────── */

.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.week-label {
  font-family: "Sora", sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--charcoal);
  text-align: center;
}

.week-grid-wrap {
  overflow-x: auto;
}

.week-grid {
  display: grid;
  grid-template-columns: 3.75rem repeat(7, 1fr);
  gap: 3px;
  min-width: 520px;
}

.wg-corner {
  /* empty top-left cell */
}

.wg-day {
  padding: 0.4rem 0.2rem 0.65rem;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(33, 48, 39, 0.5);
  line-height: 1.2;
}

.wg-day span {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: rgba(33, 48, 39, 0.4);
}

.wg-day.is-today {
  color: var(--forest);
}

.wg-day.is-today span {
  color: var(--forest);
}

.wg-time {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(33, 48, 39, 0.38);
  white-space: nowrap;
}

.wg-cell {
  height: 2.25rem;
  border-radius: 5px;
  cursor: pointer;
  background: rgba(45, 106, 79, 0.06);
  border: 1px solid transparent;
  transition: background-color 0.1s ease, opacity 0.1s ease;
  overflow: hidden;
}

.wg-cell span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: transparent;
  pointer-events: none;
  user-select: none;
  transition: color 0.1s ease;
}

.wg-cell:hover {
  background: rgba(45, 106, 79, 0.16);
}

.wg-cell:hover span {
  color: rgba(33, 48, 39, 0.42);
}

.wg-cell.is-open {
  background: rgba(45, 106, 79, 0.7);
  border-color: rgba(45, 106, 79, 0.38);
}

.wg-cell.is-open span {
  color: rgba(255, 255, 255, 0.88);
}

.wg-cell.is-open:hover {
  background: rgba(45, 106, 79, 0.52);
}

.wg-cell.is-booked {
  background: rgba(107, 63, 42, 0.2);
  border-color: rgba(107, 63, 42, 0.18);
  cursor: default;
}

.wg-cell.is-booked span {
  color: rgba(107, 63, 42, 0.55);
}

.wg-cell.is-past {
  opacity: 0.22;
  pointer-events: none;
}

.wg-cell.is-loading {
  opacity: 0.45;
  pointer-events: none;
  cursor: wait;
}

.wg-cell.is-hour-start {
  border-top-color: rgba(45, 106, 79, 0.18);
}

.wg-time.is-half-hour {
  font-size: 0.6rem;
  color: rgba(33, 48, 39, 0.22);
}

.wg-time.is-hour-start {
  border-top: 1px solid rgba(45, 106, 79, 0.18);
}

.week-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 1.1rem;
  font-size: 0.78rem;
  color: rgba(33, 48, 39, 0.58);
}

.wg-legend-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.wg-legend-swatch {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 3px;
  background: rgba(45, 106, 79, 0.06);
  border: 1px solid rgba(45, 106, 79, 0.14);
  flex-shrink: 0;
}

.wg-legend-swatch.is-open {
  background: rgba(45, 106, 79, 0.7);
  border-color: rgba(45, 106, 79, 0.38);
}

.wg-legend-swatch.is-booked {
  background: rgba(107, 63, 42, 0.2);
  border-color: rgba(107, 63, 42, 0.18);
}

@media (max-width: 1080px) {
  .metric-grid,
  .content-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .admin-header {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
  }

  .header-user {
    margin-left: 0;
    width: 100%;
    padding: 0 0 0.5rem;
    border-top: 1px solid rgba(245, 240, 232, 0.18);
  }
}

@media (max-width: 720px) {
  .page-header,
  .panel-heading,
  .pagination-row,
  .action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-main {
    padding: 1rem;
  }

  .admin-header {
    padding: 0.75rem 1rem;
  }

  .admin-nav {
    flex-wrap: wrap;
  }

  .login-card,
  .panel-card {
    padding: 1.2rem;
  }

  .week-nav {
    flex-wrap: wrap;
    justify-content: center;
  }

  .week-label {
    width: 100%;
    order: -1;
  }

  .admin-modal {
    padding: 1rem;
  }

  .admin-modal__actions {
    flex-direction: column-reverse;
  }

  .admin-modal__actions .action-button {
    width: 100%;
  }
}

/* ── Email templates workspace ─────────────────────────────── */

.template-workspace {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.template-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.template-list-item {
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.9rem;
}

.template-list-item:hover {
  background: rgba(45, 106, 79, 0.07);
}

.template-list-item.is-active {
  background: rgba(45, 106, 79, 0.13);
  font-weight: 600;
}

.template-list-empty {
  padding: 0.75rem 0.9rem;
  font-size: 0.875rem;
  color: #888;
}

.editor-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 480px;
}

.template-editor {
  min-height: 480px;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.92rem;
  line-height: 1.55;
  tab-size: 2;
}

.template-selected-notice {
  padding: 0.65rem 0.9rem;
  background: rgba(45, 106, 79, 0.08);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--forest-deep);
}

@media (max-width: 900px) {
  .template-workspace {
    grid-template-columns: 1fr;
  }
}
