/* ============================================================
   MODA FÁCIL — Shared Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&display=swap');

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #273549;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --muted: #94a3b8;
  --subtle: #64748b;

  --blue: #3b82f6;
  --blue-bg: rgba(59, 130, 246, .12);
  --blue-border: rgba(59, 130, 246, .3);
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, .12);
  --green-border: rgba(34, 197, 94, .3);
  --orange: #f97316;
  --orange-bg: rgba(249, 115, 22, .12);
  --orange-border: rgba(249, 115, 22, .3);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, .13);
  --red-border: rgba(239, 68, 68, .35);
  --purple: #6366f1;
  --purple-bg: rgba(99, 102, 241, .12);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --topbar-h: 60px;
}

/* ── Tema Claro · Atelier Joana (rosé + cobre, fundo de cetim) ──────── */
[data-theme="light"] {
  --bg: #F4E7E9;
  --surface: rgba(252, 247, 248, 0.86);
  --surface2: rgba(247, 238, 240, 0.78);
  --border: rgba(176, 122, 91, 0.20);
  --text: #2A1F22;
  --text-muted: #8A6E72;
  --muted: #9A7E82;
  --subtle: #B6989E;
  --shadow-card: 0 12px 32px rgba(120, 70, 60, 0.12);
  --radius-lg: 20px;

  --primary: #B07A5B;
  --accent: #B07A5B;

  --blue: #2563eb;
  --blue-bg: rgba(37, 99, 235, .10);
  --blue-border: rgba(37, 99, 235, .25);
  --green: #16a34a;
  --green-bg: rgba(22, 163, 74, .10);
  --green-border: rgba(22, 163, 74, .25);
  --orange: #ea580c;
  --orange-bg: rgba(234, 88, 12, .10);
  --orange-border: rgba(234, 88, 12, .25);
  --red: #dc2626;
  --red-bg: rgba(220, 38, 38, .10);
  --red-border: rgba(220, 38, 38, .28);
  --purple-bg: rgba(176, 122, 91, .14);
  --purple: #B07A5B;
}

[data-theme="light"] body {
  background-color: #F4E7E9;
  background-image:
    linear-gradient(180deg, rgba(248,238,240,0.93) 0%, rgba(244,228,231,0.80) 46%, rgba(235,216,220,0.88) 100%),
    url('/img/fundo-joana.jpg');
  background-position: center top, center center;
  background-size: cover, cover;
  background-repeat: no-repeat;
  background-attachment: fixed, fixed;
}

[data-theme="light"] .topbar {
  background: rgba(250, 243, 244, 0.72);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  backdrop-filter: blur(16px) saturate(1.1);
  border-bottom: 1px solid rgba(176, 122, 91, 0.22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.55), 0 6px 22px rgba(120,70,60,0.07);
}

/* Marca em serifa + selo cobre (vale para todas as páginas no tema claro) */
[data-theme="light"] .logo-text,
[data-theme="light"] .topbar__title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 700;
  letter-spacing: .3px;
}
[data-theme="light"] .logo-badge {
  background: linear-gradient(135deg, #DCBB9E 0%, #B07A5B 52%, #8E5B40 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(142,91,64,0.35), inset 0 1px 0 rgba(255,255,255,0.45);
}
/* Painéis translúcidos viram vidro fosco sobre o tecido */
[data-theme="light"] .card,
[data-theme="light"] .section-card,
[data-theme="light"] .modal {
  -webkit-backdrop-filter: blur(12px) saturate(1.05);
  backdrop-filter: blur(12px) saturate(1.05);
  border: 1px solid rgba(176, 122, 91, 0.18);
  box-shadow: 0 10px 30px rgba(120, 70, 60, 0.08), inset 0 1px 0 rgba(255,255,255,0.5);
}
/* Inputs definidos sobre o fundo claro */
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
  background: rgba(255, 255, 255, 0.88) !important;
  border: 1px solid rgba(176, 122, 91, 0.45) !important;
  color: var(--text) !important;
  box-shadow: inset 0 1px 2px rgba(120, 70, 60, 0.05) !important;
}
[data-theme="light"] input::placeholder,
[data-theme="light"] textarea::placeholder { color: #B49AA0 !important; }
[data-theme="light"] input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
  border-color: rgba(176, 122, 91, 0.65) !important;
  box-shadow: 0 0 0 3px rgba(176, 122, 91, 0.12) !important;
}

/* ── Theme toggle switch ────────────────────────────────── */
.theme-toggle {
  width: 54px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: #253145;
  box-shadow: inset 3px 3px 6px #131a26, inset -3px -3px 6px #374864;
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0;
  margin-right: 8px;
  transition: background 0.3s, box-shadow 0.3s;
}
.theme-toggle__knob {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #253145;
  box-shadow: 2px 2px 4px #131a26, -2px -2px 4px #374864;
  display: grid;
  place-items: center;
  position: absolute;
  left: 3px;
  transform: translateX(26px);
  transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), background 0.3s, box-shadow 0.3s;
  color: #7b8ea8;
}

[data-theme="light"] .theme-toggle {
  background: #e2e8f0;
  box-shadow: inset 4px 4px 6px #c4cdd6, inset -4px -4px 6px #ffffff;
}
[data-theme="light"] .theme-toggle__knob {
  background: #e2e8f0;
  box-shadow: 3px 3px 6px #c4cdd6, -3px -3px 6px #ffffff;
  color: #94a3b8;
  transform: translateX(0);
}

/* ── 🇧🇷 Modo Copa (Brasil — tema global, igual claro/escuro) ───────── */
[data-theme="copa"] {
  --bg: #03244a;
  --surface: rgba(2, 28, 60, .64);
  --surface2: rgba(2, 46, 86, .74);
  --border: rgba(255, 212, 0, .38);
  --text: #ffffff;
  --text-muted: rgba(232, 240, 255, .80);
  --muted: rgba(232, 240, 255, .74);
  --subtle: rgba(232, 240, 255, .56);
  --shadow-card: 0 10px 30px rgba(0, 0, 0, .32);
  --radius-lg: 18px;

  --green: #22c55e;  --green-bg: rgba(34, 197, 94, .18);  --green-border: rgba(34, 197, 94, .4);
  --orange: #fb923c; --orange-bg: rgba(249, 115, 22, .2); --orange-border: rgba(249, 115, 22, .42);
  --blue: #38bdf8;   --blue-bg: rgba(56, 189, 248, .18);  --blue-border: rgba(56, 189, 248, .4);
  --red: #f87171;    --red-bg: rgba(239, 68, 68, .2);     --red-border: rgba(239, 68, 68, .42);
}
[data-theme="copa"] body {
  background:
    linear-gradient(rgba(0,18,44,.72), rgba(2,38,20,.78)),
    url('/icons/fundo.jpg') center / cover no-repeat fixed;
  color: var(--text);
}
[data-theme="copa"] .topbar {
  background: linear-gradient(90deg, #00591f 0%, #1a8f37 40%, #ffd400 100%);
  border-bottom: 3px solid #ffd400;
  box-shadow: 0 4px 18px rgba(0,0,0,.35);
  position: relative; overflow: hidden;
}
[data-theme="copa"] .topbar::before {
  content: "★ ★ ★ ★ ★"; position: absolute; left: 50%; transform: translateX(-50%); top: 50%; margin-top: -11px;
  color: #ffd400; font-size: 17px; letter-spacing: 6px; text-shadow: 0 1px 3px rgba(0,0,0,.55);
  pointer-events: none; z-index: 0;
}
[data-theme="copa"] .logo-badge {
  background: url('/icons/bola4.png') center / contain no-repeat !important;
  border-radius: 0 !important; box-shadow: none !important;
  color: #0a2a6e;
  text-shadow: 0 1px 2px rgba(255,255,255,.9), 0 0 3px rgba(255,255,255,.75);
}
[data-theme="copa"] .theme-toggle {
  background: #0a3d6b;
  box-shadow: inset 3px 3px 6px #052036, inset -3px -3px 6px #0f5aa0;
}
[data-theme="copa"] .theme-toggle__knob {
  background: #ffd400; color: #00591f;
  box-shadow: 2px 2px 4px #052036, -2px -2px 4px #0f5aa0;
  transform: translateX(26px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
}

a {
  color: inherit;
}

ul {
  list-style: none;
}

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  outline: none;
  width: 100%;
  transition: border-color .15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--purple);
}

input::placeholder {
  color: var(--subtle);
}

select option {
  background: var(--surface);
}

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-card, none);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  padding-top: env(safe-area-inset-top);
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.logo-badge {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--purple);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.topbar__title {
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text);
}

.btn-back {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--radius);
  transition: background .15s, color .15s;
}

.btn-back:hover {
  background: var(--surface2);
  color: var(--text);
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn:active {
  transform: scale(.97);
}

.btn:disabled {
  opacity: .45;
  pointer-events: none;
}

.btn--primary {
  background: var(--purple);
  color: #fff;
}

.btn--primary:hover {
  opacity: .88;
}

.btn--success {
  background: var(--green);
  color: #fff;
}

.btn--success:hover {
  opacity: .88;
}

.btn--danger {
  background: var(--red);
  color: #fff;
}

.btn--danger:hover {
  opacity: .88;
}

.btn--ghost {
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn--ghost:hover {
  color: var(--text);
  background: var(--border);
}

.btn--sm {
  padding: 7px 13px;
  font-size: 13px;
}

.btn--icon-only {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius);
}

/* ── Layout Content ──────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 20px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 800;
}

/* ── Search Bar ──────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.search-bar input {
  flex: 1;
  min-width: min(200px, 100%);
}

/* ── Table ───────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  background: var(--surface2);
  color: var(--subtle);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: 11px 14px;
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

tr:hover td {
  background: rgba(99,102,241,.08);
}

.customer-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0;
}

.customer-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-empty td {
  text-align: center;
  color: var(--subtle);
  padding: 40px;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card, none);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card, none);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.stat-card__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--subtle);
  margin-bottom: 6px;
}

.stat-card__value {
  font-size: 28px;
  font-weight: 800;
}

.stat-card__sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Badge / Chip ────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge--blue {
  background: var(--blue-bg);
  color: var(--blue);
  border: 1px solid var(--blue-border);
}

.badge--green {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}

.badge--orange {
  background: var(--orange-bg);
  color: var(--orange);
  border: 1px solid var(--orange-border);
}

.badge--red {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red-border);
}

.badge--purple {
  background: var(--purple-bg);
  color: var(--purple);
  border: 1px solid rgba(99, 102, 241, .3);
}

.badge--gray {
  background: rgba(100, 116, 139, .12);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .7);
  animation: modal-in .2s ease;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(.96);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal__title {
  font-size: 17px;
  font-weight: 700;
}

.modal__body {
  overflow-y: auto;
  padding: 20px;
  flex: 1;
  scrollbar-width: thin;
}

.modal__footer {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  justify-content: flex-end;
}

/* ── Form ────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

/* ── Toast ───────────────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  width: min(calc(100vw - 32px), 400px);
  pointer-events: none;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  pointer-events: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
  animation: toast-in .2s ease;
}

.toast--success {
  border-color: var(--green-border);
  background: var(--green-bg);
}

.toast--error {
  border-color: var(--red-border);
  background: var(--red-bg);
}

.toast--info {
  border-color: var(--blue-border);
  background: var(--blue-bg);
}

.toast.leaving {
  animation: toast-out .2s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ── Stock pill ──────────────────────────────────────────────── */
.stock-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 24px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 0 7px;
}

.stock-pill--ok {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}

.stock-pill--low {
  background: var(--orange-bg);
  color: var(--orange);
  border: 1px solid var(--orange-border);
}

.stock-pill--zero {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red-border);
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--purple);
  border-bottom-color: var(--purple);
}

/* ── Footer ──────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 30px 20px;
  font-size: 10px;
  font-weight: 500;
  color: var(--subtle);
  margin-top: auto;
  letter-spacing: 0.5px;
  width: 100%;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .page-content {
    padding: 12px;
  }

  .page-header h1 {
    font-size: 18px;
  }

  .modal__footer {
    flex-direction: column;
  }

  .modal__footer .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 400px) {
  .topbar {
    padding: 0 12px;
  }

  .page-content {
    padding: 10px;
  }
}