/* Temas — Administração (Multi-Aplicação SGA). Padrão replicado do TimeFlow (5 temas, troca via theme-switcher). */
:root,
[data-theme="dracula"] {
  --bg-primary: #1e1f29;
  --bg-secondary: #282a36;
  --bg-tertiary: #343746;
  --bg-card: #282a36;
  --bg-hover: #373949;
  --border-color: #44475a;
  --text-primary: #f8f8f2;
  --text-secondary: #b8b8c4;
  --text-muted: #6272a4;
  --accent-primary: #bd93f9;
  --accent-secondary: #50fa7b;
  --accent-purple: #bd93f9;
  --accent-cyan: #8be9fd;
  --accent-pink: #ff79c6;
  --accent-red: #ff5555;
  --accent-danger: #ff5555;
  --accent-warning: #f1fa8c;
  --accent-info: #8be9fd;
  --accent-orange: #ffb86c;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-hover: 0 8px 30px rgba(189,147,249,0.15);
  --border-radius: 0.5rem;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-card: #1c2128;
  --bg-hover: #2d333b;
  --border-color: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  --accent-primary: #58a6ff;
  --accent-secondary: #3fb950;
  --accent-purple: #58a6ff;
  --accent-cyan: #79c0ff;
  --accent-pink: #d2a8ff;
  --accent-red: #f85149;
  --accent-danger: #f85149;
  --accent-warning: #e3b341;
  --accent-info: #79c0ff;
  --accent-orange: #ffa657;
  --shadow: 0 4px 20px rgba(0,0,0,0.5);
  --shadow-hover: 0 8px 30px rgba(88,166,255,0.15);
  --border-radius: 0.5rem;
  --transition: 0.2s ease;
}

[data-theme="futuristic"] {
  --bg-primary: #000510;
  --bg-secondary: #000d1a;
  --bg-tertiary: #001a33;
  --bg-card: #001020;
  --bg-hover: #002040;
  --border-color: #003355;
  --text-primary: #00ffff;
  --text-secondary: #00bcd4;
  --text-muted: #006080;
  --accent-primary: #00e5ff;
  --accent-secondary: #00ff41;
  --accent-purple: #00e5ff;
  --accent-cyan: #40c4ff;
  --accent-pink: #ff2bd6;
  --accent-red: #ff0040;
  --accent-danger: #ff0040;
  --accent-warning: #ffea00;
  --accent-info: #40c4ff;
  --accent-orange: #ff8a00;
  --shadow: 0 0 20px rgba(0,229,255,0.2);
  --shadow-hover: 0 0 40px rgba(0,229,255,0.4);
  --border-radius: 0.5rem;
  --transition: 0.2s ease;
}

[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-tertiary: #eaeef2;
  --bg-card: #ffffff;
  --bg-hover: #f3f4f6;
  --border-color: #d0d7de;
  --text-primary: #1f2328;
  --text-secondary: #656d76;
  --text-muted: #9ca3af;
  --accent-primary: #0969da;
  --accent-secondary: #1a7f37;
  --accent-purple: #8250df;
  --accent-cyan: #0598bc;
  --accent-pink: #bf3989;
  --accent-red: #d1242f;
  --accent-danger: #d1242f;
  --accent-warning: #9a6700;
  --accent-info: #0550ae;
  --accent-orange: #bc4c00;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-hover: 0 4px 16px rgba(9,105,218,0.15);
  --border-radius: 0.5rem;
  --transition: 0.2s ease;
}

[data-theme="glass"] {
  --bg-primary: #0f0f23;
  --bg-secondary: rgba(255,255,255,0.03);
  --bg-tertiary: rgba(255,255,255,0.08);
  --bg-card: rgba(255,255,255,0.05);
  --bg-hover: rgba(255,255,255,0.1);
  --border-color: rgba(255,255,255,0.1);
  --text-primary: #ffffff;
  --text-secondary: rgba(255,255,255,0.7);
  --text-muted: rgba(255,255,255,0.4);
  --accent-primary: #a78bfa;
  --accent-secondary: #34d399;
  --accent-purple: #a78bfa;
  --accent-cyan: #60a5fa;
  --accent-pink: #f472b6;
  --accent-red: #f87171;
  --accent-danger: #f87171;
  --accent-warning: #fbbf24;
  --accent-info: #60a5fa;
  --accent-orange: #fb923c;
  --shadow: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-hover: 0 8px 32px rgba(167,139,250,0.3);
  --border-radius: 0.5rem;
  --transition: 0.2s ease;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
}
body {
  display: flex;
  flex-direction: column;
}
.app-navbar {
  flex-shrink: 0;
  background: var(--bg-secondary) !important;
  border-bottom: 1px solid var(--border-color);
}
.app-navbar .navbar-brand {
  color: var(--accent-primary) !important;
  font-weight: 700;
  font-size: 1.1rem;
}
.app-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.app-sidebar {
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  width: 220px;
}
.app-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem;
}
.app-footer {
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Tabela densa — usada em listagens com paginate_by=10 para evitar rolagem
   vertical em app-main (a line-height padrão do Bootstrap, 1.5, é o maior
   fator de altura por linha). */
.table-compact td, .table-compact th {
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
  line-height: 1.1;
  vertical-align: middle;
}

/* Paginação padrão do SGA (replicada de sga/apps/estoque/templates/paginacao_produtos_dracula.html)
   — usar via {% include "_paginacao.html" %} em toda ListView paginada. */
.pagination-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.1rem 0 0;
}
.pagination-dracula {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 0.25rem;
}
.pagination-dracula .page-item .page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0.25rem 0.6rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 4px;
  transition: all 0.2s ease;
  font-size: 0.95rem;
}
.pagination-dracula .page-item .page-link:hover {
  background: rgba(189, 147, 249, 0.2);
  border-color: var(--accent-purple);
  color: var(--accent-purple);
}
.pagination-dracula .page-item.active .page-link {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  color: white;
  font-weight: 600;
}
.pagination-dracula .page-item.disabled .page-link {
  background: var(--bg-secondary);
  border-color: var(--border-color);
  color: var(--text-secondary);
  opacity: 0.5;
  cursor: not-allowed;
}
.pagination-info {
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.pagination-info .separator {
  margin: 0 0.5rem;
  color: var(--border-color);
}
@media (max-width: 576px) {
  .pagination-dracula .page-link {
    min-width: 32px;
    height: 32px;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
  }
}

.card, .btn-sf-primary, .btn-sf-secondary {
  background: var(--bg-card);
  border-color: var(--border-color);
}
.btn-sf-primary {
  background: var(--accent-primary);
  border: none;
  color: #1e1f29;
  padding: 0.5rem 1rem;
  border-radius: 0.4rem;
  text-decoration: none;
  display: inline-block;
}
.btn-sf-secondary {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  border-radius: 0.4rem;
  text-decoration: none;
  display: inline-block;
}

/* Banner "Em Desenvolvimento" — padrão CLAUDE.md, replicado de InfraFlow */
.em-breve {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: linear-gradient(135deg, rgba(189,147,249,0.1), rgba(80,250,123,0.08));
  border: 1px solid var(--accent-primary);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  animation: pulse-border 2.5s ease-in-out infinite;
}
.em-breve-icon { font-size: 1.4rem; color: var(--accent-primary); animation: spin-slow 4s linear infinite; flex-shrink: 0; }
.em-breve-titulo { display: block; font-weight: 700; font-size: 0.95rem; color: var(--accent-primary); letter-spacing: 0.5px; }
.em-breve-sub { display: block; font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.1rem; }
.em-breve-percentual { font-size: 0.8rem; font-weight: 700; color: var(--accent-secondary); letter-spacing: 0.3px; }

.em-breve-progress {
  position: relative; width: 100%; height: 6px; border-radius: 999px;
  background: var(--bg-tertiary); overflow: hidden; margin: 0.4rem 0 0.3rem;
}
.em-breve-progress-fill {
  --progresso: 0%;
  position: relative; height: 100%; width: var(--progresso); border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  animation: em-breve-preencher 1.2s ease-out forwards;
  transform-origin: left;
}
.em-breve-progress-fill::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  animation: em-breve-brilho 2.4s ease-in-out infinite;
}
@keyframes em-breve-preencher { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes em-breve-brilho { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@keyframes pulse-border { 0%, 100% { box-shadow: 0 0 0 0 rgba(189,147,249,0); } 50% { box-shadow: 0 0 0 4px rgba(189,147,249,0.15); } }
@keyframes spin-slow { 0% { transform: rotate(0deg); } 50% { transform: rotate(180deg); } 100% { transform: rotate(360deg); } }

/* Seletor de Temas — padrão replicado do TimeFlow */
.theme-switcher {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.theme-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
}
.theme-btn:hover, .theme-btn.active { border-color: var(--text-primary); transform: scale(1.15); }
.theme-btn[data-theme="dracula"] { background: #bd93f9; }
.theme-btn[data-theme="dark"] { background: #58a6ff; }
.theme-btn[data-theme="futuristic"] { background: #00e5ff; }
.theme-btn[data-theme="light"] { background: #f6f8fa; border-color: #d0d7de; }
.theme-btn[data-theme="glass"] { background: #a78bfa; }

/* Cabeçalho de página (ícone + título + subtítulo) — padrão para todas as telas */
.page-header { border-bottom: 1px solid var(--border-color); padding-bottom: 1rem; }
.page-icon { font-size: 1.5rem; color: var(--accent-primary); }
.page-title { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); }
.page-subtitle { font-size: 0.8rem; color: var(--text-secondary); }

/* Dropdown do usuário (navbar) */
.navbar-avatar {
  width: 22px;
  height: 22px;
  object-fit: cover;
  border: 1px solid var(--border-color);
}
.user-dropdown {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  min-width: 180px;
}
.user-dropdown-header {
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  display: block;
}
.user-dropdown-item {
  color: var(--text-primary) !important;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  transition: background var(--transition), color var(--transition);
}
.user-dropdown-item:hover { background: var(--bg-hover) !important; color: var(--accent-primary) !important; }
.user-dropdown-danger:hover { color: var(--accent-danger) !important; }
.user-dropdown-divider { border-color: var(--border-color) !important; margin: 0.25rem 0; }

/* Sidebar — accordion vertical (Bootstrap accordion, restilizado para o tema ativo) */
.app-sidebar .accordion-item {
  background: transparent;
  border: none;
}
.app-sidebar .accordion-button {
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 0.75rem 1.25rem;
  box-shadow: none;
}
.app-sidebar .accordion-button:not(.collapsed) {
  background: var(--bg-hover);
  color: var(--accent-primary);
  box-shadow: none;
}
.app-sidebar .accordion-button:focus { box-shadow: none; border-color: transparent; }
.app-sidebar .accordion-button::after { filter: invert(1) grayscale(1) brightness(1.6); }
[data-theme="light"] .app-sidebar .accordion-button::after { filter: none; }
.app-sidebar .accordion-body { padding: 0.25rem 0; }
.app-sidebar .nav-link {
  color: var(--text-secondary);
  padding: 0.6rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.app-sidebar .nav-link:hover,
.app-sidebar .nav-link.active {
  color: var(--accent-primary);
  background: var(--bg-hover);
  border-left: 3px solid var(--accent-primary);
}

/* Avatar — tela Meu Perfil e navbar */
.avatar-wrap { width: 72px; height: 72px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.avatar-preview { width: 72px; height: 72px; object-fit: cover; border: 2px solid var(--accent-primary); }
.avatar-placeholder { font-size: 72px; line-height: 1; color: var(--text-secondary); }
