/* ── Variáveis de design ────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500&display=swap');

:root {
  --color-primary:        #F25D00;
  --color-primary-dark:   #D94E00;
  --color-primary-light:  #FF7A2B;
  --color-navy:           #1A1A2E;
  --color-navy-card:      #2C2C4A;
  --color-navy-hover:     #353560;
  --color-bg:             #1A1A2E;
  --color-bg-card:        #2C2C4A;
  --color-text:           #FFFFFF;
  --color-text-muted:     rgba(255, 255, 255, 0.65);
  --color-border:         rgba(255, 255, 255, 0.08);
  --radius-btn:           4px;
  --radius-card:          12px;
  --radius-pill:          100px;
  --font-sans:            'Outfit', sans-serif;
}

/* ── Global ────────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  margin: 0;
  padding: 0;
}

.app-wrapper {
  min-height: 100vh;
  background-color: var(--color-bg);
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.dashboard-header {
  background-color: var(--color-navy);
  color: #ffffff;
  padding: 18px 0 14px;
  margin-bottom: 0;
  border-bottom: 4px solid var(--color-primary);
}

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

.header-logo {
  height: 38px;
  width: auto;
  flex-shrink: 0;
  border-radius: 6px;
}

.header-title {
  font-size: 1.45rem;
  font-weight: 500;
  color: #ffffff;
  margin-bottom: 4px;
}

.header-subtitle {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 0;
}

.update-label {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 2px;
}

.update-value {
  font-size: 0.82rem;
  color: #ffffff;
  font-weight: 500;
  margin-bottom: 6px;
}

.btn-refresh {
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: var(--radius-btn);
  background-color: var(--color-primary) !important;
  border-color: var(--color-primary) !important;
  color: #ffffff !important;
  transition: background 0.2s;
}

.btn-refresh:hover {
  background-color: var(--color-primary-dark) !important;
  border-color: var(--color-primary-dark) !important;
}

/* ── Main layout ─────────────────────────────────────────────────────────── */
.main-container {
  padding-top: 16px;
  padding-bottom: 40px;
}

/* ── Sidebar de filtros ──────────────────────────────────────────────────── */
.filter-sidebar {
  padding-right: 8px;
}

.filter-panel {
  background-color: var(--color-bg-card);
  border-radius: var(--radius-card);
  padding: 16px 12px;
  border: 1px solid var(--color-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  overflow-x: visible;
  /* Não usar overflow:hidden — cortaria o popup do calendário */
}

.filter-section-title {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 6px;
}

.filter-item {
  margin-bottom: 12px;
}

.filter-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 4px;
  display: block;
}

/* ── Dropdowns Dash — tema escuro (cobre todas as versões do Dash) ─────── */

/* Wrapper externo */
.filter-dropdown,
.filter-dropdown .dash-dropdown,
.filter-dropdown .Select {
  background-color: var(--color-navy) !important;
}

/* Controle principal (react-select v1 e v2) */
.filter-dropdown .Select-control,
.filter-dropdown .Select--multi .Select-control {
  background-color: var(--color-navy) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: var(--radius-btn) !important;
}

/* Dash 2.x — grid container e trigger */
.filter-dropdown .dash-dropdown-grid-container,
.filter-dropdown .dash-dropdown-trigger,
.filter-dropdown span.dash-dropdown-grid-container,
.filter-dropdown span.dash-dropdown-trigger {
  background-color: var(--color-navy) !important;
  color: rgba(255, 255, 255, 0.65) !important;
}

/* Textos internos */
.filter-dropdown .Select-placeholder,
.filter-dropdown .Select-value-label,
.filter-dropdown .Select-input input,
.filter-dropdown input,
.filter-dropdown .dash-dropdown-placeholder,
.filter-dropdown .dash-dropdown-value {
  background-color: transparent !important;
  color: rgba(255, 255, 255, 0.65) !important;
  font-size: 0.68rem !important;
}

/* Seta do dropdown */
.filter-dropdown .Select-arrow {
  border-top-color: rgba(255, 255, 255, 0.5) !important;
}

.filter-dropdown .Select-arrow-zone:hover .Select-arrow {
  border-top-color: #ffffff !important;
}

/* Menu aberto */
.filter-dropdown .Select-menu-outer,
.filter-dropdown .Select-menu {
  background-color: #252545 !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: var(--radius-btn) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5) !important;
  font-size: 0.68rem !important;
  z-index: 9999 !important;
}

/* Opções */
.filter-dropdown .Select-option,
.filter-dropdown .VirtualizedSelectOption {
  background-color: #252545 !important;
  color: rgba(255, 255, 255, 0.8) !important;
  font-size: 0.68rem !important;
  padding: 5px 10px !important;
}

.filter-dropdown .Select-option.is-focused,
.filter-dropdown .VirtualizedSelectOption:hover {
  background-color: var(--color-navy-hover) !important;
  color: #ffffff !important;
}

.filter-dropdown .Select-option.is-selected {
  background-color: var(--color-primary) !important;
  color: #ffffff !important;
}

/* Tags de valores selecionados (multi) */
.filter-dropdown .Select-multi-value-wrapper {
  background-color: transparent !important;
  font-size: 0.68rem !important;
}

.filter-dropdown .Select-value {
  background-color: rgba(242, 93, 0, 0.18) !important;
  border: 1px solid rgba(242, 93, 0, 0.35) !important;
  border-radius: 3px !important;
  color: #FF7A2B !important;
  font-size: 0.64rem !important;
}

.filter-dropdown .Select-value-icon {
  border-right: 1px solid rgba(242, 93, 0, 0.35) !important;
  color: #FF7A2B !important;
}

.filter-dropdown .Select-value-icon:hover {
  background-color: rgba(242, 93, 0, 0.3) !important;
  color: #ffffff !important;
}

/* ── Filtro de data (input nativo) ───────────────────────────────────────── */
.filter-date-range {
  display: flex;
  align-items: center;
  gap: 4px;
}

.filter-date-input {
  flex: 1;
  min-width: 0;
  background-color: var(--color-navy) !important;
  color: rgba(255, 255, 255, 0.8) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: var(--radius-btn) !important;
  padding: 4px 6px;
  font-size: 0.65rem;
  font-family: var(--font-sans);
  outline: none;
  width: 100%;
}

.filter-date-input:focus {
  border-color: var(--color-primary) !important;
}

/* Ícone do calendário nativo (webkit) */
.filter-date-input::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

.filter-date-arrow {
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.7rem;
  flex-shrink: 0;
}

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.main-tabs {
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 16px;
}

/* Seletor duplo para cobrir .tab e classes JSX scoped (div.jsx-XXXXX.tab) */
.main-tabs .tab,
.main-tabs > div[class*="tab"] {
  background-color: var(--color-bg) !important;
  border: 1px solid var(--color-border) !important;
  border-bottom: none !important;
  color: var(--color-text-muted) !important;
  padding: 9px 16px !important;
  font-size: 0.82rem !important;
  font-weight: 500 !important;
  border-radius: var(--radius-btn) var(--radius-btn) 0 0 !important;
  margin-right: 3px !important;
}

.main-tabs .tab--selected,
.main-tabs > div[class*="tab"][class*="selected"] {
  background-color: var(--color-bg-card) !important;
  color: var(--color-primary) !important;
  border-bottom: 2px solid var(--color-primary) !important;
  font-weight: 500 !important;
}

.tab-content-area {
  padding: 0 4px;
}

/* ── KPI Cards ───────────────────────────────────────────────────────────── */
.kpi-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background-color: var(--color-bg-card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: box-shadow 0.2s;
}

.kpi-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.card-title-kpi {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.card-value-kpi {
  font-size: 1.6rem;
  font-weight: 500;
  margin-bottom: 0;
  line-height: 1.1;
}

/* ── Gráficos ────────────────────────────────────────────────────────────── */
.dash-graph {
  border-radius: var(--radius-card);
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.dash-graph .js-plotly-plot,
.dash-graph .plot-container {
  height: 100% !important;
}

.js-plotly-plot {
  border-radius: var(--radius-card);
  background-color: transparent;
  overflow: hidden;
}

/* ── Seções ──────────────────────────────────────────────────────────────── */
.section-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-left: 3px solid var(--color-primary);
  padding-left: 8px;
  margin-bottom: 10px;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-message {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
  font-size: 1rem;
  font-style: italic;
  background-color: var(--color-bg-card);
  border-radius: var(--radius-card);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  margin-top: 20px;
}

/* ── DataTable ───────────────────────────────────────────────────────────── */
.dash-table-container {
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--color-border);
}

/* Filtro de coluna da DataTable */
.dash-filter input {
  background-color: var(--color-navy) !important;
  color: rgba(255, 255, 255, 0.8) !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
  font-size: 11px !important;
}

/* ── Scrollbar customizado ───────────────────────────────────────────────── */
.filter-panel::-webkit-scrollbar { width: 4px; }
.filter-panel::-webkit-scrollbar-track { background: var(--color-navy); }
.filter-panel::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 2px; }

/* ── Responsivo ──────────────────────────────────────────────────────────── */
@media (max-width: 992px) {
  .filter-panel {
    position: relative;
    max-height: none;
    margin-bottom: 16px;
  }

  .card-value-kpi { font-size: 1.2rem; }
  .header-title { font-size: 1.1rem; }
}

/* ── Botão de tema ───────────────────────────────────────────────────────── */
.btn-theme {
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: var(--radius-btn);
  background-color: transparent !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  color: rgba(255, 255, 255, 0.85) !important;
  transition: all 0.2s;
}

.btn-theme:hover {
  background-color: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.6) !important;
  color: #ffffff !important;
}

/* ── Transições suaves na troca de tema ─────────────────────────────────── */
.app-wrapper,
.dashboard-header,
.filter-panel,
.kpi-card,
.dash-graph,
.main-tabs .tab,
.btn-theme,
.btn-refresh,
.filter-date-input,
.section-title,
.empty-message,
.dash-table-container {
  transition: background-color 0.25s ease, color 0.25s ease,
              border-color 0.25s ease, box-shadow 0.25s ease;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODO CLARO — sobrescreve variáveis e estilos com cores hardcoded
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Variáveis ───────────────────────────────────────────────────────────── */
.light-mode {
  --color-navy:           #FFFFFF;
  --color-navy-card:      #F0F2F8;
  --color-navy-hover:     #E6E9F4;
  --color-bg:             #ECEEF5;
  --color-bg-card:        #FFFFFF;
  --color-text:           #1A1A2E;
  --color-text-muted:     rgba(26, 26, 46, 0.55);
  --color-border:         rgba(26, 26, 46, 0.12);
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.light-mode .dashboard-header {
  box-shadow: 0 2px 8px rgba(26, 26, 46, 0.08);
}

.light-mode .header-title  { color: #1A1A2E; }
.light-mode .header-subtitle { color: rgba(26, 26, 46, 0.6); }
.light-mode .update-label  { color: rgba(26, 26, 46, 0.6); }
.light-mode .update-value  { color: #1A1A2E; }

/* ── Botão de tema no modo claro ─────────────────────────────────────────── */
.light-mode .btn-theme {
  border: 1px solid rgba(26, 26, 46, 0.25) !important;
  color: rgba(26, 26, 46, 0.7) !important;
}

.light-mode .btn-theme:hover {
  background-color: rgba(26, 26, 46, 0.06) !important;
  border-color: rgba(26, 26, 46, 0.45) !important;
  color: #1A1A2E !important;
}

/* ── Dropdowns — modo claro ──────────────────────────────────────────────── */
.light-mode .filter-dropdown .Select-control,
.light-mode .filter-dropdown .Select--multi .Select-control {
  background-color: #F8F9FC !important;
  border: 1px solid rgba(26, 26, 46, 0.18) !important;
}

.light-mode .filter-dropdown .dash-dropdown-grid-container,
.light-mode .filter-dropdown .dash-dropdown-trigger {
  background-color: #F8F9FC !important;
  color: rgba(26, 26, 46, 0.65) !important;
}

.light-mode .filter-dropdown .Select-placeholder,
.light-mode .filter-dropdown .Select-value-label,
.light-mode .filter-dropdown .Select-input input,
.light-mode .filter-dropdown input,
.light-mode .filter-dropdown .dash-dropdown-placeholder,
.light-mode .filter-dropdown .dash-dropdown-value {
  color: rgba(26, 26, 46, 0.65) !important;
}

.light-mode .filter-dropdown .Select-arrow {
  border-top-color: rgba(26, 26, 46, 0.45) !important;
}

.light-mode .filter-dropdown .Select-menu-outer,
.light-mode .filter-dropdown .Select-menu {
  background-color: #FFFFFF !important;
  border: 1px solid rgba(26, 26, 46, 0.12) !important;
  box-shadow: 0 8px 24px rgba(26, 26, 46, 0.12) !important;
}

.light-mode .filter-dropdown .Select-option,
.light-mode .filter-dropdown .VirtualizedSelectOption {
  background-color: #FFFFFF !important;
  color: rgba(26, 26, 46, 0.8) !important;
}

.light-mode .filter-dropdown .Select-option.is-focused,
.light-mode .filter-dropdown .VirtualizedSelectOption:hover {
  background-color: var(--color-navy-hover) !important;
  color: #1A1A2E !important;
}

/* ── Inputs de data — modo claro ─────────────────────────────────────────── */
.light-mode .filter-date-input {
  background-color: #F8F9FC !important;
  color: #1A1A2E !important;
  border: 1px solid rgba(26, 26, 46, 0.18) !important;
}

.light-mode .filter-date-input::-webkit-calendar-picker-indicator {
  filter: invert(0.2);
}

/* ── Scrollbar — modo claro ──────────────────────────────────────────────── */
.light-mode .filter-panel::-webkit-scrollbar-track { background: #F0F2F8; }
.light-mode .filter-panel::-webkit-scrollbar-thumb { background: rgba(26, 26, 46, 0.18); }

/* ── DataTable — modo claro ──────────────────────────────────────────────── */
.light-mode .dash-filter input {
  background-color: #F8F9FC !important;
  color: #1A1A2E !important;
  border-color: rgba(26, 26, 46, 0.15) !important;
}

.light-mode .dash-spreadsheet-container .dash-spreadsheet-inner th {
  background-color: #ECEEF5 !important;
  color: #1A1A2E !important;
  border-bottom: 2px solid var(--color-primary) !important;
}

.light-mode .dash-spreadsheet-container .dash-spreadsheet-inner td {
  background-color: #FFFFFF !important;
  color: #333344 !important;
  border: 1px solid rgba(26, 26, 46, 0.08) !important;
}

/* Sobrescreve a cor da linha ímpar (#232340) definida inline no Python */
.light-mode .dash-spreadsheet-container .dash-spreadsheet-inner tr:nth-child(odd) td {
  background-color: #F4F6FC !important;
}

/* ── Gráficos Plotly — texto dos eixos e títulos ─────────────────────────── */
/* Apenas estrutura (título, rótulos de eixo, ticks, legenda).
   Não altera as anotações sobre as barras para preservar o contraste. */
.light-mode .js-plotly-plot .gtitle text,
.light-mode .js-plotly-plot .g-xtitle text,
.light-mode .js-plotly-plot .g-ytitle text,
.light-mode .js-plotly-plot .xtick text,
.light-mode .js-plotly-plot .ytick text,
.light-mode .js-plotly-plot .legendtext,
.light-mode .js-plotly-plot .cbaxis text {
  fill: #1A1A2E !important;
}

/* Linhas de grade */
.light-mode .js-plotly-plot .gridlayer .ygrid,
.light-mode .js-plotly-plot .gridlayer .xgrid {
  stroke: rgba(26, 26, 46, 0.08) !important;
}

/* Linhas dos eixos */
.light-mode .js-plotly-plot .xlines-above line,
.light-mode .js-plotly-plot .ylines-above line,
.light-mode .js-plotly-plot .xlines-below line,
.light-mode .js-plotly-plot .ylines-below line,
.light-mode .js-plotly-plot .zerolinelayer line {
  stroke: rgba(26, 26, 46, 0.15) !important;
}
