/* Tema claro (padrão) */
:root {
  --bg-color: #f8f9fa;
  --text-color: #333;
  --card-bg: white;
  --text-secondary: #495057;
  --border-color: #dee2e6;
  --table-header-bg: #a8d3ff;
  --table-header-color: #495057;
  --input-bg: white;
  --input-border: #ddd;
  --shadow: rgba(0, 0, 0, 0.1);
  /* Link colors (light theme) */
  --link-color: #020202;
  --link-hover-color: rgb(0, 0, 255);
}

/* Tema escuro */
[data-theme="dark"] {
  --bg-color: #1a1a1a;
  --text-color: #f8f9fa;
  --card-bg: #2d2d2d;
  --text-secondary: #e9ecef;
  --border-color: #444;
  --table-header-bg: #3a3a3a;
  --table-header-color: #f8f9fa;
  --input-bg: #3a3a3a;
  --input-border: #555;
  --shadow: rgba(0, 0, 0, 0.3);
  /* Link colors (dark theme) - requirement: links must be white */
  --link-color: #e9ecef;
  --link-hover-color: #48ff00;
}

/* Theme toggle button */
.theme-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000; /* Ensure it's above other elements */
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 8px var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.theme-toggle:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px var(--shadow);
}

/* Navbar */
.navbar {
    background-color: #4a6fa5 !important; /* Azul médio mate para modo claro */
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    width: 100% !important;
    max-width: none !important;
}

/* Navbar no modo escuro */
[data-theme="dark"] .navbar {
    background-color: #2d2d2d !important;
    color: var(--text-color);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100% !important;
    margin: 0 auto !important;
    padding: 0 1rem !important;
}

.nav-brand-group {
    display: flex;
    align-items: center;
    gap: 0;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: bold;
    color: white !important;
    text-decoration: none;
    margin-right: 3rem;
}

.nav-brand:hover {
    color: rgba(255, 255, 255, 0.8) !important;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-toggle {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
}

.hamburger {
    display: block;
    width: 25px;
    height: 3px;
    background-color: white;
    margin: 3px 0;
    transition: 0.3s;
}

.nav-menu {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-menu .nav-link {
    color: white !important;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    transition: background-color 0.3s ease;
}

.nav-menu .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white !important;
}

.theme-icon {
    font-size: 24px;
}

/* Reset e configurações globais */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px; /* Base para rem units */
  transition: background-color 0.3s ease, color 0.3s ease;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Links */
a:not(.btn) {
  color: var(--link-color);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:not(.btn):hover,
a:not(.btn):focus {
  color: var(--link-hover-color);
}

a:not(.btn):focus-visible {
  outline: 2px solid var(--link-hover-color);
  outline-offset: 2px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  width: 100%;
}

/* Margens reduzidas para desktop */
@media (min-width: 992px) {
  .container {
    padding: 1rem 0.5rem;
  }
}

@media (min-width: 1200px) {
  .container {
    max-width: 95%;
    padding: 1rem 0.25rem;
  }
}

/* Container-fluid com margens reduzidas para desktop */
.container-fluid {
  padding-left: 1rem;
  padding-right: 1rem;
}

@media (min-width: 992px) {
  .container-fluid {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
}

@media (min-width: 1200px) {
  .container-fluid {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }
}

@media (min-width: 1400px) {
  .container-fluid {
    max-width: 98%;
    margin: 0 auto;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }
}

/* Navbar com largura reduzida para desktop */
@media (min-width: 992px) {
  .nav-container {
    max-width: 95% !important;
    padding: 0 0.5rem !important;
  }
}

@media (min-width: 1200px) {
  .nav-container {
    max-width: 95% !important;
    padding: 0 0.25rem !important;
  }
}

@media (min-width: 1400px) {
  .nav-container {
    max-width: 98% !important;
    margin: 0 auto !important;
    padding: 0 0.25rem !important;
  }
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2rem;
  padding: 2rem 1rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 0.75rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

header h1 {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  margin-bottom: 0.5rem;
  font-weight: 700;
}

header p {
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto;
}

/* Welcome Card */
.welcome-card {
  background: var(--card-bg);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border-radius: 0.75rem;
  box-shadow: 0 4px 6px var(--shadow);
  margin-bottom: 2rem;
  transition: background-color 0.3s ease;
}

.welcome-card h2 {
  color: var(--text-color);
  margin-bottom: 1rem;
  font-size: clamp(1.25rem, 3vw, 2rem);
}

.welcome-card > p {
  color: var(--text-secondary);
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  margin-bottom: 2rem;
  line-height: 1.6;
}

/* Navigation Links */
.navigation-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 1rem;
}

.nav-link {
  display: block;
  padding: 1.5rem;
  text-decoration: none;
  border-radius: 0.75rem;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.nav-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.nav-link:active {
  transform: translateY(0);
}

.nav-link.primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.nav-link.secondary {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
}

.nav-link.tertiary {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
}

.nav-link h3 {
  margin-bottom: 0.5rem;
  font-size: clamp(1rem, 2.5vw, 1.4rem);
}

.nav-link p {
  opacity: 0.9;
  font-size: clamp(0.8rem, 2vw, 1rem);
  line-height: 1.4;
}

/* Footer */
footer {
  text-align: center;
  padding: 1.5rem 0;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
  margin-top: 2rem;
  transition: color 0.3s ease, border-color 0.3s ease;
}

/* Estilos para formulários */
.form-container {
  background: var(--card-bg);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border-radius: 0.75rem;
  box-shadow: 0 2px 4px var(--shadow);
  max-width: 600px;
  margin: 0 auto;
  transition: background-color 0.3s ease;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-color);
  font-size: 1rem;
}

.form-control {
  width: 100%;
  padding: 0.875rem;
  border: 2px solid var(--input-border);
  border-radius: 0.5rem;
  font-size: 1rem;
  transition: all 0.3s ease;
  background: var(--input-bg);
  color: var(--text-color);
  -webkit-appearance: none;
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1.5rem;
  text-decoration: none;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: all 0.3s ease;
  min-height: 44px; /* Tamanho mínimo para touch */
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary { 
  background: #667eea; 
  color: white; 
}

.btn-secondary { 
  background: #6c757d; 
  color: white; 
}

.btn-info { 
  background: #17a2b8; 
  color: white; 
}

.btn-warning { 
  background: #ffc107; 
  color: #212529; 
}

.btn-danger { 
  background: #dc3545; 
  color: white; 
}

.btn-sm { 
  padding: 0.5rem 1rem; 
  font-size: 0.875rem;
  min-height: 36px;
}

/* Botão de tema */
.theme-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  color: var(--text-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px var(--shadow);
  transition: all 0.3s ease;
  z-index: 1000;
}

.theme-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px var(--shadow);
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* Alertas */
.alert {
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid transparent;
}

.alert-success { 
  background: #d4edda; 
  color: #155724; 
  border-color: #c3e6cb; 
}

.alert-danger { 
  background: #f8d7da; 
  color: #721c24; 
  border-color: #f5c6cb; 
}

/* Header das páginas */
.header-section {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.header-section h2 {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  margin: 0;
  color: var(--text-color);
}

/* Tabelas responsivas */
.table-container {
  background: var(--card-bg);
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 2px 4px var(--shadow);
  overflow-x: auto;
  transition: background-color 0.3s ease;
}

.table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  min-width: 600px;
}

.table th,
.table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  color: var(--text-color);
}

.table th {
  background-color: var(--table-header-bg);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--table-header-color);
}

.table tbody tr:hover {
  background-color: var(--bg-color);
}

.actions {
  white-space: nowrap;
}

.actions .btn {
  margin-right: 0.5rem;
}

/* Cards para mobile */
.mobile-card {
  background: var(--card-bg);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 4px var(--shadow);
  transition: background-color 0.3s ease;
}

.mobile-card h4 {
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

.mobile-card .card-info {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.mobile-card .card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Estados vazios */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.empty-state h3 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
  color: var(--text-color);
}

/* Text utilities */
.text-danger {
  color: #dc3545;
  font-size: 0.875rem;
  margin-top: 0.25rem;
  display: block;
}

/* Responsive breakpoints */
@media (max-width: 768px) {
  html {
    font-size: 14px;
  }

  .container {
    padding: 0.75rem;
  }

  header {
    padding: 1.5rem 1rem;
    margin-bottom: 1.5rem;
  }

  .welcome-card {
    margin-bottom: 1.5rem;
  }

  .navigation-links {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .nav-link {
    padding: 1.25rem;
  }

  .mobile-card .card {
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }

  .mobile-card .card-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .mobile-card .card-actions .btn {
    flex: 1;
    min-width: calc(33.33% - 0.25rem);
  }

  .header-section {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .form-actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 13px;
  }

  .container {
    padding: 0.5rem;
  }

  header {
    border-radius: 0.5rem;
  }

  .welcome-card,
  .form-container {
    border-radius: 0.5rem;
  }

  .nav-link {
    padding: 1rem;
  }

  .mobile-card .card-actions {
    flex-direction: column;
  }

  .mobile-card .card-actions .btn {
    width: 100%;
  }
}

/* Melhorias de acessibilidade */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Estilos específicos para a tabela do Sistema */
.sistema-table {
  table-layout: fixed;
  width: 100%;
}

.sistema-table th,
.sistema-table td {
  vertical-align: top;
  padding: 0.75rem 0.5rem;
  line-height: 1.4;
}

.sistema-table .chave-column {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.sistema-table .chave-column code {
  word-wrap: break-word;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-size: 0.9rem;
}

.sistema-table .valor-column {
  max-width: 200px;
  word-wrap: break-word;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  hyphens: auto;
}

.sistema-table .descricao-column {
  max-width: 250px;
  word-wrap: break-word;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  hyphens: auto;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.sistema-table .tipo-column {
  text-align: center;
}

.sistema-table .modificado-column {
  font-size: 0.85rem;
  text-align: center;
}

.sistema-table .acoes-column {
  width: 100px;
  min-width: 100px;
  text-align: center;
}

.sistema-table .btn-group-vertical .btn {
  margin-bottom: 2px;
}

.sistema-table .btn-group-vertical .btn:last-child {
  margin-bottom: 0;
}

/* Responsividade específica para a tabela do Sistema */
@media (max-width: 1200px) {
  .sistema-table .chave-column code {
    font-size: 0.8rem;
  }
  
  .sistema-table .descricao-column {
    max-width: 180px;
    font-size: 0.85rem;
  }
}

@media (max-width: 992px) {
  .sistema-table .chave-column code {
    font-size: 0.75rem;
  }
  
  .sistema-table .valor-column {
    max-width: 150px;
  }
  
  .sistema-table .descricao-column {
    max-width: 150px;
    font-size: 0.8rem;
  }
  
  .sistema-table .modificado-column {
    font-size: 0.75rem;
  }
}

/* Estilos específicos para vista mobile do Sistema */
.mobile-cards.d-md-none {
  display: block !important;
}

@media (min-width: 768px) {
  .mobile-cards.d-md-none {
    display: none !important;
  }
}

.sistema-mobile-card {
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  box-shadow: 0 2px 4px var(--shadow);
}

.sistema-chave-mobile code {
  word-wrap: break-word;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-size: 0.9rem;
  background-color: rgba(var(--bs-info-rgb), 0.1);
  border: 1px solid rgba(var(--bs-info-rgb), 0.2);
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
}

.sistema-valor-mobile {
  word-wrap: break-word;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  hyphens: auto;
}

.sistema-valor-text {
  display: block;
  padding: 0.2rem 0;
  line-height: 1.3;
}

.sistema-descricao-mobile {
  word-wrap: break-word;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  hyphens: auto;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.sistema-mobile-card .card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

.sistema-mobile-card .card-actions .btn {
  flex: 0 1 auto;
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
}

/* Responsividade adicional para mobile muito pequeno */
@media (max-width: 480px) {
  .sistema-chave-mobile code {
    font-size: 0.8rem;
  }
  
  .sistema-valor-text {
    font-size: 0.85rem;
  }
  
  .sistema-descricao-mobile {
    font-size: 0.8rem;
  }
  
  .sistema-mobile-card .card-actions {
    flex-direction: column;
    align-items: stretch;
  }
  
  .sistema-mobile-card .card-actions .btn {
    width: 100%;
    text-align: center;
    margin-bottom: 0.25rem;
  }
  
  .sistema-mobile-card .card-actions .btn:last-child {
    margin-bottom: 0;
  }
}

/* Indicador de Modo de Manutenção */
.maintenance-indicator {
  margin-left: 1rem;
  display: flex;
  align-items: center;
}

.maintenance-badge {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
  animation: maintenance-pulse 2s infinite;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

@keyframes maintenance-pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.5);
  }
}

/* Responsividade para mobile */
@media (max-width: 768px) {
  .maintenance-indicator {
    margin-left: 0;
    margin-top: 1rem;
    justify-content: center;
    width: 100%;
  }
  
  .maintenance-badge {
    font-size: 0.7rem;
    padding: 0.3rem 0.6rem;
  }
}

/* Modo escuro para o indicador de manutenção */
[data-theme="dark"] .maintenance-badge {
  background: linear-gradient(135deg, #ff4757 0%, #c44569 100%);
  border: 2px solid rgba(255, 255, 255, 0.2);
}
