/* Mounjaro — design tokens + componentes. Contrato visual em brand.md.
   Dois temas via html[data-theme]: claro (padrão) e escuro (paleta Dracula).
   O tema é aplicado antes do primeiro paint por um script inline no <head>. */

:root,
html[data-theme="light"] {
  /* Marca */
  --primary:      #6C63FF;
  --primary-dark: #5A52D5;

  /* Status (escurecidos p/ contraste sobre fundo claro) */
  --success: #1FA85C;
  --warning: #C07C10;
  --danger:  #D93025;

  /* Superfícies */
  --dark:   #F4F5FA;   /* fundo da página (nome mantido por compat.) */
  --card:   #FFFFFF;
  --card2:  #4E46C8;   /* par do gradiente do header */

  /* Texto e bordas */
  --text:       #1E2235;
  --text-muted: #6B7285;
  --border:     #E3E5F0;

  --shadow: 0 1px 3px rgba(30, 34, 53, .08);
  --on-primary: #FFFFFF;   /* texto sobre --primary */
}

html[data-theme="dark"] {
  /* Marca (roxo Dracula) */
  --primary:      #BD93F9;
  --primary-dark: #A679F0;

  /* Status (Dracula) */
  --success: #50FA7B;
  --warning: #FFB86C;
  --danger:  #FF5555;

  /* Superfícies (Dracula — suave, sem quase-preto) */
  --dark:   #282A36;
  --card:   #343746;
  --card2:  #44475A;

  /* Texto e bordas */
  --text:       #F8F8F2;
  --text-muted: #9AA5CE;
  --border:     #44475A;

  --shadow: none;
  --on-primary: #282A36;   /* roxo Dracula é claro — texto escuro por cima */
}

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

body {
  background: var(--dark);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
}

/* ============ Header ============ */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 16px;
  background: linear-gradient(135deg, var(--primary), var(--card2));
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header h1 { font-size: 20px; font-weight: 700; color: #fff; }
.header .subtitle { font-size: 12px; color: rgba(255,255,255,.7); margin-top: 2px; }
.header .btn-icon {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}

/* ============ Páginas ============ */
.page { display: none; padding: 16px; }
.page.active { display: block; }
.page-title-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.page-title { font-size: 17px; font-weight: 700; }
.section-title { font-size: 13px; color: var(--text-muted); font-weight: 600; margin: 18px 0 10px; }

/* ============ Bottom nav ============ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1;
  min-height: 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  background: none; border: none;
  color: var(--text-muted);
  font-size: 10px; font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--primary); }

/* ============ Cards ============ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.summary-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.summary-card .label { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.summary-card .value { font-size: 22px; font-weight: 700; }

/* ============ Badges ============ */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green  { background: color-mix(in srgb, var(--success) 16%, transparent);    color: var(--success); }
.badge-yellow { background: color-mix(in srgb, var(--warning) 16%, transparent);    color: var(--warning); }
.badge-red    { background: color-mix(in srgb, var(--danger) 16%, transparent);     color: var(--danger);  }
.badge-purple { background: color-mix(in srgb, var(--primary) 16%, transparent);    color: var(--primary); }
.badge-gray   { background: color-mix(in srgb, var(--text-muted) 16%, transparent); color: var(--text-muted); }

/* ============ Botões ============ */
.btn {
  border: none;
  border-radius: 12px;
  min-height: 44px;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:disabled { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); width: 100%; }
.btn-primary:active { background: var(--primary-dark); transform: scale(.98); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-whatsapp {
  background: color-mix(in srgb, var(--success) 14%, transparent);
  color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 35%, transparent);
}
.btn-whatsapp:disabled { opacity: .4; }
.btn-add {
  background: var(--primary);
  color: var(--on-primary);
  width: 40px; height: 40px; min-height: 40px;
  border-radius: 12px;
  font-size: 22px;
  padding: 0;
}

/* ============ Formulários ============ */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.form-input {
  width: 100%;
  background: var(--dark);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  padding: 12px;
  min-height: 44px;
}
.form-input:focus { outline: none; border-color: var(--primary); }
select.form-input { appearance: none; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-hint.warn { color: var(--warning); }

/* ============ Modais (slide-up) ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,.7);
  display: none;
  align-items: flex-end;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card);
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 24px 24px 0 0;
  padding: 10px 16px calc(24px + env(safe-area-inset-bottom));
  animation: slideUp .3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle {
  width: 40px; height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 6px auto 14px;
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 16px; }

/* ============ Listas / itens ============ */
.list-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.list-item .info { flex: 1; min-width: 0; }
.list-item .title { font-size: 15px; font-weight: 600; }
.list-item .sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.list-item .actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.list-item .badges { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

/* ============ Tabs (chips) ============ */
.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 14px;
  padding-bottom: 4px;
}
.tab {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  padding: 8px 14px;
  white-space: nowrap;
  cursor: pointer;
}
.tab.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* ============ Barra de progresso (consumo do lote) ============ */
.progress { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; margin-top: 8px; }
.progress .fill { height: 100%; border-radius: 3px; background: var(--primary); }

/* ============ Kanban (funil do Início) ============ */
.kanban {
  display: flex;
  align-items: flex-start; /* cada coluna com a própria altura */
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 6px;
  scroll-snap-type: x proximity;
}
.kanban::-webkit-scrollbar { height: 5px; }
.kanban::-webkit-scrollbar-track { background: transparent; }
.kanban::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.kanban { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.kanban-col {
  min-width: 220px;
  max-width: 240px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
  scroll-snap-align: start;
}
/* Desktop: as 6 fases cabem na tela — grade sem scroll horizontal */
@media (min-width: 900px) {
  .kanban {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    overflow-x: visible;
  }
  .kanban-col { min-width: 0; max-width: none; }
}
.kanban-col .col-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 10px;
}
.kanban-col .col-title .count {
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  color: var(--primary);
  border-radius: 8px;
  padding: 1px 7px;
  font-size: 11px;
}
.kanban-card {
  background: var(--dark);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
  user-select: none;
  -webkit-user-select: none;
}
.kanban-col.drop-alvo {
  border-color: var(--primary);
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
}
.kanban-card .title { font-size: 14px; font-weight: 600; }
.kanban-card .sub { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.kanban-card .acao { margin-top: 8px; }
.kanban-col .vazio { font-size: 12px; color: var(--text-muted); text-align: center; padding: 12px 0; }

/* ============ Estados ============ */
.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}
.empty .icon { font-size: 48px; opacity: .4; margin-bottom: 10px; }
.loading { text-align: center; color: var(--text-muted); padding: 30px; }
.error-msg { color: var(--danger); font-size: 13px; text-align: center; padding: 12px; }

/* ============ Login ============ */
#login {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--dark);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#login.hidden { display: none; }
.login-box { width: 100%; max-width: 340px; text-align: center; }
.login-box .logo { font-size: 44px; margin-bottom: 12px; }
.login-box h1 { font-size: 22px; margin-bottom: 4px; }
.login-box p { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }
.login-box .form-input { text-align: center; margin-bottom: 12px; }

.hidden { display: none !important; }
