/* ─── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w:    230px;
  --sidebar-bg:   #1a1d2e;
  --sidebar-text: #9095b0;
  --sidebar-act:  #ffffff;
  --accent:       #c0392b;
  --accent-dark:  #a93226;
  --bg:           #f0f2f7;
  --card:         #ffffff;
  --border:       #e2e6ef;
  --text:         #1c1e2b;
  --muted:        #888;
  --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  /* status colours */
  --c-requested:  #2980b9;
  --c-processing: #e67e22;
  --c-completed:  #27ae60;
  --c-cancelled:  #7f8c8d;
}

html, body { height: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Admin layout ─────────────────────────────────────────────────────────── */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.brand-logo {
  width: 36px; height: 36px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-weight: 800;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-name { color: #fff; font-weight: 700; font-size: 15px; }
.brand-sub  { color: var(--sidebar-text); font-size: 11px; }

.sidebar-nav {
  list-style: none;
  padding: 12px 10px;
  flex: 1;
}
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav li a:hover,
.sidebar-nav li a.active {
  background: rgba(255,255,255,0.07);
  color: var(--sidebar-act);
  text-decoration: none;
}
.sidebar-nav li a.active {
  background: rgba(192,57,43,0.25);
  color: #fff;
}
.sidebar-nav li a svg { opacity: 0.7; }

/* ─── Accordion nav sections ───────────────────────────────────────────────── */
.sidebar-nav details > summary {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav details > summary::-webkit-details-marker { display: none; }
.sidebar-nav details > summary:hover,
.sidebar-nav details[open] > summary {
  background: rgba(255,255,255,0.07);
  color: var(--sidebar-act);
}
.sidebar-nav details > summary svg:first-child { opacity: 0.7; flex-shrink: 0; }

.nav-arrow {
  margin-left: auto;
  opacity: 0.4;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.sidebar-nav details[open] .nav-arrow { transform: rotate(90deg); }

.sidebar-nav details > a {
  display: flex;
  align-items: center;
  padding: 7px 12px 7px 37px;
  border-radius: 6px;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav details > a:hover { background: rgba(255,255,255,0.07); color: var(--sidebar-act); text-decoration: none; }
.sidebar-nav details > a.active { background: rgba(192,57,43,0.25); color: #fff; }

/* ─── Sidebar footer links ─────────────────────────────────────────────────── */
.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-footer-link,
.logout-link {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--sidebar-text);
  font-size: 13px;
  padding: 5px 0;
  transition: color 0.15s;
}
.sidebar-footer-link:hover,
.logout-link:hover { color: #fff; text-decoration: none; }

/* ─── Main area ────────────────────────────────────────────────────────────── */
.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-x: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.topbar h2 { font-size: 17px; font-weight: 700; color: var(--text); }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-user { font-size: 13px; color: var(--muted); white-space: nowrap; }

.back-link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; color: var(--muted);
}
.back-link:hover { color: var(--accent); text-decoration: none; }

.page-body {
  padding: 24px 28px;
  flex: 1;
}

/* ─── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  padding: 11px 14px;
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: 13.5px;
  line-height: 1.5;
}
.alert-success {
  background: #eafaf1; border: 1px solid #27ae60; color: #1e8449;
}
.alert-error {
  background: #fdf3f2; border: 1px solid #c0392b; color: #a93226;
}

/* ─── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border-radius: 5px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-decoration: none !important;
  white-space: nowrap;
}
.btn-primary  { background: var(--accent);  color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-block { width: 100%; justify-content: center; padding: 11px; }
.btn-xs { padding: 4px 10px; font-size: 12px; background: #fff; border-color: var(--border); color: var(--text); }
.btn-xs:hover { background: var(--bg); }

/* ─── Status tabs ──────────────────────────────────────────────────────────── */
.status-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.status-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  text-decoration: none !important;
  transition: all 0.15s;
}
.status-tab:hover { border-color: #aaa; color: var(--text); }
.status-tab.active { color: #fff; border-color: transparent; }
.status-tab.active:not([class*="tab-"])    { background: var(--text);         }
.status-tab.active.tab-requested           { background: var(--c-requested);  }
.status-tab.active.tab-processing          { background: var(--c-processing); }
.status-tab.active.tab-completed           { background: var(--c-completed);  }
.status-tab.active.tab-cancelled           { background: var(--c-cancelled);  }

.tab-count {
  background: rgba(0,0,0,0.12);
  color: inherit;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
}
.status-tab.active .tab-count { background: rgba(255,255,255,0.25); }

/* ─── Search bar ───────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}
.search-input {
  flex: 1;
  max-width: 420px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13.5px;
  background: var(--card);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.1);
}

/* ─── Table ────────────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead tr {
  background: #f7f8fc;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f9fafc; }

.cell-id   { color: var(--muted); font-size: 13px; }
.cell-sub  { font-size: 12px; color: var(--muted); margin-top: 2px; }
.cell-date { font-size: 13px; white-space: nowrap; }
.text-muted { color: var(--muted); }

/* ─── Status badges ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  color: #fff;
}
.badge-requested  { background: var(--c-requested);  }
.badge-processing { background: var(--c-processing); }
.badge-completed  { background: var(--c-completed);  }
.badge-cancelled  { background: var(--c-cancelled);  }

/* ─── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  font-size: 13px;
}
.page-btn {
  padding: 6px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 13px;
}
.page-btn:hover { background: var(--bg); text-decoration: none; }
.page-info { color: var(--muted); }

/* ─── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* ─── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 14.5px; font-weight: 600; }

/* ─── View page ────────────────────────────────────────────────────────────── */
.view-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 860px) { .view-grid { grid-template-columns: 1fr; } }

.detail-table { padding: 4px 0; }
.detail-row {
  display: flex;
  padding: 11px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { flex: 0 0 150px; font-size: 13px; color: var(--muted); }
.detail-value { flex: 1; font-size: 13.5px; }

.status-form { padding: 20px; }
.status-guide {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
}
.status-guide p { margin-bottom: 8px; font-weight: 600; color: var(--text); }
.status-guide ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.status-guide li { display: flex; align-items: center; gap: 8px; }

/* ─── Form fields ──────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 600;
  color: #333;
}
.field-hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
  margin-left: 6px;
}
.field input[type="text"],
.field input[type="password"],
.field input[type="email"],
.field select,
.field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13.5px;
  color: var(--text);
  background: #fafbfc;
  font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.1);
  background: #fff;
}
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath fill='%23666' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
}
.code-textarea {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace !important;
  font-size: 12.5px !important;
  resize: vertical;
  min-height: 120px;
}
.status-select { max-width: 220px; }

/* ─── Template page ────────────────────────────────────────────────────────── */
.template-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}
.template-tab {
  padding: 8px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  border-radius: 6px 6px 0 0;
  text-decoration: none !important;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s;
}
.template-tab:hover { color: var(--text); }
.template-tab.active {
  color: var(--accent);
  border-color: var(--border);
  border-bottom-color: #fff;
  background: var(--card);
}

.template-grid {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) { .template-grid { grid-template-columns: 1fr; } }

.card-editor .field { padding: 0 20px; }
.card-editor .field:first-of-type { padding-top: 18px; }
.card-editor .btn  { margin: 0 20px 20px; }

.card-placeholders { padding: 0; }
.placeholder-intro {
  padding: 14px 16px 8px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}
.placeholder-list {
  list-style: none;
  padding: 0 0 8px;
}
.placeholder-list li {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.placeholder-tag {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 12px;
  color: #c0392b;
  background: #fdf3f2;
  padding: 2px 6px;
  border-radius: 3px;
  display: inline-block;
  transition: background 0.15s;
}
.placeholder-tag:hover { background: #fad7d3; }
.placeholder-desc { font-size: 12px; color: var(--muted); }
.placeholder-tip {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ─── Login page ───────────────────────────────────────────────────────────── */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--sidebar-bg);
}
.login-card {
  background: var(--card);
  border-radius: 10px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}
.login-brand {
  text-align: center;
  margin-bottom: 24px;
}
.login-logo {
  width: 48px; height: 48px;
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
}
.login-brand h1 { font-size: 18px; font-weight: 700; margin-bottom: 2px; }
.login-brand p  { font-size: 13px; color: var(--muted); }

.login-card .field { margin-bottom: 14px; }
.login-card .btn-block { margin-top: 8px; }

/* Setup page */
.setup-note {
  background: #fff8e1;
  border: 1px solid #f9a825;
  border-radius: 5px;
  padding: 10px 14px;
  font-size: 13px;
  color: #5d4037;
  margin-bottom: 20px;
  line-height: 1.5;
}
