/* ============ POINT DOS LANCHES — Design tokens ============ */
:root {
  /* Surfaces */
  --bg: #0f0f0f;
  --surface: #111111;
  --surface-2: #161616;
  --surface-3: #1c1c1c;
  --surface-hover: #1f1f1f;
  --border: #262626;
  --border-2: #2a2a2a;
  --border-strong: #3a3a3a;

  /* Brand */
  --brand: #ff5500;
  --brand-light: #ff7a33;
  --brand-dim: rgba(255, 85, 0, 0.14);
  --brand-dim-2: rgba(255, 85, 0, 0.08);

  /* Accents */
  --wa: #25d366;
  --wa-dark: #1faa52;
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.15);
  --amber: #f5a623;
  --amber-dim: rgba(245, 166, 35, 0.15);
  --green: #34c759;
  --green-dim: rgba(52, 199, 89, 0.15);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.15);
  --purple: #a855f7;
  --purple-dim: rgba(168, 85, 247, 0.15);

  /* Text */
  --text: #f5f5f5;
  --text-2: #b8b8b8;
  --text-3: #8a8a8a;
  --text-4: #5f5f5f;

  /* Radii */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-full: 999px;

  /* Shadows */
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.55);
  --shadow-brand: 0 8px 28px rgba(255,85,0,0.28);

  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#root { min-height: 100vh; }

/* Focus visibility — accessible */
:focus-visible {
  outline: 2px solid var(--brand-light);
  outline-offset: 2px;
  border-radius: 4px;
}
button { font-family: inherit; color: inherit; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

/* ============ Reusable atoms ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text);
  padding: 11px 18px; border-radius: var(--r); font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all .15s ease; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-light); border-color: var(--brand-light); }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #05300f; }
.btn-wa:hover { background: #2ee676; border-color: #2ee676; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg { padding: 15px 24px; font-size: 17px; border-radius: var(--r-lg); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .2px;
  padding: 3px 9px; border-radius: var(--r-full); white-space: nowrap;
  border: 1px solid transparent;
}
.badge-red { background: var(--red-dim); color: #ff8080; border-color: rgba(239,68,68,.35); }
.badge-amber { background: var(--amber-dim); color: #ffc163; border-color: rgba(245,166,35,.35); }
.badge-brand { background: var(--brand-dim); color: var(--brand-light); border-color: rgba(255,85,0,.35); }
.badge-green { background: var(--green-dim); color: #5fe085; border-color: rgba(52,199,89,.35); }
.badge-blue { background: var(--blue-dim); color: #7fb0ff; border-color: rgba(59,130,246,.35); }
.badge-muted { background: var(--surface-3); color: var(--text-3); border-color: var(--border-2); }

.card {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg);
}

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
  border-radius: var(--r-full); font-size: 13px; font-weight: 600;
  background: var(--surface-3); border: 1px solid var(--border-2); color: var(--text-2);
  cursor: pointer; transition: all .15s ease;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip-active { background: var(--brand-dim); border-color: rgba(255,85,0,.4); color: var(--brand-light); }

input, textarea {
  font-family: inherit; background: var(--surface); border: 1px solid var(--border-2);
  color: var(--text); border-radius: var(--r); padding: 12px 14px; font-size: 15px; width: 100%;
  transition: border-color .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-4); }
input:focus, textarea:focus { outline: none; border-color: var(--brand); }

.muted { color: var(--text-3); }
.mono { font-variant-numeric: tabular-nums; }

/* Toggle switch */
.toggle {
  position: relative; width: 42px; height: 24px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border-2); cursor: pointer;
  transition: background .18s ease, border-color .18s ease; flex-shrink: 0; padding: 0;
}
.toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--text-3); transition: transform .18s ease, background .18s ease;
}
.toggle[data-on="true"] { background: var(--brand); border-color: var(--brand); }
.toggle[data-on="true"]::after { transform: translateX(18px); background: #fff; }

/* Animations — transform-only so a paused/frozen preview never hides content
   (the end-state, full opacity, is always the base state) */
@keyframes fadeUp { from { transform: translateY(10px); } to { transform: none; } }
@keyframes fadeIn { from { transform: translateY(4px); } to { transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes pulseRed {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.0); }
  50% { box-shadow: 0 0 0 4px rgba(239,68,68,.18); }
}
/* NB: 'forwards' (not 'both') so elements stay VISIBLE if the preview
   pauses animations at t=0 — base state must always be visible. */
.fade-up { animation: fadeUp .4s ease forwards; }
.fade-in { animation: fadeIn .3s ease forwards; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ============ Review bar (prototype context switcher) ============ */
.reviewbar {
  display: flex; align-items: center; gap: 14px; flex-shrink: 0;
  height: 50px; padding: 0 14px; background: #0a0a0a; border-bottom: 1px solid var(--border);
  position: relative; z-index: 60;
}
.reviewbar-brand { display: flex; align-items: center; gap: 8px; width: 150px; }
.reviewbar-brand span { font-size: 12px; font-weight: 700; color: var(--text-3); letter-spacing: .4px; text-transform: uppercase; }
.reviewbar-seg {
  display: flex; gap: 3px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: var(--r-full); margin: 0 auto;
}
.reviewseg {
  border: none; background: transparent; color: var(--text-2); font-weight: 600; font-size: 13.5px;
  padding: 6px 16px; border-radius: var(--r-full); cursor: pointer; transition: all .15s ease; white-space: nowrap;
}
.reviewseg:hover { color: var(--text); }
.reviewseg.active { background: var(--brand); color: #fff; }
.reviewbar-right { width: 150px; display: flex; justify-content: flex-end; }

/* ============ Header de tela — altura fixa 65px p/ a linha bater com o header
   da sidebar (que também tem 65px). Sem isso a borda de baixo cai em níveis
   diferentes em cada tela (padding variável). ============ */
.admin-header {
  height: 65px; box-sizing: border-box; flex-shrink: 0;
  padding: 0 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}

/* ============ Admin responsive ============ */
.admin-mobilebar {
  align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 16px; border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 40;
}

/* Kanban horizontal scrollbar — make it clearly visible */
.kanban-board { scrollbar-width: auto; scrollbar-color: var(--border-strong) var(--surface-2); }
.kanban-board::-webkit-scrollbar { height: 13px; }
.kanban-board::-webkit-scrollbar-track { background: var(--surface-2); border-radius: 99px; margin: 0 22px; }
.kanban-board::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid var(--surface-2); }
.kanban-board::-webkit-scrollbar-thumb:hover { background: var(--brand); }

@media (max-width: 860px) {
  .reviewbar-brand span { display: none; }
  .reviewbar-brand { width: auto; }
  .reviewbar-right { width: auto; }
  .reviewbar { gap: 8px; }
  .reviewseg { padding: 6px 11px; font-size: 12.5px; }

  .admin-sidebar { display: none !important; }
  .admin-mobilebar { display: flex !important; }
  .admin-root { flex-direction: column !important; }
  .dash-grid { grid-template-columns: 1fr !important; }
  .deliveries-grid { grid-template-columns: 1fr !important; }
  .settings-grid { grid-template-columns: 1fr !important; }
  .deliveries-grid .card[style*="sticky"] { position: static !important; }

  /* Kanban -> mobile single column + tabs */
  .kanban-board-wrap { display: none !important; }
  .kanban-mobile { display: block !important; }
  .kanban-tabs {
    display: flex !important; gap: 8px; padding: 12px 16px; overflow-x: auto;
    border-bottom: 1px solid var(--border); -webkit-overflow-scrolling: touch;
  }

  /* Conversa -> chat fills; profile becomes a slide-in drawer (see below) */

  /* Conversas split -> one pane at a time */
  .conv-split .conv-list { width: 100% !important; border-right: none !important; }
  .conv-split.has-selection .conv-list { display: none !important; }
  .conv-split:not(.has-selection) .conv-pane { display: none !important; }
}

@media (min-width: 861px) {
  .kanban-tabs, .kanban-mobile { display: none !important; }
}

/* ----- Conversa profile: column on wide, slide-in drawer on narrower ----- */
.conversa-profbtn { display: none; }
.conversa-profbackdrop { display: none; }
@media (max-width: 1200px) {
  .conversa-profbtn { display: inline-flex !important; }
  .conversa-profbackdrop { display: block; position: absolute; inset: 0; background: rgba(0,0,0,.5); z-index: 35; animation: fadeIn .2s ease; }
  .conversa-profile {
    position: absolute !important; top: 0; right: 0; bottom: 0; width: min(330px, 86%) !important;
    transform: translateX(102%); z-index: 40;
    box-shadow: -12px 0 44px rgba(0,0,0,.55);
  }
  .conversa-profile.open { transform: none; }
}

@media (max-width: 560px) {
  .settings-grid .card[style*="-1"] { grid-column: auto; }
  .rule-grid { grid-template-columns: 1fr !important; }
}

/* ============ Admin sidebar nav (server-rendered) ============ */
.admin-navlink {
  display: flex; align-items: center; gap: 11px; padding: 10px 11px;
  border-radius: 10px; border: none; cursor: pointer; text-align: left;
  font-size: 14.5px; font-weight: 600; background: transparent; color: var(--text-2);
  position: relative; transition: background .12s ease; text-decoration: none; width: 100%;
}
.admin-navlink:hover { background: var(--surface-2); color: var(--text); }
.admin-navlink.active { background: var(--brand-dim); color: var(--brand-light); }
.admin-navlink.active:hover { background: var(--brand-dim); }
.admin-navlink[aria-disabled="true"] { color: var(--text-4); cursor: default; }
.admin-navlink[aria-disabled="true"]:hover { background: transparent; color: var(--text-4); }
.admin-navlink .nav-soon {
  margin-left: auto; font-size: 9.5px; font-weight: 700; letter-spacing: .4px;
  text-transform: uppercase; color: var(--text-4); border: 1px solid var(--border-2);
  border-radius: var(--r-full); padding: 1px 6px;
}
