/* Bee's Honey Store — admin panel. Clean, professional: white, gray, amber. */

:root {
  --amber: #d97706;
  --amber-dark: #b45309;
  --amber-soft: #fef3c7;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f3f4f6;
  --sidebar: #1f2937;
  --sidebar-2: #111827;
  --white: #ffffff;
  --green: #16a34a;
  --red: #dc2626;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over component display rules below
   (e.g. .login-view / .dashboard set display:grid). Without this the
   login screen and dashboard would both show at once. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

/* ── Buttons & inputs ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn-primary { background: var(--amber); color: #fff; }
.btn-primary:hover { background: var(--amber-dark); }
.btn-ghost { background: var(--white); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: #f9fafb; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.input, input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus, .input:focus {
  outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
}
label { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; font-weight: 600; color: var(--ink); }
.muted { color: var(--muted); }

.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.alert { padding: 10px 12px; border-radius: 8px; font-size: 0.88rem; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }

/* ── Login ────────────────────────────────────────────────────────────── */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.login-card {
  width: min(380px, 100%);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 36px 30px;
  display: flex; flex-direction: column; gap: 14px;
  text-align: center;
}
.login-logo {
  width: 64px; height: 64px; margin: 0 auto;
  display: grid; place-items: center;
  font-size: 2rem;
  background: var(--amber-soft);
  border-radius: 50%;
}
.login-card h1 { margin: 6px 0 0; font-size: 1.5rem; }
.login-sub { margin: 0 0 8px; color: var(--muted); font-size: 0.9rem; }
.login-card label { text-align: left; }

/* ── Dashboard layout ─────────────────────────────────────────────────── */
.dashboard { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar);
  color: #d1d5db;
  display: flex; flex-direction: column;
  padding: 22px 16px;
  gap: 8px;
}
.sidebar-logo { font-size: 1.2rem; font-weight: 700; color: #fff; padding: 6px 10px 18px; }
.sidebar-logo em { color: var(--amber); font-style: normal; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  background: transparent; border: none;
  color: #d1d5db; font: inherit; font-weight: 500;
  text-align: left;
  padding: 11px 12px; border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.is-active { background: var(--amber); color: #fff; }
.nav-ico { width: 20px; text-align: center; }
.side-foot { margin-top: auto; color: #9ca3af; text-decoration: none; font-size: 0.85rem; padding: 10px; }
.side-foot:hover { color: #fff; }

.main { padding: 22px 28px; overflow-x: hidden; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.topbar h2 { margin: 0; font-size: 1.4rem; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.welcome { color: var(--muted); font-size: 0.92rem; }

/* ── Stats ────────────────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
}
.stat-label { color: var(--muted); font-size: 0.82rem; font-weight: 500; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--ink); }

/* ── Toolbar + table ──────────────────────────────────────────────────── */
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .input { flex: 1; min-width: 200px; }

.table-wrap { background: var(--white); border: 1px solid var(--line); border-radius: 12px; overflow: auto; box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { background: #f9fafb; color: var(--muted); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafafa; }
.ta-right { text-align: right; }
.cell-img { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; background: var(--amber-soft); display: grid; place-items: center; }

.pill-status { font-size: 0.76rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.pill-status.active { background: #dcfce7; color: #166534; }
.pill-status.hidden { background: #f3f4f6; color: #6b7280; }

/* Order status badges (color coded) */
.badge { display: inline-block; font-size: 0.74rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; text-transform: capitalize; }
.badge-pending { background: #fef9c3; color: #854d0e; }
.badge-processing { background: #dbeafe; color: #1e40af; }
.badge-shipped { background: #ede9fe; color: #6d28d9; }
.badge-delivered { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }

/* Orders summary spacing */
.orders-summary { grid-template-columns: repeat(1, 1fr); }
@media (min-width: 720px) { .orders-summary { grid-template-columns: repeat(3, 1fr); } }

/* Order detail modal */
.order-detail { padding: 22px 24px; display: flex; flex-direction: column; gap: 22px; }
.order-detail h4 { margin: 0 0 10px; font-size: 0.95rem; color: var(--ink); }
.order-customer dl { margin: 0; display: grid; grid-template-columns: 1fr; gap: 8px; }
.order-customer dl > div { display: grid; grid-template-columns: 90px 1fr; gap: 10px; }
.order-customer dt { color: var(--muted); font-size: 0.85rem; }
.order-customer dd { margin: 0; font-size: 0.9rem; word-break: break-word; }
.order-items .table { border: 1px solid var(--line); border-radius: 10px; }
.order-items tfoot td { background: #f9fafb; }
.order-update .form-grid { padding: 0; }

.row-actions { display: inline-flex; gap: 8px; justify-content: flex-end; }
.link-btn { background: none; border: none; cursor: pointer; font: inherit; font-weight: 600; padding: 0; }
.link-btn.edit { color: var(--amber-dark); }
.link-btn.delete { color: var(--red); }
.link-btn:hover { text-decoration: underline; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; }

/* ── Modals ───────────────────────────────────────────────────────────── */
.modal { border: none; border-radius: 16px; padding: 0; width: min(620px, 94%); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25); }
.modal::backdrop { background: rgba(17, 24, 39, 0.5); }
.modal form, .modal.modal-sm { padding: 0; }
.modal.modal-sm { padding: 24px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.icon-button { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 22px 24px; }
.form-grid .col-2 { grid-column: 1 / -1; }
.form-grid .check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.form-grid .check input { width: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line); }
.modal.modal-sm .modal-actions { border-top: none; padding: 18px 0 0; }
#modal-error { margin: 0 24px; }

/* Slug preview + char counter */
.slug-preview { font-weight: 400; font-size: 0.78rem; color: var(--muted); }
.slug-preview code { background: #f3f4f6; padding: 1px 6px; border-radius: 5px; color: var(--amber-dark); }
.char-counter { font-weight: 400; font-size: 0.75rem; color: var(--muted); align-self: flex-end; }

/* Live image preview */
.image-preview-wrap {
  display: grid; place-items: center;
  min-height: 120px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #fafafa;
  overflow: hidden;
}
.image-preview { max-width: 100%; max-height: 200px; object-fit: contain; border-radius: 8px; }
.image-preview-empty { color: var(--muted); font-size: 0.85rem; }
#coupon-error { margin: 0 24px; }

/* Coupons */
.coupon-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.04em;
  background: #fff7ed;
  color: var(--amber-dark);
  padding: 2px 8px;
  border-radius: 6px;
}

/* Delivery / settings card */
.settings-card {
  max-width: 640px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 26px 26px;
}
.settings-card h3 { margin: 0 0 6px; }
.settings-card .form-grid { padding: 18px 0 4px; }
.settings-card .char-counter { align-self: flex-start; }
.settings-card .modal-actions { border-top: none; padding: 8px 0 0; }
#settings-error { margin: 4px 0; }

/* Toggle switch */
.switch { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  flex: none;
  width: 42px; height: 24px;
  background: #cbd5e1;
  border-radius: 999px;
  position: relative;
  transition: background 0.2s ease;
}
.switch-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease;
}
.switch input:checked + .switch-track { background: var(--amber); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.3); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translate(-50%, 120%);
  z-index: 100;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: transform 0.32s cubic-bezier(0.18, 0.89, 0.32, 1.28), opacity 0.32s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* Fast taps everywhere on the admin too. */
.btn, .nav-item, .link-btn, .icon-button, button, select { touch-action: manipulation; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (min-width: 720px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 768px) {
  .dashboard { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; flex-wrap: wrap; padding: 12px; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .nav-item { min-height: 44px; }
  .side-foot { margin: 0; }
  .form-grid { grid-template-columns: 1fr; }

  /* The product/order tables scroll horizontally inside their wrapper;
     keep columns from collapsing so the scroll is usable. */
  .table { min-width: 640px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }

  /* 16px inputs prevent iOS auto-zoom on focus; comfortable buttons. */
  input, select, textarea, .input { font-size: 16px; }
  .btn { min-height: 44px; }

  /* Full-screen, scrollable modals on small screens. */
  .modal {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .modal form { max-height: 100dvh; overflow-y: auto; }
  .modal.modal-sm { height: auto; max-height: 90dvh; border-radius: 16px; width: 92%; }
}
