/* ═══════════════════════════════════════════════════════════
   DHA ADMIN — MODERNIZATION OVERLAY
   Loaded AFTER admin.css. Refines depth, motion, empty states,
   command palette, last-saved stamps, activity drawer.
   ═══════════════════════════════════════════════════════════ */

:root {
  --shadow-soft: 0 1px 2px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.25);
  --shadow-lift: 0 2px 4px rgba(0,0,0,0.5), 0 16px 48px rgba(0,0,0,0.35);
  --shadow-blood: 0 0 0 1px var(--blood), 0 8px 28px rgba(227,24,55,0.35);
  --radius-md: 6px;
  --radius-lg: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ─── Body refinement ─── */
body { font-feature-settings: "ss01","cv11","liga"; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }

/* ─── Sidebar refinements ─── */
.sidebar { background: linear-gradient(180deg, #050505 0%, #020202 100%); }
.brand .logo { letter-spacing: 0.02em; }
.nav-section { position: relative; padding-top: 18px; }
.nav-section::before {
  content: ''; position: absolute; left: 14px; right: 14px; top: 8px;
  height: 1px; background: rgba(255,255,255,0.04);
}
.nav-section:first-of-type::before { display: none; }
.nav a { position: relative; transition: all 0.18s var(--ease); }
.nav a:hover { padding-left: 18px; }
.nav a.active { box-shadow: 0 4px 16px rgba(227,24,55,0.4); }
.nav a.active::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  background: #fff; border-radius: 0 2px 2px 0;
}

/* ─── Top bar refinement ─── */
.bar h1 { background: linear-gradient(180deg, #fff 0%, #c8c8c8 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.search input {
  border-radius: var(--radius-md); transition: all 0.2s var(--ease);
  background: rgba(255,255,255,0.04); backdrop-filter: blur(8px);
}
.search input:focus { background: rgba(255,255,255,0.08); border-color: var(--blood); box-shadow: 0 0 0 3px rgba(227,24,55,0.15); outline: none; }

/* ─── Buttons: subtle lift + scale + smooth ─── */
.btn {
  border-radius: var(--radius-md); position: relative; overflow: hidden;
  transition: all 0.18s var(--ease);
  letter-spacing: 0.12em;
}
.btn:not(:disabled):hover { transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.btn:not(:disabled):active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(180deg, var(--blood-light) 0%, var(--blood) 60%, var(--blood-dark) 100%);
  border: none; padding: 10px 16px;
}
.btn.primary:hover { box-shadow: 0 4px 18px rgba(227,24,55,0.5); }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* ─── Panels: depth + soft border ─── */
.panel {
  background: linear-gradient(180deg, var(--panel) 0%, #0f0f0f 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  transition: border-color 0.2s var(--ease);
}
.panel:has([data-editable]):hover { border-color: rgba(255,255,255,0.12); }
.panel-head h3 {
  background: linear-gradient(180deg, #fff 0%, #b8b8b8 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

/* ─── KPI cards: refined ─── */
.kpi {
  background: linear-gradient(135deg, #161616 0%, #0c0c0c 100%);
  border-left-width: 4px;
  border-radius: var(--radius-md);
  padding: 20px 22px;
  position: relative; overflow: hidden;
  transition: all 0.2s var(--ease);
}
.kpi::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at top right, rgba(255,255,255,0.04), transparent 60%);
  pointer-events: none;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); border-left-color: var(--blood-light); }
.kpi .val {
  background: linear-gradient(180deg, #fff 0%, #c8c8c8 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.kpi .delta { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; background: rgba(46,204,113,0.1); border-radius: 99px; }
.kpi .delta.down { background: rgba(227,24,55,0.1); }

/* ─── Tables: refined hover + sticky header ─── */
table.t thead th { background: rgba(255,255,255,0.02); position: sticky; top: 0; z-index: 1; }
table.t tbody tr { transition: all 0.12s var(--ease); }
table.t tbody tr:hover { background: rgba(227,24,55,0.04); }
table.t .status { font-weight: 700; }

/* ─── Empty states ─── */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--ash);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.empty-state .icon { font-size: 36px; opacity: 0.4; }
.empty-state .title { font-family: var(--display); font-size: 20px; color: var(--concrete); text-transform: uppercase; letter-spacing: 0.02em; }
.empty-state .desc { font-size: 12px; max-width: 360px; line-height: 1.6; }
.empty-state .cta { margin-top: 8px; }

/* ─── Skeleton loaders ─── */
@keyframes shimmer { 0% { background-position: -800px 0; } 100% { background-position: 800px 0; } }
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 100%);
  background-size: 800px 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 3px; display: inline-block; height: 14px; vertical-align: middle;
}
.skeleton-row td { padding: 16px 12px !important; }
.skeleton-row .skeleton { width: 100%; height: 12px; }

/* ─── Toast: bottom-right stack ─── */
.toast {
  top: auto !important; left: auto !important; right: 24px; bottom: 24px;
  transform: translate(140%, 0) !important; opacity: 0; max-width: 360px;
  border-radius: var(--radius-md);
  padding: 14px 20px; font-size: 12px; text-align: left;
  border: 1px solid rgba(255,255,255,0.08);
}
.toast.show { transform: translate(0, 0) !important; opacity: 1; }
.toast.ok { background: linear-gradient(135deg, #0d8a3d 0%, #096928 100%); }
.toast.err { background: linear-gradient(135deg, #c81e2e 0%, #8a1422 100%); }
.toast.warn { background: linear-gradient(135deg, #c87b18 0%, #8a5210 100%); }

/* ─── Last-saved stamp ─── */
.last-saved {
  font-family: var(--mono); font-size: 10px; color: var(--success);
  letter-spacing: 0.1em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; background: rgba(46,204,113,0.08); border-radius: 99px;
  margin-left: 8px; opacity: 0; transition: opacity 0.3s var(--ease);
}
.last-saved.visible { opacity: 1; }
.last-saved::before { content: '●'; color: var(--success); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ─── Command palette (Cmd+K) ─── */
.cmdk-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 9998; padding-top: 18vh;
}
.cmdk-overlay.open { display: flex; }
.cmdk-box {
  width: 92vw; max-width: 640px; background: var(--panel);
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift); overflow: hidden;
}
.cmdk-input {
  width: 100%; padding: 18px 22px; background: transparent;
  border: none; color: #fff; font-size: 16px; font-family: var(--body);
  border-bottom: 1px solid var(--line);
}
.cmdk-input:focus { outline: none; }
.cmdk-list { max-height: 50vh; overflow-y: auto; padding: 8px; }
.cmdk-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; cursor: pointer; border-radius: var(--radius-md);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em;
  color: var(--concrete); transition: all 0.12s var(--ease);
}
.cmdk-item:hover, .cmdk-item.active { background: rgba(227,24,55,0.1); color: #fff; }
.cmdk-item .key { padding: 3px 7px; background: rgba(255,255,255,0.05); border-radius: 3px; font-size: 10px; margin-left: auto; color: var(--ash); }
.cmdk-hint {
  padding: 10px 18px; font-family: var(--mono); font-size: 9px;
  letter-spacing: 0.18em; color: var(--ash); text-transform: uppercase;
  border-top: 1px solid var(--line); display: flex; justify-content: space-between;
}

/* ─── Activity drawer (bottom-right) ─── */
.activity-drawer {
  position: fixed; right: 16px; bottom: 16px; width: 360px; max-width: 92vw;
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lift);
  z-index: 200; overflow: hidden; transition: all 0.25s var(--ease);
}
.activity-drawer.collapsed { width: 180px; }
.activity-drawer.collapsed .activity-body { display: none; }
.activity-head {
  padding: 12px 16px; background: rgba(255,255,255,0.02);
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; border-bottom: 1px solid var(--line);
}
.activity-head .ttl { font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--concrete); }
.activity-head .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); animation: pulse 2s ease-in-out infinite; }
.activity-body { max-height: 320px; overflow-y: auto; padding: 8px 0; }
.activity-row {
  padding: 8px 16px; font-family: var(--mono); font-size: 11px;
  color: var(--concrete); border-bottom: 1px solid rgba(255,255,255,0.03);
  display: flex; gap: 10px; align-items: flex-start;
}
.activity-row:last-child { border-bottom: none; }
.activity-row .ts { color: var(--ash); flex-shrink: 0; font-size: 9px; letter-spacing: 0.08em; padding-top: 1px; }
.activity-row .msg { flex: 1; line-height: 1.4; }
.activity-row.success { border-left: 2px solid var(--success); padding-left: 14px; }
.activity-row.error { border-left: 2px solid var(--blood); padding-left: 14px; }
.activity-row.info { border-left: 2px solid var(--info); padding-left: 14px; }

/* ─── Field refinement ─── */
.field input, .field select, .field textarea {
  border-radius: var(--radius-md);
  transition: all 0.18s var(--ease);
  background: linear-gradient(180deg, #050505 0%, #080808 100%);
}
.field input:focus, .field select:focus, .field textarea:focus {
  background: linear-gradient(180deg, #080808 0%, #0c0c0c 100%);
  border-color: var(--blood); box-shadow: 0 0 0 3px rgba(227,24,55,0.12);
}

/* ─── Status badges: refined ─── */
.status { border-radius: 99px; font-weight: 700; padding: 4px 10px; box-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.status.live { background: linear-gradient(135deg, var(--blood-light) 0%, var(--blood) 100%); }
.status.shipped { background: linear-gradient(135deg, rgba(46,204,113,0.25) 0%, rgba(46,204,113,0.15) 100%); border: 1px solid rgba(46,204,113,0.3); }
.status.processing { background: linear-gradient(135deg, rgba(245,166,35,0.25) 0%, rgba(245,166,35,0.15) 100%); border: 1px solid rgba(245,166,35,0.3); }

/* ─── Flow nodes (Designer + Automations): refined ─── */
.flow-node {
  border-radius: var(--radius-md);
  transition: all 0.2s var(--ease);
}
.flow-node:hover { transform: translateX(2px); }
.flow-node .icon { font-size: 16px; }

/* ─── Product cards refined ─── */
.pcard {
  border-radius: var(--radius-md); border: 1px solid var(--line);
  transition: all 0.2s var(--ease);
}
.pcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-soft); border-color: var(--line-strong); }
.pcard .img { border-radius: 4px; }
/* Hover-flip: show back design on hover. The img wrapper has the front img +
   an absolutely-positioned back img that fades in on hover. Mirrors the
   storefront pattern in /Storefront/assets/brand.css ".product-card-img". */
.pcard .pcard-img-wrap { position: relative; display: block; }
.pcard .pcard-back {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none; border-radius: 4px;
}
.pcard:hover .pcard-back { opacity: 1; }

/* ─── Reduce visual noise from old "background:#040404" hardcodes inside panels ─── */
.panel [style*="#040404"] { border-radius: var(--radius-md); }

/* ═══════════════════════════════════════════════════════════
   MOBILE — billionaire grade. Drawer-style sidebar, stacked
   KPIs, scrollable tables, 48px tap targets, no horizontal
   overflow, no clipped controls. Triggered ≤760px wide.
   ═══════════════════════════════════════════════════════════ */

/* Hamburger button is injected by admin-modern.js. Visible only on mobile. */
.mobile-hamburger {
  display: none;
  position: fixed; top: 12px; left: 12px; z-index: 80;
  width: 44px; height: 44px;
  background: rgba(10,10,10,0.92); backdrop-filter: blur(8px);
  border: 1px solid var(--line-strong); border-radius: 8px;
  color: #fff; font-size: 22px; line-height: 1;
  display: none; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,0.45);
  transition: transform 0.15s var(--ease);
}
.mobile-hamburger:active { transform: scale(0.94); }
.mobile-hamburger-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  z-index: 70; backdrop-filter: blur(2px);
}

@media (max-width: 760px) {
  /* ── 1. SHELL: one column, sidebar drawer ── */
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 280px; max-width: 86vw;
    transform: translateX(-100%);
    transition: transform 0.28s var(--ease);
    z-index: 90; box-shadow: 8px 0 32px rgba(0,0,0,0.6);
    padding-top: 64px; /* clears the hamburger area */
  }
  .sidebar.is-open { transform: translateX(0); }
  /* Re-show full nav labels in the open drawer (admin.css hides them ≤900px) */
  .sidebar.is-open .brand .role,
  .sidebar.is-open .brand .logo span:not(.dot) { display: inline; }
  .sidebar.is-open .nav a { justify-content: space-between; }
  .sidebar.is-open .nav a span:not(.pill) { display: inline; }
  .sidebar.is-open .nav-section { display: block; }

  .mobile-hamburger { display: flex; }
  body.drawer-open .mobile-hamburger-backdrop { display: block; }

  /* ── 2. MAIN content area gets full width + comfy padding ── */
  .main { padding: 64px 14px 96px; }   /* top clears hamburger, bottom clears activity drawer */
  .bar { flex-wrap: wrap; gap: 8px; padding-left: 60px; }
  .bar h1 { font-size: 22px; }
  .bar-meta { display: none; }            /* the "MAY 16 · LIVE" meta is fluff on mobile */

  /* Search input → full width, no kbd hint (Cmd-K is desktop) */
  .search { max-width: 100%; flex: 1 1 100%; order: 99; }
  .search .kbd { display: none; }

  /* ── 3. KPIs stack 2-col on phone, 1-col on narrow phone ── */
  .kpis { grid-template-columns: 1fr 1fr !important; gap: 8px; }
  .kpi { padding: 14px 12px; }
  .kpi .val { font-size: 26px; }

  /* ── 4. PANELS lose tight margins, header wraps gracefully ── */
  .panel { padding: 14px; margin-bottom: 12px; }
  .panel-head { gap: 8px; }
  .panel-head h3 { font-size: 16px; }
  .panel-head .actions { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .panel-head .actions::-webkit-scrollbar { display: none; }

  /* ── 5. TABLES become horizontally scrollable in a wrapper ── */
  table.t {
    display: block; overflow-x: auto; -webkit-overflow-scrolling: touch;
    white-space: nowrap; max-width: 100vw;
  }
  table.t thead, table.t tbody, table.t tr { display: table; width: 100%; table-layout: auto; }
  table.t td, table.t th { padding: 10px 12px; font-size: 12px; }

  /* ── 6. BUTTONS get 44px tap targets ── */
  .btn { min-height: 44px; padding: 10px 14px; font-size: 11px; }
  .btn[style*="font-size:9px"], .btn[style*="font-size:10px"] {
    min-height: 40px; padding: 10px 12px !important; font-size: 11px !important;
  }
  .seg button { min-height: 40px; padding: 10px 12px; font-size: 10px; }

  /* ── 7. PRODUCT GRID stays a grid but 2-up on phone ── */
  .pgrid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .pcard { padding: 8px; }
  .pcard .nm { font-size: 12px; }
  .pcard .meta { font-size: 10px; }

  /* ── 8. BULK actions bar — horizontally scrollable strip ── */
  #prod-bulk-bar > div {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
  }
  #prod-bulk-bar > div::-webkit-scrollbar { display: none; }

  /* ── 9. ACTIVITY DRAWER docks bottom edge, full width when open ── */
  .activity-drawer {
    right: 0; bottom: 0; left: 0;
    width: 100%; max-width: 100vw;
    border-radius: 8px 8px 0 0;
  }
  .activity-drawer.collapsed {
    width: 130px; right: 8px; left: auto; bottom: 8px;
    border-radius: 8px;
  }
  .activity-body { max-height: 35vh; }

  /* ── 10. COMMAND PALETTE adapts to small viewports ── */
  .cmdk-box { max-width: calc(100vw - 24px); margin: 60px 12px 0; }
  .cmdk-list { max-height: 60vh; }

  /* ── 11. INLINE detail/modal drawers (product detail, etc) ── */
  #dha-product-detail, .modal, [class*="detail"] {
    max-width: 100vw !important; max-height: 100vh !important;
  }

  /* ── 12. FORMS: inputs need to be readable, not iOS-zoom-triggering ── */
  input, select, textarea {
    font-size: 16px !important;   /* prevents iOS Safari from auto-zooming on focus */
    min-height: 44px;
  }
  textarea { min-height: 88px; }

  /* ── 13. HIDE the persistent admin sanity banners on mobile (clutter) ── */
  div[style*="background:#e31837"][style*="margin-bottom:14px"] { display: none; }
}

@media (max-width: 480px) {
  /* Tighter: full single-col KPIs on small phones */
  .kpis { grid-template-columns: 1fr !important; }
  .pgrid { grid-template-columns: 1fr; }
  .panel-head h3 { font-size: 14px; }
  .main { padding: 60px 10px 96px; }
}
