/* ==================== RESPONSIVE CSS ====================
 * Este arquivo torna o sistema responsivo para dispositivos móveis
 * ======================================================== */

/* Variáveis CSS para consistência */
:root {
  --header-height: 64px;
  --mobile-header-height: 56px;
  --sidebar-width: 280px;
  --orange-primary: #ea580c;
  --orange-hover: #c2410c;
}

/* ==================== RESET E BASE ==================== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* ==================== HEADER RESPONSIVO ==================== */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Container do header */
header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  gap: 1rem;
}

/* Título do sistema */
header h1 {
  font-size: 1.25rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Informações do usuário no header */
.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

/* ==================== NAVEGAÇÃO/TABS ==================== */
nav {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
}

nav::-webkit-scrollbar {
  display: none; /* Chrome, Safari */
}

.tab-btn {
  white-space: nowrap;
  flex-shrink: 0;
  padding: 0.75rem 1.5rem;
  transition: all 0.2s;
}

/* ==================== CONTAINERS E GRIDS ==================== */
.container {
  width: 100%;
  max-width: 100%;
  padding-left: 1rem;
  padding-right: 1rem;
  margin-left: auto;
  margin-right: auto;
}

/* Grid responsivo */
.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* ==================== CARDS ==================== */
.card {
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 1rem;
  background: white;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0,0,0,0.15);
}

/* ==================== MODAIS RESPONSIVOS ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  overflow-y: auto;
}

.modal-content {
  background: white;
  border-radius: 0.5rem;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ==================== FORMULÁRIOS ==================== */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #374151;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.625rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--orange-primary);
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.1);
}

/* ==================== BOTÕES RESPONSIVOS ==================== */
button {
  cursor: pointer;
  border: none;
  border-radius: 0.375rem;
  font-weight: 600;
  transition: all 0.2s;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
}

button:active {
  transform: scale(0.98);
}

/* ==================== TABELAS RESPONSIVAS ==================== */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

thead {
  background: #f9fafb;
  border-bottom: 2px solid #e5e7eb;
}

th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e5e7eb;
}

/* Scroll horizontal para tabelas em mobile */
@media (max-width: 768px) {
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* ==================== MEDIA QUERIES ==================== */

/* Tablets e telas médias (768px - 1024px) */
@media (max-width: 1024px) {
  .container {
    max-width: 100%;
  }
  
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
}

/* Smartphones grandes (640px - 768px) */
@media (max-width: 768px) {
  /* Header */
  header h1 {
    font-size: 1.125rem;
  }
  
  .user-info {
    font-size: 0.75rem;
  }
  
  /* Tabs mais compactas */
  .tab-btn {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
  }
  
  /* Grid de 2 colunas */
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
  }
  
  /* Cards mais compactos */
  .card {
    padding: 0.75rem;
  }
  
  /* Modais ocupam mais espaço */
  .modal-overlay {
    padding: 0.5rem;
  }
  
  .modal-content {
    max-height: 95vh;
  }
  
  .modal-header,
  .modal-body {
    padding: 1rem;
  }
  
  .modal-footer {
    padding: 0.75rem 1rem;
  }
  
  /* Botões empilhados em modais */
  .modal-footer button {
    flex: 1;
    min-width: 100px;
  }
  
  /* Formulários */
  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px; /* Previne zoom no iOS */
  }
}

/* Smartphones pequenos (< 640px) */
@media (max-width: 640px) {
  /* Header ainda mais compacto */
  header .container {
    padding: 0.5rem 0.75rem;
  }
  
  header h1 {
    font-size: 1rem;
  }
  
  /* Esconder texto, mostrar apenas ícones nas tabs */
  .tab-btn {
    padding: 0.5rem 0.75rem;
  }
  
  .tab-btn i {
    margin-right: 0;
  }
  
  /* Grid de 1 coluna */
  .grid {
    grid-template-columns: 1fr;
  }
  
  /* Botões full-width em mobile */
  .modal-footer {
    flex-direction: column;
  }
  
  .modal-footer button {
    width: 100%;
  }
  
  /* Cards ocupam largura total */
  .card {
    border-radius: 0.375rem;
  }
  
  /* Tabelas em modo card em telas muito pequenas */
  .table-responsive {
    display: block;
  }
  
  .table-responsive thead {
    display: none;
  }
  
  .table-responsive tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.75rem;
  }
  
  .table-responsive td {
    display: block;
    text-align: right;
    padding: 0.5rem;
    border: none;
    position: relative;
    padding-left: 50%;
  }
  
  .table-responsive td::before {
    content: attr(data-label);
    position: absolute;
    left: 0.5rem;
    font-weight: 600;
    text-align: left;
  }
}

/* Dispositivos muito pequenos (< 375px) */
@media (max-width: 375px) {
  .container {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  
  header h1 {
    font-size: 0.875rem;
  }
  
  button {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
  }
}

/* ==================== ORIENTAÇÃO PAISAGEM ==================== */
@media (max-height: 500px) and (orientation: landscape) {
  .modal-content {
    max-height: 95vh;
  }
  
  .modal-body {
    max-height: 60vh;
    overflow-y: auto;
  }
}

/* ==================== UTILITÁRIOS ==================== */

/* Esconder em mobile */
.hidden-mobile {
  display: block;
}

@media (max-width: 768px) {
  .hidden-mobile {
    display: none !important;
  }
}

/* Mostrar apenas em mobile */
.show-mobile {
  display: none;
}

@media (max-width: 768px) {
  .show-mobile {
    display: block !important;
  }
}

/* Texto responsivo */
.text-responsive {
  font-size: clamp(0.875rem, 2vw, 1rem);
}

/* Padding responsivo */
.p-responsive {
  padding: clamp(0.5rem, 2vw, 1.5rem);
}

/* Gap responsivo */
.gap-responsive {
  gap: clamp(0.5rem, 2vw, 1rem);
}

/* ==================== ANIMAÇÕES SUAVES ==================== */
@media (prefers-reduced-motion: no-preference) {
  * {
    scroll-behavior: smooth;
  }
  
  .card,
  button,
  .tab-btn {
    transition: all 0.2s ease;
  }
}

/* Desabilitar animações para quem prefere */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==================== DARK MODE (OPCIONAL) ==================== */
@media (prefers-color-scheme: dark) {
  /* Descomente para ativar dark mode automático
  body {
    background: #1f2937;
    color: #f9fafb;
  }
  
  .card {
    background: #374151;
  }
  
  .modal-content {
    background: #374151;
  }
  */
}

/* ==================== ACESSIBILIDADE ==================== */

/* Melhor contraste para links */
a {
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.2s;
}

a:hover,
a:focus {
  text-decoration-color: currentColor;
}

/* Foco visível para teclado */
*:focus-visible {
  outline: 2px solid var(--orange-primary);
  outline-offset: 2px;
}

/* Melhor área de toque em mobile */
@media (max-width: 768px) {
  button,
  a,
  .tab-btn {
    min-height: 44px; /* Tamanho mínimo recomendado pela Apple */
    min-width: 44px;
  }
}
