/* ============================================================
   Imagina Lab — Design System
   Cores extraídas do logo: amarelo #FFFF66 · menta #66FFCC · índigo #3A0BA7
   Fontes: Poppins (títulos, botões, números, menu) · Open Sans (textos e explicações)
   ============================================================ */
:root {
  /* Marca */
  --amarelo: #ffff66;
  --menta: #66ffcc;
  --indigo: #3a0ba7;
  --indigo-700: #2d0885;
  --indigo-100: #e3daf8;
  --indigo-50: #f1ecfc;
  --menta-100: #ddfcef;
  --menta-200: #c4f7e1;

  /* Menu / áreas escuras (cinza-roxo) */
  --roxo-900: #2a2438;
  --roxo-800: #352e47;
  --roxo-700: #453d5b;
  --roxo-texto: #d5cee6;
  --roxo-mute: #9a91b3;

  /* Neutros e semânticos */
  --bg: #f8f6fd;
  --panel: #ffffff;
  --surface-2: #f5f2fc;
  --border: #e4def3;
  --text: #231b3a;
  --text-mute: #6a6182;
  --danger: #d92d20;
  --success: #087a59;

  /* Compatibilidade com o código existente */
  --accent: var(--indigo);
  --accent-dark: var(--indigo-700);

  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(42, 36, 56, 0.05), 0 4px 14px rgba(42, 36, 56, 0.04);

  --font-display: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-text: "Open Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
}

[hidden] { display: none !important; }

/* ---------- Estrutura ---------- */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.main {
  padding: 28px 36px;
  max-width: 1100px;
  min-width: 0;
}

.main h2 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 700;
  color: var(--indigo);
  letter-spacing: -0.01em;
}
.main .subtitle {
  font-family: var(--font-text);
  color: var(--text-mute);
  font-size: 14px;
  margin-bottom: 24px;
}

/* ---------- Menu lateral ---------- */
.sidebar {
  background: var(--roxo-900);
  color: var(--roxo-texto);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 22px;
}
.sidebar-brand img { width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0; }
.sidebar-brand strong { display: block; font-size: 16px; font-weight: 700; color: var(--amarelo); line-height: 1.1; }
.sidebar-brand span { display: block; font-family: var(--font-text); font-size: 11px; color: var(--roxo-mute); margin-top: 3px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--roxo-texto);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  margin-bottom: 4px;
}
.nav-item .nav-ico { width: 20px; height: 20px; flex-shrink: 0; color: var(--amarelo); display: inline-flex; }
.nav-item .nav-ico svg { width: 20px; height: 20px; }
.nav-item:hover { background: var(--roxo-800); }
.nav-item.active {
  background: var(--roxo-800);
  color: #fff;
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--amarelo);
}

.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--roxo-700); }
.sidebar-user { font-family: var(--font-text); font-size: 12px; padding: 0 12px 10px; color: var(--roxo-mute); }
.sidebar-user strong { display: block; font-family: var(--font-display); color: #fff; font-size: 13px; }

/* ---------- Tela de acesso ---------- */
.auth-root {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--amarelo);
  position: relative;
  overflow: hidden;
}
/* manchas menta, como no logo */
.auth-root::before,
.auth-root::after {
  content: "";
  position: absolute;
  background: var(--menta);
  border-radius: 58% 42% 52% 48% / 46% 56% 44% 54%;
  pointer-events: none;
}
.auth-root::before { width: 420px; height: 380px; top: -170px; right: -130px; }
.auth-root::after { width: 360px; height: 340px; bottom: -150px; left: -120px; }

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 3px solid var(--indigo);
  border-radius: 24px;
  box-shadow: 6px 6px 0 var(--indigo);
  padding: 26px 26px 28px;
}
.auth-logo { display: block; width: 132px; height: 132px; border-radius: 26px; margin: 0 auto 14px; }
.auth-card h1 { margin: 0 0 4px; font-size: 21px; font-weight: 700; color: var(--indigo); text-align: center; }
.auth-card .subtitle { font-family: var(--font-text); color: var(--text-mute); font-size: 13px; margin-bottom: 18px; text-align: center; }
.auth-card label { margin-top: 12px; }
.auth-card .btn { width: 100%; margin-top: 20px; padding: 12px 16px; }
.auth-erro { font-family: var(--font-text); color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 16px; }
.auth-ok { font-family: var(--font-text); color: var(--success); font-size: 13px; margin-top: 12px; }

/* ---------- Cartões e formulários ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.card .card-sub { font-family: var(--font-text); color: var(--text-mute); font-size: 13px; margin-bottom: 14px; }

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

label {
  font-family: var(--font-text);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mute);
  display: block;
  margin-bottom: 4px;
}

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--text);
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(102, 255, 204, 0.55);
}
input::placeholder { color: #a79fbd; }

/* ---------- Botões ---------- */
button.btn {
  padding: 9px 18px;
  border-radius: 10px;
  border: none;
  background: var(--indigo);
  color: #fff;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
button.btn:hover { background: var(--indigo-700); }
button.btn:active { transform: translateY(1px); }
button.btn:focus-visible { outline: 3px solid var(--menta); outline-offset: 2px; }
button.btn.secondary { background: var(--menta-100); color: var(--indigo); }
button.btn.secondary:hover { background: var(--menta-200); }
button.btn.danger { background: transparent; color: var(--danger); padding: 4px 8px; }
button.btn.danger:hover { background: #fde8e6; }

/* ---------- Tabelas ---------- */
table { width: 100%; border-collapse: collapse; font-family: var(--font-text); font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-mute); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
td:first-child { font-family: var(--font-display); font-weight: 700; }
tr:last-child td { border-bottom: none; }

.empty { font-family: var(--font-text); color: var(--text-mute); font-size: 13px; padding: 12px 0; }

.badge {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 100px;
  background: var(--amarelo);
  color: var(--indigo);
}

/* ---------- Indicadores ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.stat .label { font-family: var(--font-text); font-size: 12px; color: var(--text-mute); margin-bottom: 6px; }
.stat .value { font-size: 22px; font-weight: 700; color: var(--indigo); }

.placeholder { font-family: var(--font-text); text-align: center; padding: 60px 20px; color: var(--text-mute); }

/* ---------- Fila de impressão (Kanban) ---------- */
.kanban-scroll { overflow-x: auto; padding-bottom: 8px; }

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 260px));
  gap: 14px;
  align-items: start;
  width: max-content;
  min-width: 100%;
}

.kanban-col { background: var(--indigo-50); border-radius: var(--radius-lg); padding: 10px; min-height: 120px; }

.kanban-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--indigo);
  padding: 4px 6px 10px;
}
.kanban-col-header span:first-child { display: inline-flex; align-items: center; gap: 8px; }
.kanban-col-header span:first-child::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amarelo);
  box-shadow: inset 0 0 0 2px var(--indigo);
}
.kanban-col:nth-child(2) .kanban-col-header span:first-child::before { background: var(--menta); }
.kanban-col:nth-child(3) .kanban-col-header span:first-child::before { background: var(--indigo); }
.kanban-col:nth-child(4) .kanban-col-header span:first-child::before { background: var(--success); box-shadow: inset 0 0 0 2px var(--success); }

.kanban-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 13px;
  cursor: grab;
}
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: 0.4; }
.kanban-card .cliente { font-weight: 700; margin-bottom: 2px; }
.kanban-card .itens { font-family: var(--font-text); color: var(--text-mute); font-size: 12px; margin-bottom: 6px; }
.kanban-card .meta { display: flex; justify-content: space-between; font-family: var(--font-text); font-size: 12px; color: var(--text-mute); }
.kanban-card .acoes { display: none; }

/* ============================================================
   MOBILE / APP
   ============================================================ */
.topbar, .tabbar { display: none; }

.tabbar .ico {
  width: 54px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 15px;
  transition: background .15s;
}
.tabbar svg, .sheet-item svg { width: 24px; height: 24px; }

@media (min-width: 768px) {
  .sheet, .sheet-overlay { display: none !important; }
}

/* Toque: botões de mover cartões (arrastar é pouco confiável) */
@media (max-width: 767px), (pointer: coarse) {
  .kanban-card { cursor: default; }
  .kanban-card .acoes {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }
  .kanban-card .acoes button {
    flex: 1;
    min-height: 40px;
    border: 1.5px solid var(--border);
    background: var(--surface-2);
    color: var(--indigo);
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
  }
  .kanban-card .acoes button:active { background: var(--indigo-100); }
  .kanban-card .acoes button:disabled { opacity: .35; }
}

@media (max-width: 767px) {
  body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }

  .app { display: block; min-height: 100dvh; }
  .sidebar { display: none; }

  /* Topo amarelo com contorno índigo, como o logo */
  .topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 20;
    padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
    background: var(--amarelo);
    border-bottom: 3px solid var(--indigo);
  }
  .topbar-logo { width: 36px; height: 36px; border-radius: 10px; }
  .topbar-title { font-size: 18px; font-weight: 700; letter-spacing: -.01em; color: var(--indigo); }

  .main { padding: 14px 12px calc(92px + env(safe-area-inset-bottom)); max-width: none; }
  .main > h2, .main > .subtitle { display: none; }

  .card { padding: 14px; border-radius: var(--radius-lg); margin-bottom: 14px; }
  .card h3 { font-size: 16px; }

  /* Barra de abas escura com ícones amarelos */
  .tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--roxo-900);
    box-shadow: 0 -4px 18px rgba(42, 36, 56, .25);
  }
  .tabbar button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-height: 54px;
    padding: 4px 2px;
    border: 0;
    background: none;
    color: var(--roxo-mute);
    font-family: var(--font-display);
    font-size: 10.5px;
    font-weight: 400;
    cursor: pointer;
  }
  .tabbar button .ico { color: var(--amarelo); opacity: .72; }
  .tabbar button.active { color: #fff; font-weight: 700; }
  .tabbar button.active .ico { background: var(--roxo-700); opacity: 1; }

  /* Folha "Mais" */
  .sheet-overlay { position: fixed; inset: 0; z-index: 40; background: rgba(20, 14, 34, .55); }
  .sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    max-height: 85vh;
    overflow-y: auto;
    padding: 8px 12px calc(16px + env(safe-area-inset-bottom));
    background: var(--roxo-900);
    color: #fff;
    border-radius: 22px 22px 0 0;
    animation: subir .22s ease-out;
  }
  @keyframes subir { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  .sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--roxo-700); margin: 6px auto 12px; }
  .sheet-user { padding: 4px 10px 12px; font-family: var(--font-text); font-size: 13px; color: var(--roxo-mute); border-bottom: 1px solid var(--roxo-700); margin-bottom: 6px; }
  .sheet-user strong { display: block; font-family: var(--font-display); color: #fff; font-size: 16px; }
  .sheet-item {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 52px;
    padding: 12px 10px;
    border: 0;
    border-radius: 12px;
    background: none;
    color: #fff;
    font-family: var(--font-display);
    font-size: 16px;
    text-align: left;
    cursor: pointer;
  }
  .sheet-item:active { background: var(--roxo-800); }
  .sheet-item svg { color: var(--amarelo); flex-shrink: 0; }
  .sheet-item.perigo, .sheet-item.perigo svg { color: #ff9a92; }
  .sheet-sep { height: 1px; background: var(--roxo-700); margin: 6px 0; }

  /* Formulários confortáveis ao toque (16px evita o zoom automático do iOS) */
  input, select { min-height: 44px; font-size: 16px; padding: 10px 12px; border-radius: 10px; }
  label { font-size: 12px; margin-bottom: 5px; }
  button.btn { min-height: 44px; border-radius: 10px; font-size: 15px; }
  button.btn.danger { min-height: 40px; padding: 8px 12px; }

  .grid-form { grid-template-columns: 1fr 1fr; gap: 12px 10px; }
  .grid-form > div:has(> select),
  .grid-form > div:has(> input[type="text"]),
  .grid-form > div:has(> input[type="date"]),
  .grid-form > div:has(> input[type="password"]) { grid-column: 1 / -1; }

  [data-subtab] { flex: 1; }

  /* Ações principais ocupam a largura toda */
  .main .card button.btn:not(.secondary):not(.danger),
  .main .card [data-role="add-insumo"],
  .main .card [data-role="add-item"],
  .main .card [data-role="cancel"],
  .main .card [data-role="copy"] { width: 100%; }
  .main .card [data-role="cancel"] { margin-top: 8px; }

  /* Linhas dinâmicas (insumos, itens do pedido/orçamento) */
  .linha-item { flex-wrap: wrap; }
  .linha-item select { flex: 1 1 100% !important; }
  .linha-item input { flex: 1 1 0 !important; min-width: 0; }

  /* Indicadores */
  .stat-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px; border-radius: 12px; }
  .stat .value { font-size: 18px; }
  .stat-row .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }

  /* Tabelas viram lista de cartões */
  .main table, .main thead, .main tbody, .main tr, .main td { display: block; }
  .main thead { display: none; }
  .main tr {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    margin-bottom: 10px;
  }
  .main td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 5px 0;
    border: 0;
    text-align: right;
    overflow-wrap: anywhere;
  }
  .main td::before {
    content: attr(data-label);
    flex-shrink: 0;
    color: var(--text-mute);
    font-size: 12px;
    font-weight: 600;
    text-align: left;
  }
  .main td:first-child { justify-content: flex-start; font-size: 15px; font-weight: 700; text-align: left; }
  .main td:first-child::before { display: none; }
  .main td[data-label=""] { justify-content: flex-end; gap: 8px; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
  .main td[data-label=""]::before { display: none; }

  /* Kanban: uma coluna por vez, deslizando */
  .kanban-scroll { margin: 0 -12px; padding: 0 12px 8px; scroll-snap-type: x mandatory; scroll-padding: 0 12px; }
  .kanban-board { grid-template-columns: repeat(4, 84vw); gap: 10px; }
  .kanban-col { scroll-snap-align: start; }

  .auth-card { padding: 22px; }
  .auth-logo { width: 116px; height: 116px; }
}
