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

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@700;800&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;
}

/* ── Light theme (Customized Mauve/Pink Palette) ────────── */
[data-theme="light"] {
  --bg: #c7a3a3;
  --surface: #ebdada;
  --surface2: #dfcccc;
  --border: rgba(61, 43, 43, 0.08);
  --text: #4a3a3a;
  --text-muted: #7d6464;
  --muted: #8c7a7a;
  --subtle: #a69191;
  --shadow-card: 0 12px 32px rgba(61, 43, 43, 0.1);
  --radius-lg: 20px;

  --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(74, 58, 58, .12);
  --purple: #4a3a3a;
}

[data-theme="light"] body {
  background: var(--bg);
}

[data-theme="light"] .topbar {
  background: #b08e8e; /* Mauve topbar from photo */
  border-bottom-color: rgba(61, 43, 43, 0.05);
}

/* ── 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);
}

*,
*::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;
  background: linear-gradient(135deg, #818cf8 0%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: 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;
  }
}