/* Tokens de tema — carregados antes do boot para splash e chrome PWA */
:root {
  color-scheme: light;

  /* Layout & Main */
  --color-main-bg: #ffffff;
  --color-main-text: #173F5F;
  --color-page-paper: #F3EFE8;

  /* Superfície chrome — fonte única: status bar, header, nav bar, splash */
  --color-chrome-surface: color-mix(in srgb, var(--color-main-bg) 90%, var(--color-table-header-bg));
  --color-header-surface: #ffffff;
  --color-header-bg: #ffffff;
  --color-header-border: #e5eaf0;
  --color-header-text: #173F5F;
  --color-header-hover-text: #0f172a;
  --color-header-hover-bg: rgba(23, 63, 95, 0.05);

  /* Sidebar — clara, leve, com personalidade suave */
  --color-sidebar-bg: #FFFFFF;
  --color-sidebar-hover: #F0F5FA;
  --color-sidebar-text: #173F5F;
  --color-sidebar-muted: #64748B;
  --color-sidebar-active-bg: #FFC300;
  --color-sidebar-active-text: #173F5F;
  --color-sidebar-card-bg: #F3EFE8;
  --color-sidebar-shadow: 0 8px 28px -10px rgba(23, 63, 95, 0.18);

  /* Tabela */
  --color-table-header-bg: #e8f0f8;
  --color-table-header-text: #173F5F;
  --color-table-border: #dae4f0;
  --color-table-row-hover: #f5faff;
  --color-table-text: #1e293b;
  --color-table-empty-text: #64748b;

  /* Modal */
  --color-modal-bg: #ffffff;
  --color-modal-text: #173F5F;
  --color-modal-overlay: rgba(0, 0, 0, 0.4);
  --color-modal-border: #dae4f0;

  /* Ações & Status */
  --color-action-primary: #FFC300;
  --color-action-primary-text: #173F5F;
  --color-action-secondary: #4F9C8F;

  /* Botões de Ação na Tabela (Exclusivo TableActions) */
  --btn-edit-bg: rgba(59, 130, 246, 0.08);
  --btn-edit-text: #3b82f6;
  --btn-delete-bg: rgba(239, 68, 68, 0.08);
  --btn-delete-text: #ef4444;

  /* Skeleton / loading placeholders */
  --color-skeleton-bg: var(--color-table-header-bg);

  /* Área de texto (textarea) — contraste sutil em relação ao fundo do form */
  --color-input-area-bg: color-mix(in srgb, var(--color-main-bg) 82%, var(--color-table-header-bg));
  --color-input-area-border: color-mix(in srgb, var(--color-table-border) 70%, var(--color-main-bg));
}

.dark {
  color-scheme: dark;

  --color-main-bg: #1e293b;
  --color-main-text: #e2e8f0;
  --color-page-paper: #1a2332;

  --color-chrome-surface: color-mix(in srgb, var(--color-main-bg) 82%, var(--color-table-border));
  --color-header-surface: var(--color-chrome-surface);
  --color-header-bg: var(--color-chrome-surface);
  --color-header-border: var(--color-table-border);
  --color-header-text: #f9fafb;
  --color-header-hover-text: #f1f5f9;
  --color-header-hover-bg: rgba(255, 255, 255, 0.08);

  --color-sidebar-bg: #0f172a;
  --color-sidebar-hover: #1e293b;
  --color-sidebar-text: #f3f4f6;
  --color-sidebar-muted: color-mix(in srgb, #f3f4f6 62%, transparent);
  --color-sidebar-active-bg: var(--color-action-primary);
  --color-sidebar-active-text: var(--color-action-primary-text);
  --color-sidebar-card-bg: color-mix(in srgb, #ffffff 8%, #0f172a);
  --color-sidebar-shadow: 0 8px 28px -10px rgba(0, 0, 0, 0.45);

  --color-table-header-bg: #1e293b;
  --color-table-header-text: #e2e8f0;
  --color-table-border: #334155;
  --color-table-row-hover: #0f172a;
  --color-table-text: #f1f5f9;
  --color-table-empty-text: #94a3b8;

  --color-modal-bg: #1e293b;
  --color-modal-text: #e2e8f0;
  --color-modal-overlay: rgba(0, 0, 0, 0.6);
  --color-modal-border: #334155;

  --btn-edit-bg: rgba(59, 130, 246, 0.2);
  --btn-edit-text: #60a5fa;
  --btn-delete-bg: rgba(239, 68, 68, 0.2);
  --btn-delete-text: #f87171;

  --color-skeleton-bg: var(--color-table-border);

  --color-input-area-bg: color-mix(in srgb, var(--color-main-bg) 88%, var(--color-table-border));
  --color-input-area-border: color-mix(in srgb, var(--color-table-border) 75%, var(--color-main-bg));
}

html,
body {
  background-color: var(--color-main-bg);
  color: var(--color-main-text);
}

/* Splash de boot — mesma cor do chrome */
.app-splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-chrome-surface);
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

.app-splash--hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.app-splash__logo {
  width: 11rem;
  height: auto;
  animation: app-splash-pulse 1.4s ease-in-out infinite;
}

.app-splash__logo--dark {
  display: none;
}

.dark .app-splash__logo--light {
  display: none;
}

.dark .app-splash__logo--dark {
  display: block;
}

/* Site institucional — splash sempre claro, independente do tema salvo do app */
html.marketing-boot .app-splash {
  background-color: #ffffff !important;
}

html.marketing-boot .app-splash__logo--light {
  display: block !important;
}

html.marketing-boot .app-splash__logo--dark {
  display: none !important;
}

html.marketing-boot.dark .app-splash__logo--light {
  display: block !important;
}

html.marketing-boot.dark .app-splash__logo--dark {
  display: none !important;
}

@keyframes app-splash-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.04);
    opacity: 0.88;
  }
}
