/* ==========================================================================
   Admin panel styles — hand written, no build step, no CDN, no npm.
   Loaded via asset('css/admin.css').
   ========================================================================== */

:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --sidebar: #23211e;
  --sidebar-hover: #322f2a;
  --line: #ddd8cf;
  --ink: #26241f;
  --muted: #736d63;
  --brand: #a94430;
  --brand-dark: #8a3626;
  --brand-soft: #f6e7e2;
  --ok: #2f6b46;
  --ok-soft: #e4f1e9;
  --warn: #8a6216;
  --warn-soft: #fbf0d8;
  --danger: #a3271f;
  --danger-soft: #fae4e2;
  --info: #24596e;
  --info-soft: #e0eff4;
  --radius: 8px;
  --sidebar-w: 236px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }

/* ---------- layout ---------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
}

.sidebar__brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.sidebar__brand strong { display: block; font-size: 16px; letter-spacing: .3px; }
.sidebar__brand span { display: block; font-size: 12px; color: #a9a49b; margin-top: 2px; }

.sidebar__nav { padding: 10px 0; flex: 1; }

.sidebar__section {
  padding: 14px 18px 6px;
  font-size: 11px;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: #8f8a81;
}

.sidebar__link {
  display: block;
  padding: 10px 18px;
  color: #e9e6e0;
  text-decoration: none;
  border-left: 3px solid transparent;
  font-size: 14px;
}

.sidebar__link:hover { background: var(--sidebar-hover); }

.sidebar__link.is-active {
  background: var(--sidebar-hover);
  border-left-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

.sidebar__link.is-disabled {
  color: #7d786f;
  cursor: default;
}

.sidebar__foot { padding: 14px 18px; border-top: 1px solid rgba(255, 255, 255, .12); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 12px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar__title { font-size: 17px; font-weight: 700; margin: 0; }
.topbar__spacer { flex: 1; }
.topbar__user { text-align: right; line-height: 1.25; }
.topbar__user strong { display: block; font-size: 14px; }
.topbar__user span { font-size: 12px; color: var(--muted); }

.content { padding: 22px; max-width: 1180px; width: 100%; }

/* ---------- cards & panels ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
}

.card__head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}

.card__head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.card__body { padding: 18px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat__label {
  font-size: 11px;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.stat__value { font-size: 26px; font-weight: 800; margin-top: 4px; }

/* ---------- tables ---------- */

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

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

table.data th,
table.data td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

table.data th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  background: #faf8f5;
}

table.data tbody tr:hover { background: #fbfaf8; }

.empty {
  padding: 34px 18px;
  text-align: center;
  color: var(--muted);
}

/* ---------- badges ---------- */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-success { background: var(--ok-soft); color: var(--ok); }
.badge-warning { background: var(--warn-soft); color: var(--warn); }
.badge-danger  { background: var(--danger-soft); color: var(--danger); }
.badge-info    { background: var(--info-soft); color: var(--info); }
.badge-accent  { background: var(--brand-soft); color: var(--brand); }
.badge-muted   { background: #ece8e2; color: var(--muted); }

/* ---------- forms ---------- */

.form-row { margin-bottom: 15px; }

.form-row label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
}

.form-row .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font: inherit;
  color: var(--ink);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}

.has-error input,
.has-error select { border-color: var(--danger); background: #fffaf9; }

.field-error { color: var(--danger); font-size: 12.5px; margin-top: 4px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 16px;
}

.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }

.readonly-value {
  padding: 9px 11px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: #faf8f5;
  color: var(--muted);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-block;
  padding: 9px 15px;
  border-radius: 6px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }

.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: #f6f3ee; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }

.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.btn-link {
  background: none;
  border: none;
  color: var(--brand);
  padding: 0;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- alerts ---------- */

.alert {
  padding: 11px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid transparent;
  font-size: 14px;
}

.alert-success { background: var(--ok-soft); border-color: #bcdcc9; color: var(--ok); }
.alert-error   { background: var(--danger-soft); border-color: #eec4c0; color: var(--danger); }

.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- filters & pagination ---------- */

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filters .form-row { margin-bottom: 0; min-width: 160px; }

.pagination-wrap { padding: 14px 18px; border-top: 1px solid var(--line); }

.pagination-wrap nav { display: flex; gap: 6px; flex-wrap: wrap; }

.pagination-wrap a,
.pagination-wrap span {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  text-decoration: none;
  font-size: 13px;
  background: #fff;
}

.pagination-wrap [aria-current="page"] span {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* ---------- guest (login) ---------- */

.guest {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--sidebar);
}

.guest__card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 12px;
  padding: 28px;
}

.guest__title { margin: 0 0 4px; font-size: 21px; font-weight: 800; color: var(--brand); }
.guest__sub { margin: 0 0 20px; color: var(--muted); font-size: 13.5px; }

/* ---------- responsive ---------- */

.nav-toggle { display: none; }

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .18s ease;
  }

  .sidebar.is-open { transform: translateX(0); }

  .nav-toggle {
    display: inline-block;
    background: none;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
  }

  .content { padding: 16px; }

  .scrim {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .38);
    z-index: 40;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}
