/* core/base.css — Shell e componentes dos mini apps X Drop
   Receitas de ~/webdrops/plataforma/PLATAFORMA.md. Depende de tokens.css.
   Apps estilizam POR CIMA em app/app.css — nunca editar este arquivo. */

/* ============ Reset enxuto ============ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; }
body {
  min-height: 100%;
  background: var(--wd-bg);
  color: var(--wd-text);
  font: 400 13.5px/1.45 var(--wd-body);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; }
img { max-width: 100%; display: block; }

h1, h2, h3 { font-family: var(--wd-display); font-weight: 700; }
h1 { font-size: 18px; }
h2 { font-size: 15px; }

/* Micro-labels: 9.5–10px uppercase, o carimbo tipográfico da marca */
.micro-label, .field-label, .nav-label, .crumb {
  font-family: var(--wd-display);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--wd-text-2);
}

/* ============ Motivo gota (marca) ============ */
.drop {
  width: 10px; height: 10px; flex: none;
  border-radius: 50% 50% 50% 0;
  transform: rotate(135deg);
  background: var(--wd-accent);
}

/* ============ Shell: sidebar + conteúdo ============ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 218px; flex: none;
  display: flex; flex-direction: column;
  background: var(--wd-surface);
  border-right: 1px solid var(--wd-rule-dark);
}
.logo { display: flex; align-items: center; gap: 8px; padding: 16px 14px; }
.logo .mark { font-family: var(--wd-display); font-weight: 700; font-size: 13px; letter-spacing: .02em; }

.nav { flex: 1; padding: 4px 8px; overflow-y: auto; }
.nav-label { padding: 10px 6px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  padding: 7px 8px; border: 0; border-left: 2px solid transparent;
  border-radius: var(--wd-r-md);
  background: transparent; color: var(--wd-text-2);
  font: 500 12.5px/1.2 var(--wd-body); cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--wd-accent-tint-06); color: var(--wd-text); }
.nav-item[aria-current="true"], .nav-item.active {
  border-left-color: var(--wd-accent);
  background: var(--wd-accent-tint-06);
  color: var(--wd-text);
}

.side-foot { padding: 12px 14px; border-top: 1px solid var(--wd-rule-dark); }
.foot-logo { display: inline-block; opacity: .85; transition: opacity .12s; }
.foot-logo:hover { opacity: 1; }
.foot-logo img { height: 24px; }
[data-theme="light"] .foot-logo img {
  background: var(--wd-surface-2); border-radius: 6px; padding: 4px 8px;
}

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--wd-rule);
}
.topbar .crumb { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page { flex: 1; padding: 20px; }

/* ============ Botões ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 12px/1 var(--wd-body);
  padding: 8px 13px;
  border: 1px solid var(--wd-rule); border-radius: var(--wd-r-md);
  background: transparent; color: var(--wd-text);
  cursor: pointer; transition: border-color .12s, background .12s, color .12s;
}
.btn:hover { border-color: var(--wd-accent); }
.btn:disabled { opacity: .35; cursor: default; }
.btn-primary { background: var(--wd-accent); border-color: var(--wd-accent); color: var(--wd-on-accent); }
.btn-primary:hover { background: var(--wd-accent-hover); border-color: var(--wd-accent-hover); }
.btn-danger { background: var(--wd-danger); border-color: var(--wd-danger); color: #fff; }
.btn-danger:hover { background: var(--wd-danger-hover); border-color: var(--wd-danger-hover); }
.btn-ghost { border-color: transparent; color: var(--wd-text-2); }
.btn-ghost:hover { color: var(--wd-accent); border-color: transparent; background: var(--wd-accent-tint-06); }
.btn-ghost.danger:hover { color: var(--wd-danger); background: color-mix(in srgb, var(--wd-danger) 8%, transparent); }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0;
  border: 1px solid transparent; border-radius: var(--wd-r-md);
  background: transparent; color: var(--wd-text-2); cursor: pointer;
  transition: background .12s, color .12s;
}
.btn-icon:hover { color: var(--wd-text); background: var(--wd-surface-2); border-color: var(--wd-rule); }
.btn-icon.danger:hover { color: var(--wd-accent); border-color: var(--wd-accent); }
.btn-icon:disabled { opacity: .3; cursor: default; }

/* Ícones: wrapper padrão */
.ico { display: inline-flex; width: 14px; height: 14px; flex: none; }
.ico svg { width: 100%; height: 100%; }

:focus-visible { outline: none; box-shadow: var(--wd-focus-ring); }

/* ============ Cards e listas ============ */
.card {
  background: var(--wd-surface);
  border: 1px solid var(--wd-rule);
  border-radius: var(--wd-r-md);
  padding: var(--wd-s-lg);
}
.row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--wd-rule);
  transition: background .12s;
}
.row:hover { background: var(--wd-accent-tint-06); }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font: 600 10px/1 var(--wd-body);
  text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 8px; border-radius: var(--wd-r-full);
  background: var(--wd-accent-tint-10); color: var(--wd-accent);
}
.pill.success { background: color-mix(in srgb, var(--wd-success-light) 14%, transparent); color: var(--wd-success-light); }
.pill.danger { background: color-mix(in srgb, var(--wd-danger) 14%, transparent); color: var(--wd-danger-hover); }

.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 48px 20px; text-align: center; color: var(--wd-text-2);
}
.empty-state .icon .ico { width: 34px; height: 34px; opacity: .6; }

/* ============ Stats strip ============ */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.stats .stat { padding: 10px 14px; border-right: 1px solid var(--wd-rule); }
.stats .stat:last-child { border-right: 0; }
.stats .stat .lbl { display: block; margin-bottom: 3px; }
.stats .stat .val { font-family: var(--wd-display); font-size: 19px; font-weight: 700; }

/* ============ Forms ============ */
.field-label { display: block; margin-bottom: 5px; }
.input, .modal-input {
  width: 100%;
  background: var(--wd-bg);
  border: 1px solid var(--wd-rule);
  border-radius: var(--wd-r-md);
  color: var(--wd-text);
  font: 400 13px/1 var(--wd-body);
  padding: 9px 11px;
}
.input:focus, .modal-input:focus {
  outline: none; border-color: var(--wd-accent); box-shadow: var(--wd-focus-ring);
}

/* ============ Modais (texto + confirm) ============ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: var(--wd-overlay);
  opacity: 0; visibility: hidden;
  transition: opacity .15s, visibility .15s;
  padding: 16px;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-overlay[hidden] { display: none; }
.modal {
  width: 100%; max-width: 380px;
  background: var(--wd-surface);
  border: 1px solid var(--wd-rule);
  border-radius: var(--wd-r-lg);
  padding: 18px;
  transform: scale(.97);
  transition: transform .15s;
}
.modal-overlay.active .modal { transform: scale(1); }
.modal.wide { max-width: 520px; }
.modal-title { font-family: var(--wd-display); font-size: 14px; margin-bottom: 12px; }
.modal-body { margin-bottom: 14px; }
.confirm-message { color: var(--wd-text-2); font-size: 12.5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ============ A11y ============ */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}

/* ============ Nav drawer mobile (hambúrguer) ============ */
/* Desktop: botão e scrim invisíveis. Mobile: tira mínima (logo + hambúrguer)
   e a sidebar vira drawer por cima do conteúdo (ver media query abaixo). */
.nav-toggle {
  display: none;
  width: 40px; height: 40px; flex: none;
}
.nav-toggle .ico { width: 20px; height: 20px; }
.nav-scrim {
  display: none;
  position: fixed; inset: 0; z-index: 44;
  background: rgba(0, 0, 0, .5);
}
@keyframes drawer-in { from { transform: translateX(-100%); } to { transform: translateX(0); } }

/* ============ Responsivo: tira mínima + drawer ============ */
@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  /* Tira fixa no topo: logo + hambúrguer (fora do fluxo → sem salto ao abrir) */
  .sidebar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 45;
    width: auto;
    height: calc(52px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 8px 0;
    flex-direction: row; align-items: center;
    border-right: 0; border-bottom: 1px solid var(--wd-rule-dark);
  }
  .logo { padding: 10px; flex: 1; min-width: 0; overflow: hidden; }
  .nav-toggle { display: inline-flex; }
  .nav, .side-foot { display: none; }
  .content { padding-top: calc(52px + env(safe-area-inset-top, 0px)); }

  /* Drawer aberto: painel full-height por cima do conteúdo */
  .sidebar.open {
    right: auto; bottom: 0;
    width: min(300px, 86vw);
    height: 100vh; height: 100dvh;
    padding: 0;
    flex-direction: column; align-items: stretch;
    border-right: 1px solid var(--wd-rule-dark); border-bottom: 0;
    animation: drawer-in .18s ease-out;
  }
  .sidebar.open .logo { flex: none; padding-right: 52px; }
  .sidebar.open .nav-toggle {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 6px); right: 8px;
  }
  .sidebar.open .nav {
    display: flex; flex-direction: column; gap: 2px;
    padding: 4px 8px; overflow-y: auto;
  }
  .sidebar.open .side-foot { display: block; margin-top: auto; }
  .nav-scrim.active { display: block; }

  .topbar { flex-wrap: wrap; padding: 12px 14px; }
  .page { padding: 14px; }
}
@media (hover: none) {
  .row:hover, .nav-item:hover { background: transparent; }
}
