/* =========================================
   1. RESET E VARIÁVEIS GLOBAIS
========================================= */
:root {
  --primary: #007bff;
  --secondary: #6c757d;
  --success: #28a745;
  --danger: #dc3545;
  --background: #f4f6f8;
  --card-bg: #ffffff;
  --text-dark: #333;
  --text-muted: #666;
  --border: #e0e0e0;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Roboto', 'Segoe UI', sans-serif;
  background-color: var(--background);
  color: var(--text-dark);
  padding-bottom: 40px;
  -webkit-font-smoothing: antialiased;
}

/* =========================================
   2. HEADER E TÍTULO
========================================= */
.content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
}

.header {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 20px;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-title h1 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.2;
}

.sigla {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.9em;
}

.btn-back {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 5px;
  border-radius: 50%;
  transition: background 0.2s;
}

.btn-back:hover {
  background-color: #e9ecef;
  color: var(--primary);
}

/* Botão Novo RDO */
.btn-novo-rdo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--primary);
  color: #fff;
  text-decoration: none;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-weight: 600;
  box-shadow: 0 4px 6px rgba(0,123,255,0.2);
  transition: transform 0.2s;
  text-align: center;
}

.btn-novo-rdo:hover {
  background-color: #0056b3;
  transform: translateY(-2px);
}

/* =========================================
   3. FILTROS
========================================= */
.filtro-container {
  background: var(--card-bg);
  padding: 15px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filtro-container label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.filtro-container select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background-color: #fff;
  font-size: 1rem;
}

/* =========================================
   4. ACORDEÃO (LISTAGEM) - MOBILE FIRST
========================================= */
.acordeon-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Título do Acordeão (O Card Fechado) */
.acordeon-title {
  background-color: var(--card-bg);
  border-radius: var(--radius);
  padding: 15px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border-left: 5px solid var(--primary); /* Destaque visual */
  transition: background 0.2s;
}

.acordeon-title:hover {
  background-color: #fdfdfd;
}

/* Layout Interno do Título - Coluna no Mobile */
.linha-conteudo-fixa {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lado-esquerdo {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.iniciais-autor {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #e3f2fd;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0; /* Não deixa amassar */
}

.titulo {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-dark);
  line-height: 1.3;
}

.lado-direito {
  display: flex;
  align-items: center;
  justify-content: space-between; /* Espalha os itens no mobile */
  width: 100%;
  border-top: 1px solid #f0f0f0; /* Separação sutil no mobile */
  padding-top: 10px;
}

.data-rdo {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  background: #f8f9fa;
  padding: 4px 8px;
  border-radius: 4px;
}

/* Botões de Ação no Card */
.btn-pdf, .btn-delete {
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: opacity 0.2s;
}

.btn-pdf {
  background-color: #fff;
  color: var(--danger);
  border: 1px solid #f5c6cb;
}

.btn-delete {
  background-color: #fff;
  color: var(--secondary);
  border: 1px solid var(--border);
}

.btn-pdf:active, .btn-delete:active {
  transform: scale(0.95);
}

.icon-expand {
  color: var(--text-muted);
  transition: transform 0.3s;
}

/* =========================================
   5. CONTEÚDO EXPANDIDO (DETALHES)
========================================= */
.acordeon-content {
  display: none; /* JS controla isso */
  background-color: #fafafa;
  border: 1px solid var(--border);
  border-top: none;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  padding: 15px;
  overflow-x: auto; /* Permite rolagem horizontal em tabelas grandes */
}

/* Tabela de Detalhes */
.tabela-detalhes {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.tabela-detalhes th {
  background-color: #e9ecef;
  color: var(--text-dark);
  padding: 10px;
  text-align: left;
  font-size: 0.85rem;
  text-transform: uppercase;
  border-radius: 4px;
}

.tabela-detalhes td {
  padding: 8px 10px;
  border-bottom: 1px solid #eee;
  vertical-align: top;
  color: #444;
}

/* Ajuste visual para tabelas internas geradas pelo JS */
.tabela-detalhes b {
  color: #222;
  font-weight: 600;
}

/* Ajustes de Imagens no Detalhe */
.tabela-detalhes img {
  max-width: 100%;
  height: auto;
  border: 1px solid #ddd;
  margin-top: 5px;
}

/* Links de Nota Fiscal */
.tabela-detalhes a {
  color: var(--primary);
  text-decoration: none;
  word-break: break-all; /* Quebra links longos */
}

/* =========================================
   6. PRELOADER
========================================= */
#preloader {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(255,255,255,0.9);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 40px; height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.preloader-text {
  margin-top: 10px;
  font-weight: 600;
  color: var(--text-muted);
}

/* =========================================
   7. PAGINAÇÃO
========================================= */
#paginacao-container button {
  background: #fff;
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-dark);
}
#paginacao-container button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#paginacao-container span {
  display: flex;
  align-items: center;
  font-weight: 600;
  font-size: 0.9rem;
}

/* =========================================
   8. MEDIA QUERIES (DESKTOP)
========================================= */
@media (min-width: 768px) {
  /* Header em linha */
  .header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .header-title h1 {
    font-size: 1.5rem;
  }

  .btn-novo-rdo {
    width: auto; /* Tamanho natural no desktop */
  }

  /* Filtros em linha */
  .filtro-container {
    flex-direction: row;
    align-items: center;
    gap: 15px;
  }
  .filtro-container select {
    width: auto;
    min-width: 200px;
  }

  /* Card RDO em linha */
  .linha-conteudo-fixa {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .lado-esquerdo {
    width: auto;
  }

  .lado-direito {
    width: auto;
    border-top: none;
    padding-top: 0;
    justify-content: flex-end;
    gap: 15px;
  }
}
/* =========================================
   AJUSTE DE LARGURA DESKTOP (95%)
========================================= */
@media (min-width: 1024px) {
  .content {
    /* Remove o limite antigo de 1000px */
    max-width: 95% !important;
    width: 95% !important;
    
    /* Mantém centralizado */
    margin-left: auto !important;
    margin-right: auto !important;
  }
}
/* =========================================
   GALERIA DE IMAGENS (Dentro do Acordeão)
========================================= */

/* Container que segura todas as imagens */
.rdo-galeria {
  display: grid;
  /* Cria colunas automáticas. Se não couber, joga pra baixo */
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  padding: 10px 0;
  width: 100%;
}

/* O Card de cada imagem */
.rdo-img-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  transition: transform 0.2s;
}

.rdo-img-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* A Imagem em si */
.rdo-img-card img {
  width: 100%;
  height: 120px; /* Altura fixa para ficarem alinhadas */
  object-fit: cover; /* Corta o excesso para não distorcer */
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

/* A Descrição abaixo da imagem */
.rdo-img-card span {
  padding: 8px;
  font-size: 0.8rem;
  color: #555;
  text-align: center;
  word-break: break-word;
  background-color: #fafafa;
  flex: 1; /* Empurra o texto para preencher espaço */
  display: flex;
  align-items: center;
  justify-content: center;
}
/* =========================================
   9. MODAL / LIGHTBOX DE IMAGEM
========================================= */
.modal-overlay {
  position: fixed; /* O SEGREDO: Fixa na tela, ignora o scroll */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85); /* Fundo escuro transparente */
  z-index: 10000; /* Garante que fique acima de tudo (até do preloader) */
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  backdrop-filter: blur(5px); /* Efeito de desfoque no fundo */
}

/* Quando a classe 'active' for adicionada via JS */
.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content-img {
  max-width: 90%;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content-img {
  transform: scale(1);
}

.modal-close-btn {
  position: absolute;
  top: 20px;
  right: 30px;
  color: #fff;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  z-index: 10001;
  transition: color 0.2s;
  background: transparent;
  border: none;
}

.modal-close-btn:hover {
  color: var(--danger); /* Usa a cor vermelha definida nas suas variáveis */
}
.rdo-galeria {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.foto-card {
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #eee;
    transition: transform 0.2s;
}

.foto-card:hover { transform: scale(1.02); }

.foto-card img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    cursor: pointer;
}

.foto-card p {
    font-size: 10px;
    padding: 5px;
    margin: 0;
    color: #444;
    text-align: center;
    line-height: 1.2;
}

.table-rdo {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
    margin-bottom: 15px;
}
.table-rdo th { background: #f3f4f6; padding: 8px; text-align: left; }
.table-rdo td { border-bottom: 1px solid #eee; padding: 8px; }
/* Garante que o conteúdo comece escondido e suma quando a classe estiver presente */
.hidden { 
    display: none !important; 
}

/* Estilo para dar um feedback visual quando o mouse passa no título */
.acordeon-title:hover {
    background-color: #f9fafb !important;
    transform: translateY(-1px);
    transition: all 0.2s;
}
/* CLASSE FUNDAMENTAL PARA O ACORDEON FUNCIONAR */
.hidden {
    display: none !important;
}

/* Opcional: para indicar que é clicável */
.acordeon-title {
    cursor: pointer;
    user-select: none; /* Evita selecionar o texto ao clicar rápido */
}
.hidden {
    display: none !important;
}

/* --- LAYOUT INTERNO DO ACORDEON (GRID DASHBOARD) --- */
.rdo-layout-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr; /* 3 Colunas Iguais */
    gap: 20px;
    margin-bottom: 25px;
}

/* Em telas menores (Tablets verticais e Celulares), vira uma coluna só */
@media (max-width: 1024px) {
    .rdo-layout-grid {
        grid-template-columns: 1fr;
    }
}

/* Estilo dos Cards internos (Informações, Equipe, Materiais) */
.rdo-card-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    height: fit-content; /* Ajusta altura ao conteúdo */
}

.rdo-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 8px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Linhas de informação (chave: valor) */
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.85rem;
    color: #475569;
}
.info-row:last-child { border-bottom: none; }
.info-label { font-weight: 600; color: #64748b; }
.info-value { font-weight: 500; text-align: right; color: #1e293b; }

/* Lista de Equipe e Materiais */
.simple-list-item {
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.85rem;
}
.simple-list-item:last-child { border-bottom: none; }
.item-primary { font-weight: 600; color: #334155; display: block; }
.item-secondary { font-size: 0.75rem; color: #64748b; display: block; margin-top: 2px; }

/* Seção Full Width (Imagens e Notas) */
.rdo-full-section {
    margin-top: 20px;
    border-top: 1px solid #e5e7eb;
    padding-top: 20px;
}