/* ==========================================================================
   Precificador Ideia no Bolso — folha de estilos
   ========================================================================== */

:root {
  --bg: #f2f4f8;
  --panel: #ffffff;
  --border: #e2e5ec;
  --text: #14161a;
  --muted: #6b7280;
  --primary: #1e5fd9;
  --primary-dark: #154aab;
  --accent: #0a8f5e;
  --danger: #c0392b;
  --shadow: 0 1px 3px rgba(20, 22, 26, 0.07);
  --shadow-hover: 0 10px 24px rgba(20, 22, 26, 0.10);
}

/* Segue o tema do sistema quando o usuário não escolheu manualmente ainda */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12141a;
    --panel: #1a1d26;
    --border: #2b2f3b;
    --text: #eceef2;
    --muted: #8b93a3;
    --primary: #4c8dff;
    --primary-dark: #3b73d6;
    --accent: #34d399;
    --danger: #f56565;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-hover: 0 10px 26px rgba(0, 0, 0, 0.55);
  }
}

/* Escolha manual do botão de tema, vale para os dois lados */
:root[data-theme="dark"] {
  --bg: #12141a;
  --panel: #1a1d26;
  --border: #2b2f3b;
  --text: #eceef2;
  --muted: #8b93a3;
  --primary: #4c8dff;
  --primary-dark: #3b73d6;
  --accent: #34d399;
  --danger: #f56565;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-hover: 0 10px 26px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s, color 0.2s;
}

/* ---------- Header / navegação ---------- */

header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
  transition: background-color 0.2s, border-color 0.2s;
}

header h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-kicker {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 2px;
}

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

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
  background: var(--border);
  color: var(--text);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-sun {
  display: none;
}

.theme-toggle.is-dark .icon-sun {
  display: block;
}

.theme-toggle.is-dark .icon-moon {
  display: none;
}

nav {
  display: flex;
  gap: 6px;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
}

nav button {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

nav button.active {
  background: var(--primary);
  color: #fff;
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 20px;
  flex: 1;
  width: 100%;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

/* ---------- Campos genéricos ---------- */

input[type="number"],
input[type="text"],
input[type="password"],
select {
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  color: var(--text);
  background: var(--panel);
  width: 100%;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

input[type="number"]:focus,
input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

/* ---------- Dashboard: cartão de custo ---------- */

.hero-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 30px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--primary);
}

.hero-card .hint {
  color: var(--muted);
  font-size: 13.5px;
  margin: 4px 0 22px;
  font-weight: 600;
}

.hero-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.hero-field label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.cost-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 24px;
}

.cost-field span.prefix {
  font-size: 26px;
  font-weight: 800;
  color: var(--muted);
}

#costInput {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 40px;
  font-weight: 800;
  padding: 6px 0;
  width: 220px;
  text-align: center;
}

#costInput:focus {
  outline: none;
}

/* ---------- Dashboard: cartões de canal ---------- */

.section-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 10px 2px;
  text-align: center;
}

.channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

.channel-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 18px 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.channel-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.channel-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--brand);
}

.channel-card[data-channel="tiktok"]::before {
  background: linear-gradient(90deg, #25f4ee, #fe2c55);
}

.channel-tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--brand);
  color: var(--brand-text, #fff);
  margin-bottom: 14px;
}

.channel-price {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.channel-stats {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 8px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.stat-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.stat-value.accent {
  color: var(--accent);
}

.channel-extra {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.channel-extra label {
  font-size: 11px;
  display: block;
  margin-bottom: 5px;
}

.channel-extra input,
.channel-extra select {
  padding: 7px 9px;
  font-size: 13px;
  max-width: 170px;
  text-align: center;
}

.pagamento-subfield {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---------- Configuração ---------- */

.config-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--brand, var(--primary));
  text-align: center;
}

.config-section h2 {
  font-size: 15px;
  margin: 0 0 4px 0;
  font-weight: 800;
}

.config-section .config-sub {
  font-size: 12px;
  color: var(--muted);
  margin: 0 auto 14px;
  max-width: 520px;
}

.config-section .provider-note {
  font-style: italic;
}

.grid-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 190px));
  gap: 14px 20px;
  justify-content: center;
}

.field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.grid-fields .field label {
  min-height: 2.6em;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  line-height: 1.3;
  text-align: center;
}

.field input,
.field select {
  max-width: 190px;
}

.field small {
  color: var(--muted);
  font-size: 11px;
  max-width: 190px;
}

.section-save-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.save-note-inline {
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.3s;
}

.save-note-inline.show {
  opacity: 1;
}

.tier-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
}

.tier-table th {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 6px 6px;
}

.tier-table td {
  padding: 4px 6px;
}

.tier-table input {
  padding: 7px 8px;
  font-size: 13px;
  max-width: 90px;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 14px;
}

button.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: background 0.15s;
}

button.btn:hover {
  background: var(--primary-dark);
}

button.btn.secondary {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

button.btn.secondary:hover {
  background: var(--danger);
  color: #fff;
}

button.btn-save,
button.btn-accent {
  background: var(--accent);
  padding: 8px 20px;
  font-size: 13px;
}

button.btn-save:hover,
button.btn-accent:hover {
  background: #067a4e;
}

.save-note {
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
  margin-right: 10px;
  opacity: 0;
  transition: opacity 0.3s;
}

.save-note.show {
  opacity: 1;
}

/* ---------- Rodapé ---------- */

footer.app-footer {
  text-align: center;
  padding: 18px 20px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

footer.app-footer strong {
  color: var(--text);
}

/* ---------- Login ---------- */

.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 32px;
  text-align: center;
  box-shadow: var(--shadow-hover);
}

.login-kicker {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 6px;
}

.login-title {
  font-size: 24px;
  font-weight: 800;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.login-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 26px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.login-form label {
  font-size: 12px;
}

.login-submit {
  margin-top: 8px;
  padding: 11px;
  font-size: 15px;
}

.login-footer {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.login-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.login-badge svg {
  width: 15px;
  height: 15px;
}

.login-meta {
  color: var(--muted);
  font-size: 11px;
  margin: 0;
}

.logout-btn {
  padding: 8px 14px;
  font-size: 13px;
}

/* ---------- SweetAlert2 (acompanha o tema claro/escuro do site) ---------- */

.swal2-popup {
  background: var(--panel) !important;
  color: var(--text) !important;
  border-radius: 16px !important;
}

.swal2-title,
.swal2-html-container {
  color: var(--text) !important;
}

.swal2-input,
.swal2-textarea {
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  background: var(--panel) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
}

.swal2-input:focus,
.swal2-textarea:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px var(--primary) !important;
}

.swal2-actions button {
  border-radius: 8px !important;
}

.swal2-cancel {
  background: var(--border) !important;
  color: var(--text) !important;
}

.swal2-toast {
  background: var(--panel) !important;
  color: var(--text) !important;
}

/* ---------- Responsivo ---------- */

@media (max-width: 600px) {
  header {
    padding: 12px 14px;
  }
  header h1 {
    font-size: 16px;
  }
  main {
    padding: 16px 14px;
  }
  .channel-price {
    font-size: 24px;
  }
  #costInput {
    font-size: 30px;
    width: 160px;
  }
  .hero-card {
    padding: 22px 16px;
  }
}
