/**
 * Contraste e tipografia — painéis com toggle de tema (lojista, admin, portal).
 *
 * IMPORTANTE: regras de modo claro só em html.theme-panel / html.theme-portal.
 * Login (theme-auth) tem estilo próprio — não herda html:not(.dark) global.
 */
:root {
  --aguia-text: #020617;
  --aguia-text-muted: #1e293b;
  --aguia-text-subtle: #334155;
  --aguia-text-faint: #475569;
}

html.dark {
  --aguia-text: #f1f5f9;
  --aguia-text-muted: #cbd5e1;
  --aguia-text-subtle: #94a3b8;
  --aguia-text-faint: #64748b;
}

html {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════
   MODO CLARO — só painéis com toggle (lojista / admin)
═══════════════════════════════════════════════════════════════ */
html.theme-panel:not(.dark),
html.theme-portal:not(.dark) {
  color-scheme: light;
}

html.theme-panel:not(.dark) body,
html.theme-portal:not(.dark) body {
  color: var(--aguia-text);
}

html.theme-panel:not(.dark) body.bg-white,
html.theme-panel:not(.dark) body.bg-slate-50,
html.theme-portal:not(.dark) body.bg-white,
html.theme-portal:not(.dark) body.bg-slate-50 {
  color: var(--aguia-text);
}

html.theme-panel:not(.dark) .text-slate-900,
html.theme-panel:not(.dark) .text-slate-800,
html.theme-portal:not(.dark) .text-slate-900,
html.theme-portal:not(.dark) .text-slate-800 {
  color: #0f172a !important;
}

html.theme-panel:not(.dark) .text-slate-700,
html.theme-portal:not(.dark) .text-slate-700 {
  color: #0f172a !important;
}

html.theme-panel:not(.dark) .text-slate-600 {
  color: var(--aguia-text-muted) !important;
}

html.theme-panel:not(.dark) .text-slate-500 {
  color: var(--aguia-text-subtle) !important;
}

html.theme-panel:not(.dark) .text-slate-400 {
  color: var(--aguia-text-faint) !important;
}

/* Portal claro — contraste mais forte que o painel lojista */
html.theme-portal:not(.dark) .text-slate-600 {
  color: #1e293b !important;
}

html.theme-portal:not(.dark) .text-slate-500 {
  color: #334155 !important;
}

html.theme-portal:not(.dark) .text-slate-400 {
  color: #475569 !important;
}

html.theme-panel:not(.dark) .text-slate-300 {
  color: #64748b !important;
}

html.theme-portal:not(.dark) .text-slate-300 {
  color: #334155 !important;
}

html.theme-panel:not(.dark) .help-text,
html.theme-panel:not(.dark) .fiscal-ac-label,
html.theme-panel:not(.dark) .fiscal-ac-empty,
html.theme-panel:not(.dark) .ap-field-label,
html.theme-panel:not(.dark) .field-rule--optional,
html.theme-panel:not(.dark) .fiscal-rules-legend,
html.theme-panel:not(.dark) #billing-countdown-lbl,
html.theme-panel:not(.dark) .sidebar-label {
  color: var(--aguia-text-subtle) !important;
}

html.theme-panel:not(.dark) th {
  color: var(--aguia-text-muted) !important;
}

html.theme-panel:not(.dark) .user-role-btn {
  color: var(--aguia-text-subtle);
}

html.theme-panel:not(.dark) label.text-xs,
html.theme-panel:not(.dark) .label.text-xs {
  color: var(--aguia-text-muted) !important;
}

html.theme-panel:not(.dark) .text-xs.text-slate-500,
html.theme-panel:not(.dark) .text-xs.text-slate-600,
html.theme-panel:not(.dark) .text-xs.text-slate-400 {
  color: var(--aguia-text-muted) !important;
}

html.theme-panel:not(.dark) .text-sm.text-slate-500,
html.theme-panel:not(.dark) .text-sm.text-slate-600,
html.theme-panel:not(.dark) .text-sm.text-slate-400 {
  color: var(--aguia-text-muted) !important;
}

html.theme-panel:not(.dark) .text-\[10px\].text-slate-500,
html.theme-panel:not(.dark) .text-\[10px\].text-slate-600,
html.theme-panel:not(.dark) .text-\[11px\].text-slate-500,
html.theme-panel:not(.dark) .text-\[11px\].text-slate-600 {
  color: var(--aguia-text-muted) !important;
}

html.theme-panel:not(.dark) .sidebar-link:not(:hover) {
  color: var(--aguia-text-subtle) !important;
}

html.theme-panel:not(.dark) .input,
html.theme-panel:not(.dark) input.input,
html.theme-panel:not(.dark) textarea.input,
html.theme-panel:not(.dark) select.input {
  color: var(--aguia-text) !important;
}

html.theme-panel:not(.dark) .input::placeholder,
html.theme-panel:not(.dark) input::placeholder,
html.theme-panel:not(.dark) textarea::placeholder {
  color: #64748b !important;
  opacity: 1;
}

html.theme-panel:not(.dark) .nav-item:not(.active),
html.theme-panel:not(.dark) .bottom-nav-item:not(.active) {
  color: var(--aguia-text-subtle);
}

/* Portal claro — inputs e nav */
html.theme-portal:not(.dark) .input,
html.theme-portal:not(.dark) input.input,
html.theme-portal:not(.dark) textarea.input {
  color: var(--aguia-text) !important;
}

html.theme-portal:not(.dark) .input::placeholder,
html.theme-portal:not(.dark) input::placeholder,
html.theme-portal:not(.dark) textarea::placeholder {
  color: #64748b !important;
  opacity: 1;
}

html.theme-portal:not(.dark) .nav-link:not(.active) {
  color: var(--aguia-text-subtle) !important;
}

/* ═══════════════════════════════════════════════════════════════
   MODO ESCURO — painéis
═══════════════════════════════════════════════════════════════ */
html.dark .text-slate-700:not([class*="dark:text-"]),
html.dark .text-slate-600:not([class*="dark:text-"]),
html.dark .text-slate-500:not([class*="dark:text-"]) {
  color: #94a3b8;
}

html.dark .text-slate-400:not([class*="dark:text-"]) {
  color: #cbd5e1;
}

html.dark .help-text,
html.dark .fiscal-ac-label,
html.dark .fiscal-ac-empty,
html.dark .ap-field-label,
html.dark .field-rule--optional,
html.dark .fiscal-rules-legend,
html.dark #billing-countdown-lbl {
  color: #94a3b8;
}

html.dark th {
  color: #94a3b8;
}

html.dark .user-role-btn {
  color: #94a3b8;
}

.cal-day.today {
  color: #111;
}

html.dark .bg-\[var\(--accent\)\].dark\:text-white,
html.dark .bg-amber-400.dark\:text-white,
html.dark .bg-amber-500.dark\:text-white {
  color: #111 !important;
}

.period-btn.bg-accent,
.bg-accent {
  background: var(--accent);
  color: #111 !important;
}

html.dark .period-btn:not(.bg-accent) {
  color: #e2e8f0;
}

html.dark input.input::placeholder,
html.dark .input::placeholder {
  color: #94a3b8;
  opacity: 1;
}

html.dark input::placeholder,
html.dark textarea::placeholder {
  color: #94a3b8;
  opacity: 1;
}

/* Portal escuro — reforço de contraste */
html.theme-portal.dark .text-slate-500 {
  color: #94a3b8 !important;
}

html.theme-portal.dark .text-slate-600 {
  color: #cbd5e1 !important;
}

html.theme-portal.dark .text-slate-400 {
  color: #cbd5e1 !important;
}

html.theme-portal.dark .nav-link:not(.active) {
  color: #cbd5e1 !important;
}

html.theme-portal.dark .input {
  color: #f8fafc !important;
}

html.theme-portal.dark .input::placeholder {
  color: #94a3b8 !important;
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════
   LOGIN — tema fixo escuro-suave (sem toggle), sempre legível
═══════════════════════════════════════════════════════════════ */
html.theme-auth {
  color-scheme: dark;
}

html.theme-auth body.page-auth {
  color: #e2e8f0;
  background: linear-gradient(160deg, #1e293b 0%, #0f172a 45%, #111827 100%) !important;
}

html.theme-auth .label {
  color: #e2e8f0 !important;
}

html.theme-auth .text-slate-500 {
  color: #94a3b8 !important;
}

html.theme-auth .text-slate-600 {
  color: #cbd5e1 !important;
}

html.theme-auth .text-slate-400 {
  color: #cbd5e1 !important;
}

html.theme-auth .text-slate-300 {
  color: #e2e8f0 !important;
}

html.theme-auth .text-slate-700 {
  color: #94a3b8 !important;
}

html.theme-auth .btn-secondary {
  color: #cbd5e1 !important;
  border-color: #475569 !important;
}

html.theme-auth .btn-secondary:hover {
  color: #f1f5f9 !important;
  border-color: #64748b !important;
}

html.theme-auth .input-icon-wrap .icon,
html.theme-auth .input-icon-wrap .icon-right {
  color: #94a3b8 !important;
}

html.theme-auth input,
html.theme-auth .input-field,
html.theme-auth .otp-box {
  color: #f8fafc !important;
}

html.theme-auth input::placeholder {
  color: #94a3b8 !important;
  opacity: 1;
}

html.theme-auth .btn-primary {
  color: #111 !important;
}

html.theme-auth #merchant-modal .modal-card p.text-slate-500,
html.theme-auth #merchant-modal .modal-card p.text-slate-600,
html.theme-auth #merchant-modal .modal-card span.text-slate-400,
html.theme-auth #merchant-modal .modal-card span.text-slate-600 {
  color: #cbd5e1 !important;
}

html.theme-auth a.text-slate-600 {
  color: #cbd5e1 !important;
}

html.theme-auth a.text-slate-600:hover {
  color: #f1f5f9 !important;
}

/* ═══════════════════════════════════════════════════════════════
   Telas largas — px fixo do Tailwind não escala com rem
═══════════════════════════════════════════════════════════════ */
@media (min-width: 1280px) {
  html {
    font-size: 17px;
  }

  .text-\[9px\],
  .text-\[10px\] {
    font-size: 0.75rem !important;
    line-height: 1.35 !important;
  }

  .text-\[11px\] {
    font-size: 0.8125rem !important;
    line-height: 1.4 !important;
  }

  .sidebar-label,
  .badge,
  .help-text,
  .ap-field-label,
  .fiscal-ac-label,
  html.theme-auth .label {
    font-size: 0.75rem;
  }

  html.theme-auth .text-\[10px\],
  html.theme-auth .text-\[11px\],
  html.theme-portal .text-\[10px\],
  html.theme-portal .text-\[11px\] {
    font-size: 0.8125rem !important;
    line-height: 1.4 !important;
  }
}

@media (min-width: 1536px) {
  html {
    font-size: 18px;
  }
}
