/* Global sizing reset so padding/borders are included in element widths. */
* {
  box-sizing: border-box;
}

/* Admin theme tokens: change these to recolour the dashboard in one place. */
:root {
  --green-deepest: #031612;
  --green-deep: #08241e;
  --green-main: #12382f;
  --wood: #8a5f38;
  --wood-soft: #c29a68;
  --paper: #eee9dd;
  --paper-soft: #e4ddce;
  --soft-black: #171814;
  --muted: #62685f;
  --line: rgba(8, 36, 30, 0.14);
  --danger: #9f2f2f;
}

/* Default admin page background, text colour, and font. */
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(
      circle at 88% 8%,
      rgba(194, 154, 104, 0.18),
      transparent 32%
    ),
    var(--paper);
  color: var(--soft-black);
  font-family: "Barlow", system-ui, sans-serif;
}

/* Utility class used by admin.js to swap the login screen and dashboard. */
.hidden {
  display: none !important;
}

button,
input {
  /* Form controls inherit the admin font. */
  font: inherit;
}

.login-screen {
  /* Full-page centered login screen. */
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(
      circle at 22% 18%,
      rgba(194, 154, 104, 0.18),
      transparent 32%
    ),
    linear-gradient(135deg, var(--green-deepest), var(--green-deep));
}

.login-card {
  /* Glassy login box that contains the password form. */
  width: min(480px, 100%);
  display: grid;
  gap: 28px;
  padding: clamp(26px, 5vw, 44px);
  border: 1px solid rgba(238, 233, 221, 0.12);
  border-radius: 30px;
  background: rgba(238, 233, 221, 0.08);
  color: var(--paper);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

.admin-brand {
  /* Logo + name link used on both login screen and dashboard header. */
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
  color: inherit;
  text-decoration: none;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-brand img {
  /* Circular logo badge. */
  width: 42px;
  height: 42px;
  object-fit: contain;
  padding: 7px;
  border-radius: 999px;
  background: var(--paper);
}

.kicker {
  /* Small uppercase label above major headings. */
  margin: 0 0 12px;
  color: var(--wood-soft);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  /* Removes default top margin so card/section spacing stays consistent. */
  margin-top: 0;
}

.login-card h1,
.dashboard-hero h1 {
  /* Big condensed headings for login and dashboard hero. */
  margin-bottom: 12px;
  font-family: "Barlow Condensed", "Barlow", sans-serif;
  font-size: clamp(3rem, 8vw, 5.8rem);
  line-height: 0.9;
  letter-spacing: -0.06em;
  text-transform: uppercase;
}

.login-note,
.dashboard-hero p,
.security-note {
  /* Muted explanatory copy. */
  color: rgba(238, 233, 221, 0.68);
  line-height: 1.65;
}

.login-form {
  /* Password form layout. */
  display: grid;
  gap: 16px;
}

.login-form label,
.search-box {
  /* Label + input stacks used by the login form and dashboard search. */
  display: grid;
  gap: 8px;
}

.login-form span,
.search-box span {
  /* Small uppercase labels above inputs. */
  color: var(--wood-soft);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.login-form input,
.search-box input {
  /* Shared input styling for password and dashboard search. */
  width: 100%;
  min-height: 54px;
  padding: 0 18px;
  border: 1px solid rgba(238, 233, 221, 0.16);
  border-radius: 16px;
  background: rgba(238, 233, 221, 0.09);
  color: var(--paper);
  outline: none;
}

.search-box input {
  /* Search input switches to a light style on the paper dashboard. */
  background: #f4f0e7;
  border-color: var(--line);
  color: var(--soft-black);
}

.login-form input::placeholder {
  color: rgba(238, 233, 221, 0.48);
}

.search-box input::placeholder {
  color: #7d837a;
}

.login-form button,
.header-actions button,
.tool-buttons button,
.receipt-actions button {
  /* Shared rounded button style across login, header, tools, and receipt actions. */
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--wood-soft), var(--wood));
  color: var(--green-deepest);
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.error-message {
  /* Login error text. Kept at a minimum height so the form does not jump. */
  min-height: 1.3em;
  margin: 0;
  color: #ffd0d0;
  font-weight: 700;
}

.security-note {
  /* Small note under the login form. */
  margin: 0;
  font-size: 0.92rem;
}

.security-note code {
  color: var(--wood-soft);
}

.dashboard {
  /* Main admin dashboard wrapper. */
  min-height: 100vh;
}

.admin-header {
  /* Sticky dashboard top bar. */
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(18px, 4vw, 54px);
  background: rgba(3, 22, 18, 0.9);
  color: var(--paper);
  backdrop-filter: blur(14px);
}

.header-actions {
  /* View-site link and logout button group. */
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-actions a {
  color: rgba(238, 233, 221, 0.78);
  text-decoration: none;
  font-weight: 800;
}

.dashboard-hero,
.tools-panel,
.receipts-area {
  /* Shared max-width wrapper for dashboard sections. */
  width: min(1180px, calc(100% - 36px));
  margin-inline: auto;
}

.dashboard-hero {
  /* Dashboard title area with stats on the right. */
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 32px;
  align-items: end;
  padding: clamp(52px, 7vw, 94px) 0 34px;
}

.dashboard-hero p {
  max-width: 660px;
  color: var(--muted);
}

.stats-grid {
  /* Three metric cards: total, new, and latest date. */
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
}

.stats-grid article {
  /* Individual dashboard metric card. */
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper-soft);
}

.stats-grid span {
  display: block;
  color: var(--green-deep);
  font-family: "Barlow Condensed", "Barlow", sans-serif;
  font-size: 2rem;
  font-weight: 900;
}

.stats-grid p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.tools-panel {
  /* Search box plus export/clear buttons row. */
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 26px;
}

.tool-buttons {
  /* Export JSON, export CSV, and clear-all buttons. */
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tool-buttons button {
  min-height: 48px;
  background: var(--green-deep);
  color: var(--paper);
}

button.danger,
.danger {
  /* Red destructive-action styling for clear/delete buttons. */
  background: var(--danger) !important;
  color: white !important;
}

.empty-state {
  /* Message shown when there are no saved contact submissions. */
  padding: 38px;
  border: 1px dashed rgba(8, 36, 30, 0.18);
  border-radius: 24px;
  text-align: center;
  background: rgba(255, 255, 255, 0.28);
}

.empty-state h2 {
  margin-bottom: 8px;
}

.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

.receipt-list {
  /* Vertical list where admin.js renders receipt cards. */
  display: grid;
  gap: 18px;
  padding-bottom: 72px;
}

.receipt-card {
  /* One saved contact-form submission. */
  padding: clamp(20px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.34),
      rgba(255, 255, 255, 0.08)
    ),
    var(--paper-soft);
  box-shadow: 0 18px 48px rgba(3, 22, 18, 0.07);
}

.receipt-top {
  /* Receipt title area: name/details on the left, status pill on the right. */
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.receipt-id {
  /* Small receipt/submission identifier. */
  margin-bottom: 8px;
  color: var(--wood);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.receipt-name {
  /* Customer name heading inside each receipt card. */
  margin: 0;
  color: var(--soft-black);
  font-family: "Barlow Condensed", "Barlow", sans-serif;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
  text-transform: uppercase;
}

.receipt-status {
  /* "New" / "Read" status badge. */
  align-self: start;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(8, 36, 30, 0.1);
  color: var(--green-deep);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.receipt-details {
  /* Four-column metadata grid: email, phone, service, and date. */
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}

.receipt-details div,
.message-box {
  /* Small inset boxes inside a receipt card. */
  padding: 16px;
  border: 1px solid rgba(8, 36, 30, 0.1);
  border-radius: 16px;
  background: rgba(238, 233, 221, 0.52);
}

.receipt-details dt,
.message-box span {
  /* Labels inside receipt detail boxes. */
  margin-bottom: 6px;
  color: var(--wood);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.receipt-details dd,
.message-box p {
  /* Actual saved values inside receipt detail boxes. */
  margin: 0;
  color: var(--soft-black);
  overflow-wrap: anywhere;
}

.message-box p {
  /* Preserves line breaks in the submitted message. */
  line-height: 1.65;
  white-space: pre-wrap;
}

.receipt-actions {
  /* Mark-read and delete buttons at the bottom of each receipt card. */
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.receipt-actions button {
  min-height: 42px;
  background: var(--green-deep);
  color: var(--paper);
}

@media (max-width: 880px) {
  /* Tablet layout: stack hero/tools and reduce receipt details to two columns. */
  .dashboard-hero,
  .tools-panel {
    grid-template-columns: 1fr;
  }

  .stats-grid,
  .receipt-details {
    grid-template-columns: 1fr 1fr;
  }

  .tool-buttons {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  /* Phone layout: stack header/action rows and make buttons full width. */
  .admin-header,
  .header-actions,
  .receipt-top,
  .receipt-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-grid,
  .receipt-details {
    grid-template-columns: 1fr;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions button,
  .header-actions a,
  .tool-buttons button {
    width: 100%;
    text-align: center;
  }
}
