﻿/* =========================================================
   Calculadora ML — Cabr@lves Tecnologia
   Mobile-first. Dois temas: dark (padrão) e champagne.
   ========================================================= */

:root {
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="dark"] {
  --bg: #0E0E0F;
  --surface: #1A1A1C;
  --surface-raised: #222225;
  --border: #2E2C27;
  --gold: #C9A227;
  --gold-light: #E8C766;
  --text: #F2F0EA;
  --text-muted: #9A968C;
  --success: #4CAF7D;
  --danger: #D9534F;
  --overlay: rgba(6, 6, 6, 0.72);
}

[data-theme="champagne"] {
  --bg: #F5F0E6;
  --surface: #FFFFFF;
  --surface-raised: #FBF8F1;
  --border: #E3D9C4;
  --gold: #A8842A;
  --gold-light: #C9A227;
  --text: #1F1D18;
  --text-muted: #6B665A;
  --success: #2F8F5B;
  --danger: #B8443F;
  --overlay: rgba(31, 29, 24, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

button, input, select {
  font-family: inherit;
  color: inherit;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  object-fit: cover;
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.2px;
}

.brand-name em {
  font-style: normal;
  color: var(--gold);
}

.theme-toggle {
  width: 46px;
  height: 26px;
  border-radius: 20px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  padding: 0;
}

.theme-toggle-dot {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gold);
  transition: left 0.2s ease;
}

[data-theme="champagne"] .theme-toggle-dot { left: 22px; }

/* ---------- Stage / hero ---------- */
.stage {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 18px 60px;
}

.hero { margin-bottom: 28px; }

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 34px;
  line-height: 1.1;
  margin: 0 0 10px;
}

.hero-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.5;
  max-width: 48ch;
}

/* ---------- Cards (mobile: coluna única) ---------- */
.cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.tool-card:hover,
.tool-card:focus-visible {
  border-color: var(--gold);
  transform: translateY(-2px);
}

.tool-card:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.tool-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface-raised);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
}

.tool-card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
}

.tool-card-desc {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.45;
}

/* ---------- Modal: full-screen no mobile, caixa central no desktop ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: flex-end;
  z-index: 100;
}

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

.modal {
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  background: var(--bg);
  border-radius: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 2;
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 0;
}

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 15px;
}

.modal-body { padding: 18px; flex: 1; }

/* ---------- Formulários ---------- */
.modal-form fieldset {
  border: none;
  padding: 0;
  margin: 0 0 24px;
}

.modal-form legend {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--gold);
  margin-bottom: 12px;
  padding: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field[hidden] {
  display: none;
}

.field span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.field small {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.field input,
.field select {
  min-height: 48px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0 14px;
  font-size: 16px;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--gold);
}

.segmented {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.seg-btn {
  flex: 1;
  min-width: 90px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

.seg-btn.is-active {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--surface-raised);
}

.link-btn {
  background: none;
  border: none;
  color: var(--gold);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  padding: 8px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.alert-slot {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  background: rgba(217, 83, 79, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
}

.btn-primary,
.btn-secondary {
  width: 100%;
  min-height: 52px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--gold);
  color: #17150F;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  filter: brightness(1.08);
  transform: translateY(-2px);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  margin-top: 10px;
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
  border-color: var(--gold);
  transform: translateY(-2px);
}

/* ---------- Resultado ---------- */
.result-view { display: flex; flex-direction: column; gap: 16px; }
.result-view[hidden] { display: none; }

.result-hero {
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
}

.result-hero-text { text-align: left; }

.result-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.result-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 40px;
  color: var(--gold);
}

.result-title-text {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 10px;
}

.char-counter {
  font-size: 12px;
  color: var(--text-muted);
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.result-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.result-chip span {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.result-chip strong {
  font-size: 17px;
  font-weight: 700;
}

.result-breakdown {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-breakdown .row {
  display: flex;
  justify-content: space-between;
  color: var(--text);
}

/* ---------- Desktop (telas maiores) ---------- */
@media (min-width: 640px) {
  .cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .modal-overlay { align-items: center; justify-content: center; }

  .modal {
    width: 100%;
    max-width: 560px;
    height: auto;
    max-height: 88vh;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
  }

  .hero h1 { font-size: 44px; }
}

/* ---------- Topbar: sessão (nome, admin, sair) ---------- */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-name {
  font-size: 13px;
  color: var(--text-muted);
  display: none;
}

@media (min-width: 480px) {
  .user-name { display: inline; }
}

.admin-link,
.logout-btn {
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
  background: none;
  border: none;
  text-decoration: none;
  cursor: pointer;
}

/* ---------- Login ---------- */
.auth-stage {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 26px;
}

.brand-center {
  justify-content: center;
  margin-bottom: 18px;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  margin: 0 0 4px;
}

.auth-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 24px;
}

/* ---------- Admin ---------- */
.admin-h1 {
  font-family: var(--font-display);
  font-size: 30px;
  margin: 0 0 24px;
}

.admin-h3 {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--gold);
  margin: 20px 0 12px;
}

.admin-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 14px;
}

.admin-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}

.admin-section h2 {
  font-family: var(--font-display);
  font-size: 20px;
  margin: 0 0 14px;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}

.admin-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
}

.admin-row-nome {
  flex: 1 1 140px;
  font-weight: 600;
  font-size: 14px;
}

.admin-row-nome small {
  display: block;
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
}

.admin-row-input {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.admin-row-input input,
select.admin-row-input {
  min-height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 0 10px;
  font-size: 14px;
  width: 90px;
}

select.admin-row-input { width: auto; }

.admin-row-save,
.admin-row-toggle {
  min-height: 40px;
  width: auto;
  padding: 0 14px;
}


/* ---------- Banner promocional (login) ---------- */
.promo-banner {
  width: 100%;
  max-width: 380px;
  margin: 0 0 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gold);
  background: radial-gradient(circle at 30% 20%, rgba(201, 162, 39, 0.18), var(--surface) 70%);
  padding: 22px;
  text-align: center;
}

.promo-banner-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 10px;
  color: var(--gold);
}

.promo-banner-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  line-height: 1.1;
  margin: 0;
}

.promo-banner-title em {
  font-style: normal;
  color: var(--gold);
  display: block;
}

.promo-banner-sub {
  margin: 8px 0 0;
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ---------- Logo do cliente (fundo branco em chip) ---------- */
.brand-logo-chip {
  display: inline-flex;
  align-items: center;
  background: #FFFFFF;
  border-radius: 10px;
  padding: 6px 10px;
}

.brand-logo-full {
  display: block;
  height: 140px;
  width: auto;
  margin: 0 auto;
}








/* ---------- Sugestão de preço mínimo (calculadora) ---------- */
.sugestao-preco {
  color: var(--gold) !important;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Frete via API (Melhor Envio) ---------- */
.frete-api-box {
  margin-top: 14px;
  padding: 14px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.frete-api-titulo {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.frete-api-box .field {
  margin-bottom: 10px;
}

.frete-api-box .link-btn {
  margin-right: 12px;
  padding: 6px 0;
}

.frete-api-resultado {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.frete-opcao-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.frete-opcao-card:hover {
  border-color: var(--gold);
}

.frete-opcao-card.is-selected {
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.08);
}

.frete-opcao-transp {
  flex: 1;
  font-size: 13px;
  color: var(--text-muted);
}

.frete-opcao-preco {
  font-size: 15px;
  font-weight: 700;
  color: var(--gold-light);
}

.frete-opcao-prazo {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.frete-api-erro {
  margin: 0;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--danger);
  background: rgba(217, 83, 79, 0.1);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
}

.modal-sm .modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
/* ---------- Botão compacto (frete-API) ---------- */
.frete-api-acoes {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.btn-sm {
  width: auto;
  min-height: 40px;
  padding: 0 18px;
  margin-top: 0;
  font-size: 14px;
}

.btn-sm.btn-secondary {
  border-color: var(--gold);
  color: var(--gold-light);
}

.btn-sm.btn-secondary:hover {
  background: rgba(201, 162, 39, 0.1);
}