@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap");

/* ============================================================
   Quantum Industries — Admin dashboard
   Same paper/ink/copper identity as the storefront, run tighter:
   this is a working tool, not a shop window.
   ============================================================ */
:root {
  --paper: #f6f3ec;
  --paper-dim: #ede8dc;
  --ink: #1e2530;
  --ink-soft: #55606f;
  --line: #dcd5c4;
  --copper: #a8601f;
  --copper-dark: #7f4816;
  --copper-tint: #f1e1cd;
  --whatsapp: #2f9e58;
  --danger: #b3402f;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(30, 37, 48, 0.06), 0 6px 20px rgba(30, 37, 48, 0.07);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; }
p { margin: 0; line-height: 1.55; }
img { max-width: 100%; display: block; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius);
  padding: 11px 18px; font-size: 0.9rem; font-weight: 600; font-family: inherit;
  text-decoration: none; cursor: pointer; transition: background 0.15s ease;
}
.btn-primary { background: var(--copper); color: #fff; }
.btn-primary:hover { background: var(--copper-dark); }
.btn-primary:disabled { background: var(--ink-soft); cursor: progress; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--paper-dim); }
.btn-block { width: 100%; }
.btn-small { padding: 7px 12px; font-size: 0.82rem; }
.btn-danger { background: #fff; color: var(--danger); border-color: #e6c3bc; }
.btn-danger:hover { background: #fbeeeb; }

/* ---------- Boot & login ---------- */
.boot-view, .login-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  color: var(--ink-soft);
}
.login-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 30px; width: min(420px, 100%);
}
.login-mark {
  width: 44px; height: 44px; border-radius: 10px; background: var(--copper); color: #fff;
  font-family: var(--font-display); font-weight: 600;
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.login-card h1 { font-size: 1.4rem; }
.login-note { color: var(--ink-soft); font-size: 0.88rem; margin-top: 6px; }
.login-card label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); margin: 16px 0 6px; }
.login-card input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 0.94rem; font-family: inherit; background: var(--paper); color: var(--ink);
}
.login-card .btn { margin-top: 20px; }

/* ---------- Header ---------- */
.admin-header { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 30; }
.admin-header-inner {
  max-width: 1100px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.admin-brand { display: flex; align-items: center; gap: 12px; }
.logo-fallback {
  width: 40px; height: 40px; border-radius: 8px; background: var(--copper); color: #fff;
  font-family: var(--font-display); font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.admin-title { display: block; font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; }
.admin-user { display: block; font-size: 0.78rem; color: #aab2bd; }
.admin-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-header .btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,0.3); }
.admin-header .btn-ghost:hover { background: rgba(255,255,255,0.12); }

.admin-tabs { max-width: 1100px; margin: 0 auto; padding: 0 20px; display: flex; gap: 4px; overflow-x: auto; }
.admin-tab {
  background: none; border: 0; border-bottom: 3px solid transparent; color: #aab2bd;
  font-family: inherit; font-size: 0.92rem; font-weight: 600; padding: 10px 14px; cursor: pointer; white-space: nowrap;
}
.admin-tab:hover { color: #fff; }
.admin-tab[aria-selected="true"] { color: #fff; border-bottom-color: var(--copper); }

/* ---------- Layout ---------- */
.admin-main { max-width: 1100px; margin: 0 auto; padding: 28px 20px 60px; }
.panel { display: flex; flex-direction: column; gap: 20px; }
.panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.panel-head h2 { font-size: 1.4rem; }
.panel-note { color: var(--ink-soft); font-size: 0.86rem; margin-top: 4px; max-width: 60ch; }
.empty-note { color: var(--ink-soft); font-size: 0.9rem; }

.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-chip {
  padding: 7px 14px; border-radius: 20px; border: 1px solid var(--line); background: #fff;
  font-family: inherit; font-size: 0.82rem; font-weight: 500; color: var(--ink-soft); cursor: pointer;
}
.filter-chip.active { background: var(--copper); border-color: var(--copper); color: #fff; }

/* ---------- Forms ---------- */
.card-form { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field-wide { grid-column: 1 / -1; }
.form-field label { font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 0.92rem; font-family: inherit; background: var(--paper); color: var(--ink);
}
.form-field textarea { resize: vertical; }
.inline-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-row input[type="url"] { flex: 1 1 240px; }
.upload-label { flex-shrink: 0; }
.field-note { font-size: 0.8rem; color: var(--ink-soft); }
.field-note.ok { color: #2b6e4c; }
.field-note.error { color: var(--danger); }
.form-error { color: var(--danger); font-size: 0.85rem; margin-top: 10px; }
.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; }

/* ---------- Records ---------- */
.record-list { display: grid; gap: 10px; }
.record {
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap;
}
.record[data-status="Pending"]   { border-left-color: #d79a3b; }
.record[data-status="Confirmed"] { border-left-color: var(--copper); }
.record[data-status="Ready"]     { border-left-color: var(--whatsapp); }
.record[data-status="Collected"] { border-left-color: var(--ink-soft); }

.record-main { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.record-title { font-weight: 600; font-size: 0.98rem; }
.record-meta { font-size: 0.8rem; color: var(--ink-soft); }
.record-details { font-size: 0.88rem; color: var(--ink-soft); white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.record-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.record-side select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  font-family: inherit; font-size: 0.85rem; background: var(--paper); color: var(--ink);
}
.record-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.record-thumb { width: 64px; height: 64px; border-radius: var(--radius); object-fit: cover; border: 1px solid var(--line); flex-shrink: 0; background: var(--paper-dim); }
.wa-reply { color: var(--whatsapp); font-weight: 600; font-size: 0.82rem; text-decoration: none; }
.wa-reply:hover { text-decoration: underline; }
.tag { display: inline-block; font-size: 0.7rem; font-weight: 600; padding: 3px 9px; border-radius: 20px; background: var(--paper-dim); color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; }
.tag-hidden { background: #fbeeeb; color: var(--danger); }
.tag-popular { background: var(--copper-tint); color: var(--copper-dark); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: var(--radius);
  font-size: 0.88rem; opacity: 0; pointer-events: none; z-index: 80; max-width: 92vw; text-align: center;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-error { background: var(--danger); }

@media (max-width: 640px) {
  .record { flex-direction: column; }
  .record-side { align-items: flex-start; width: 100%; }
  .record-actions { justify-content: flex-start; }
}

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

/* ---------- Added: dialogs, status pills, branding layout ---------- */
.login-mark { color: var(--copper); background: none; width: auto; height: auto; margin-bottom: 12px; }
.admin-header .logo-fallback { color: #fff; background: var(--copper); }

.btn-tiny { padding: 5px 10px; font-size: 0.8rem; }
.btn-danger-text { color: var(--danger); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #983526; }

.status-select {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  background: #fff;
  cursor: pointer;
}
.status-Pending { color: #8a6416; border-color: #d7b878; background: #f7ecd6; }
.status-Confirmed { color: var(--copper-dark); border-color: var(--copper); background: var(--copper-tint); }
.status-Ready { color: #2b6e4c; border-color: #8cc2a5; background: #e1efe7; }
.status-Collected { color: var(--ink-soft); border-color: var(--line); background: var(--paper-dim); }

.branding-grid { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }
.card-form h3 { font-family: var(--font-display); font-size: 1.05rem; margin-bottom: 14px; }
.logo-preview-wrap {
  width: 100%; height: 130px;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper-dim); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden;
}
.logo-preview-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-placeholder { color: var(--ink-soft); font-size: 0.82rem; }
.logo-card .upload-label { margin-bottom: 8px; }

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

/* Dialogs */
dialog {
  border: none;
  border-radius: var(--radius);
  padding: 26px;
  width: 92%;
  max-width: 480px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 12px 40px rgba(30, 37, 48, 0.25);
}
dialog::backdrop { background: rgba(30, 37, 48, 0.45); }
dialog h2 { font-family: var(--font-display); font-size: 1.15rem; margin-bottom: 14px; }
dialog label {
  display: block; font-size: 0.82rem; font-weight: 600;
  color: var(--ink-soft); margin: 14px 0 6px;
}
dialog input[type="text"],
dialog input[type="number"],
dialog input[type="url"],
dialog input[type="file"],
dialog textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); font-size: 0.93rem; color: var(--ink); font-family: inherit;
}
dialog textarea { resize: vertical; }
.checkbox-row {
  display: flex; align-items: center; gap: 8px; margin-top: 16px;
  font-weight: 400; font-size: 0.9rem; color: var(--ink);
}
.checkbox-row input { width: auto; }
.image-field { display: flex; align-items: center; gap: 12px; }
.image-field img { width: 56px; height: 56px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }
.image-field input[type="file"] { flex: 1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.confirm-body p { color: var(--ink-soft); font-size: 0.92rem; }
