/* style.css - Sistema de Estilos Responsivo Mobile-First */
/* Uroginecologia Em Dia - Versão Otimizada para Mobile, Tablet e Desktop */

/* ==========================================
   RESET GLOBAL PARA RESPONSIVIDADE
   ========================================== */

/* Reset Global para Responsividade */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
  max-width: 100vw;
  margin: 0;
  padding: 0;
}

/* Correções do Footer */
footer {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  box-sizing: border-box;
}

footer * {
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ==========================================
   ACESSIBILIDADE - SKIP LINK
   ========================================== */

/* Skip Link - Para navegação por teclado */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #1e40af;
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  z-index: 100;
  border-radius: 0 0 4px 0;
  font-weight: 600;
}

.skip-link:focus {
  top: 0;
  z-index: 100;
}

/* Classe auxiliar para esconder visualmente mas manter acessível */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.sr-only:focus,
.focus\:not-sr-only:focus {
  position: static;
  width: auto;
  height: auto;
  padding: 0.5rem 1rem;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Media Query Mobile */
@media (max-width: 768px) {
  footer {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  footer .grid {
    grid-template-columns: 1fr !important;
  }

  footer a[href^="mailto:"] {
    word-break: break-all;
    font-size: 0.875rem;
  }
}

/* ==========================================
   VARIÁVEIS E CONFIGURAÇÕES BASE
   ========================================== */

:root {
  /* Cores do tema */
  --uro-azul-escuro: #1e40af;
  --uro-azul: #3b82f6;
  --uro-azul-claro: #60a5fa;
  --uro-branco: #ffffff;
  --uro-cinza: #f3f4f6;
  --uro-cinza-escuro: #6b7280;

  /* Breakpoints */
  --mobile-max: 767px;
  --tablet-min: 768px;
  --tablet-max: 1023px;
  --desktop-min: 1024px;

  /* Espaçamentos responsivos */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* Tamanhos de fonte base (mobile-first) */
  --font-xs: 0.875rem;  /* 14px - acessível em mobile */
  --font-sm: 0.875rem;  /* 14px */
  --font-base: 1rem;    /* 16px */
  --font-lg: 1.125rem;  /* 18px */
  --font-xl: 1.25rem;   /* 20px */
  --font-2xl: 1.5rem;   /* 24px */
  --font-3xl: 1.875rem; /* 30px */
  --font-4xl: 2.25rem;  /* 36px */

  /* Largura mínima touch-friendly */
  --touch-target-min: 44px;
}

/* ==========================================
   RESET E ESTILOS GLOBAIS
   ========================================== */

html {
  font-size: 16px; /* Base para rem */
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: #1f2937;

  /* Safe area insets para iPhones com notch e home indicator */
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
}

/* Garantir que imagens sejam sempre responsivas */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ==========================================
   BOTÕES E ELEMENTOS INTERATIVOS (Touch-Friendly)
   ========================================== */

button,
.btn,
a.button {
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

/* Aumentar área de toque em mobile */
@media (max-width: 767px) {
  button,
  .btn,
  a.button,
  .nav-button {
    padding: 1rem 1.25rem;
    font-size: var(--font-base);
  }

  /* Forçar tamanho mínimo de fonte em mobile (acessibilidade) */
  .text-xs,
  small {
    font-size: 0.875rem !important; /* 14px mínimo */
  }
}

/* ==========================================
   CARDS (Mobile-First)
   ========================================== */

.card-hover {
  transition: all 0.3s ease;
  cursor: pointer;
}

/* Em mobile, menos transformação para economizar performance */
@media (max-width: 767px) {
  .card-hover:active {
    transform: scale(0.98);
    box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.1);
  }
}

/* Em tablet e desktop, hover tradicional */
@media (min-width: 768px) {
  .card-hover:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15);
  }
}

/* ==========================================
   NAVEGAÇÃO (Mobile-First)
   ========================================== */

.nav-button {
  transition: all 0.3s ease;
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
}

/* Mobile: esconder navegação principal, mostrar apenas menu hamburger */
@media (max-width: 767px) {
  .nav-button {
    display: none !important;
  }

  #mobileMenuButton {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Tablet: mostrar navegação compacta */
@media (min-width: 768px) and (max-width: 1023px) {
  .nav-button {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }

  #mobileMenuButton {
    display: flex;
  }
}

/* Desktop: navegação completa */
@media (min-width: 1024px) {
  .nav-button:hover {
    background-color: var(--uro-azul);
    color: white;
  }

  #mobileMenuButton {
    display: none;
  }
}

/* ==========================================
   ANIMAÇÕES
   ========================================== */

.fade-in {
  animation: fadeIn 0.6s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Reduzir animações em dispositivos com preferência */
@media (prefers-reduced-motion: reduce) {
  .card-hover,
  .nav-button,
  .fade-in,
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================
   CARROSSÉIS (Mobile-First)
   ========================================== */

.carousel-container {
  display: flex;
  overflow-x: auto;
  scroll-behavior: smooth;
  gap: var(--spacing-sm);
  padding: var(--spacing-xs) 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling em iOS */
}

.carousel-container::-webkit-scrollbar {
  display: none;
}

.carousel-item {
  flex: 0 0 auto;
  width: 100%; /* Mobile: um item por vez */
  min-width: 0;
}

/* Tablet: 2 itens */
@media (min-width: 768px) and (max-width: 1023px) {
  .carousel-item {
    width: calc(50% - var(--spacing-sm) / 2);
  }
}

/* Desktop: 3 itens */
@media (min-width: 1024px) {
  .carousel-item {
    width: calc(33.333% - var(--spacing-sm) * 2 / 3);
  }
}

.news-carousel {
  display: flex;
  overflow-x: auto;
  scroll-behavior: smooth;
  gap: var(--spacing-md);
  padding: var(--spacing-xs) 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.news-carousel::-webkit-scrollbar {
  display: none;
}

.news-item {
  flex: 0 0 auto;
  width: 280px; /* Mobile */
}

@media (min-width: 768px) {
  .news-item {
    width: 320px; /* Tablet */
  }
}

@media (min-width: 1024px) {
  .news-item {
    width: 350px; /* Desktop */
  }
}

/* ==========================================
   GRID LAYOUTS RESPONSIVOS
   ========================================== */

.responsive-grid {
  display: grid;
  gap: var(--spacing-md);
}

/* Mobile: 1 coluna */
.responsive-grid {
  grid-template-columns: 1fr;
}

/* Tablet: 2 colunas */
@media (min-width: 768px) {
  .responsive-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-lg);
  }
}

/* Desktop: 3 colunas */
@media (min-width: 1024px) {
  .responsive-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ==========================================
   TIPOGRAFIA RESPONSIVA
   ========================================== */

/* Mobile: tamanhos menores */
h1 { font-size: var(--font-3xl); line-height: 1.2; }
h2 { font-size: var(--font-2xl); line-height: 1.3; }
h3 { font-size: var(--font-xl); line-height: 1.4; }
h4 { font-size: var(--font-lg); line-height: 1.4; }
p { font-size: var(--font-base); line-height: 1.6; }

/* Tablet: tamanhos médios */
@media (min-width: 768px) {
  h1 { font-size: var(--font-4xl); }
  h2 { font-size: var(--font-3xl); }
  h3 { font-size: var(--font-2xl); }
}

/* Desktop: tamanhos maiores */
@media (min-width: 1024px) {
  h1 { font-size: 3rem; }
  h2 { font-size: 2.5rem; }
  h3 { font-size: var(--font-2xl); }
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================
   CONTAINER E ESPAÇAMENTOS
   ========================================== */

.container {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--spacing-sm);
  padding-right: var(--spacing-sm);
}

/* Tablet */
@media (min-width: 768px) {
  .container {
    max-width: 768px;
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .container {
    max-width: 1024px;
  }
}

/* Desktop large */
@media (min-width: 1280px) {
  .container {
    max-width: 1280px;
    padding-left: var(--spacing-lg);
    padding-right: var(--spacing-lg);
  }
}

/* ==========================================
   HEADER RESPONSIVO
   ========================================== */

#header-component {
  position: relative;
  z-index: 40;
}

/* Mobile: layout em coluna, elementos empilhados */
@media (max-width: 767px) {
  header .container > div:first-child {
    flex-direction: column;
    align-items: stretch !important;
  }

  header h1 {
    font-size: 1.5rem !important;
    margin-bottom: var(--spacing-sm);
  }

  /* Search bar ocupa largura total em mobile */
  header .relative {
    width: 100% !important;
    margin-top: var(--spacing-sm);
  }

  /* Redes sociais menores em mobile */
  header .flex.space-x-4 a {
    padding: 0.5rem;
  }
}

/* Tablet: layout mais compacto */
@media (min-width: 768px) and (max-width: 1023px) {
  header h1 {
    font-size: 1.75rem !important;
  }
}

/* ==========================================
   FOOTER RESPONSIVO
   ========================================== */

#footer-component {
  margin-top: auto;
}

/* Mobile: grid de 1 coluna no footer */
@media (max-width: 767px) {
  footer .grid {
    grid-template-columns: 1fr !important;
    gap: var(--spacing-lg);
    text-align: center;
  }

  footer .flex.space-x-4 {
    justify-content: center;
  }
}

/* Tablet: 2 colunas no footer */
@media (min-width: 768px) and (max-width: 1023px) {
  footer .grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ==========================================
   MENU MOBILE
   ========================================== */

#mobileMenu {
  /* Otimizado para touch */
}

/* Menu mobile panel - safe area insets */
#mobileMenu > div:last-child {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

#mobileMenu a {
  min-height: var(--touch-target-min);
  display: flex;
  align-items: center;
}

/* ==========================================
   BADGES E CATEGORIAS
   ========================================== */

.categoria-badge {
  font-size: var(--font-xs);
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-weight: 600;
  display: inline-block;
}

@media (min-width: 768px) {
  .categoria-badge {
    font-size: var(--font-sm);
    padding: 0.375rem 1rem;
  }
}

/* Categorias de Protocolos */
.categoria-infeccioso {
  background-color: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.categoria-urodinamico {
  background-color: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #dbeafe;
}

.categoria-cirurgico {
  background-color: #f0fdf4;
  color: #16a34a;
  border: 1px solid #dcfce7;
}

.categoria-funcional {
  background-color: #faf5ff;
  color: #7c3aed;
  border: 1px solid #e9d5ff;
}

/* Categorias de Artigos */
.categoria-pesquisa {
  background-color: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.categoria-estudo {
  background-color: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #dbeafe;
}

.categoria-revisao {
  background-color: #f0fdf4;
  color: #16a34a;
  border: 1px solid #dcfce7;
}

.categoria-meta {
  background-color: #faf5ff;
  color: #7c3aed;
  border: 1px solid #e9d5ff;
}

/* ==========================================
   IMAGENS E GRADIENTES
   ========================================== */

.protocol-image,
.artigo-image {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #60a5fa 100%);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 767px) {
  .protocol-image,
  .artigo-image {
    min-height: 150px;
  }
}

/* ==========================================
   FORMULÁRIOS RESPONSIVOS
   ========================================== */

input[type="text"],
input[type="email"],
input[type="search"],
textarea,
select {
  font-size: var(--font-base);
  min-height: var(--touch-target-min);
}

/* Evitar zoom automático em iOS */
@media (max-width: 767px) {
  input[type="text"],
  input[type="email"],
  input[type="search"],
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* ==========================================
   TABELAS RESPONSIVAS
   ========================================== */

.evidence-table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--spacing-md) 0;
  overflow-x: auto;
  display: block;
}

@media (max-width: 767px) {
  .evidence-table {
    font-size: var(--font-sm);
  }

  .evidence-table th,
  .evidence-table td {
    padding: 0.5rem;
  }
}

.evidence-table th,
.evidence-table td {
  border: 1px solid #e5e7eb;
  padding: 0.75rem;
  text-align: left;
}

.evidence-table th {
  background-color: var(--uro-azul);
  color: white;
  font-weight: 600;
}

/* ==========================================
   ELEMENTOS ESPECIAIS
   ========================================== */

.highlight-box {
  background: #f0f9ff;
  border-left: 4px solid var(--uro-azul);
  padding: var(--spacing-md);
  border-radius: 0.5rem;
  margin: var(--spacing-md) 0;
}

@media (max-width: 767px) {
  .highlight-box {
    padding: var(--spacing-sm);
    border-left-width: 3px;
  }
}

.key-point {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: var(--spacing-md);
  border-radius: 0.5rem;
  margin: var(--spacing-md) 0;
}

/* ==========================================
   LOADING STATE
   ========================================== */

.loading {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  border: 3px solid #f3f4f6;
  border-top: 3px solid var(--uro-azul);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

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

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.sr-only:focus {
  position: static;
  width: auto;
  height: auto;
  padding: 0.5rem 1rem;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Focus states */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--uro-azul);
  outline-offset: 2px;
}

/* ==========================================
   UTILIDADES RESPONSIVAS
   ========================================== */

/* Ocultar em mobile */
@media (max-width: 767px) {
  .hidden-mobile {
    display: none !important;
  }
}

/* Ocultar em tablet */
@media (min-width: 768px) and (max-width: 1023px) {
  .hidden-tablet {
    display: none !important;
  }
}

/* Ocultar em desktop */
@media (min-width: 1024px) {
  .hidden-desktop {
    display: none !important;
  }
}

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

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

/* ==========================================
   PERFORMANCE E OTIMIZAÇÕES
   ========================================== */

/* Otimizar renderização de animações */
.card-hover,
.nav-button {
  will-change: transform;
}

/* Suavizar fontes */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Melhorar scroll em dispositivos touch */
.carousel-container,
.news-carousel {
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}

.carousel-item,
.news-item {
  scroll-snap-align: start;
}

/* ==========================================
   MELHORIAS DE RESPONSIVIDADE PARA PROTOCOLOS E ARTIGOS
   ========================================== */

/* Títulos de protocolos e artigos em mobile */
@media (max-width: 767px) {
  /* Títulos principais (H1) em páginas de protocolo/artigo */
  main h1 {
    font-size: 1.5rem !important;
    line-height: 1.3;
  }

  /* Subtítulos (H2) em conteúdo de protocolo/artigo */
  main .protocol-section h2,
  main article h2 {
    font-size: 1.25rem !important;
    line-height: 1.4;
  }

  /* Sub-subtítulos (H3) */
  main .protocol-section h3,
  main article h3 {
    font-size: 1.125rem !important;
  }

  /* Headers de protocolo - ajuste específico */
  .bg-white.rounded-lg.shadow-md.border-l-4 h1 {
    font-size: 1.375rem !important;
    line-height: 1.3;
  }

  /* Ajustar padding dos cards em mobile */
  .bg-white.rounded-lg.shadow-md {
    padding: 1rem !important;
  }

  /* Tabelas de recomendações em mobile */
  .recommendation-table {
    font-size: 0.875rem;
  }

  .recommendation-table th,
  .recommendation-table td {
    padding: 0.5rem;
  }

  /* Flowcharts em mobile - scroll horizontal */
  .flowchart-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mermaid {
    min-width: 600px;
  }
}

/* Tablets - ajustes intermediários */
@media (min-width: 768px) and (max-width: 1023px) {
  main h1 {
    font-size: 1.875rem !important;
  }

  main .protocol-section h2,
  main article h2 {
    font-size: 1.5rem !important;
  }

  .bg-white.rounded-lg.shadow-md {
    padding: 1.5rem !important;
  }
}

/* Cards de protocolos e artigos - responsividade */
@media (max-width: 767px) {
  /* Grid de 1 coluna em mobile */
  .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-3 {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
}

/* Breadcrumb em mobile */
@media (max-width: 767px) {
  nav.mb-6.text-sm {
    font-size: 0.75rem;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
}

/* Hero sections - ajuste de padding em mobile */
@media (max-width: 767px) {
  .bg-gradient-to-r.from-uro-azul_escuro.to-uro-azul {
    padding: 1.5rem !important;
  }

  .bg-gradient-to-r.from-uro-azul_escuro.to-uro-azul h1 {
    font-size: 1.75rem !important;
  }

  .bg-gradient-to-r.from-uro-azul_escuro.to-uro-azul p {
    font-size: 1rem !important;
  }
}

/* Botões de ação em mobile - mais espaço */
@media (max-width: 767px) {
  .flex.justify-between button,
  .flex.justify-between a {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }

  /* Botões empilhados em telas muito pequenas */
  .flex.justify-between.mt-8 {
    flex-direction: column;
    gap: 0.75rem;
  }

  .flex.justify-between.mt-8 a,
  .flex.justify-between.mt-8 button {
    width: 100%;
    justify-content: center;
  }
}

/* ==========================================
   SISTEMA DE PDF - ESTILOS
   ========================================== */

/* Classe para esconder elementos do PDF */
.no-print {
  /* Visível na tela, mas não vai para o PDF */
}

/* Animações para notificações de PDF */
@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

/* Estilos para PDF */
@media print {
  .no-print {
    display: none !important;
  }

  #conteudo-pdf {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  #conteudo-pdf h1 {
    page-break-after: avoid;
    font-size: 24pt !important;
  }

  #conteudo-pdf h2 {
    page-break-after: avoid;
    page-break-before: avoid;
    font-size: 18pt !important;
    margin-top: 20pt;
  }

  #conteudo-pdf h3 {
    page-break-after: avoid;
    font-size: 14pt !important;
  }

  #conteudo-pdf p {
    page-break-inside: avoid;
    orphans: 3;
    widows: 3;
  }

  #conteudo-pdf ul,
  #conteudo-pdf ol {
    page-break-inside: avoid;
  }
}

/* Para forçar quebra de página se necessário */
.page-break-before {
  page-break-before: always;
}

.page-break-after {
  page-break-after: always;
}

/* Estilo para conteúdo PDF (tela) */
#conteudo-pdf {
  line-height: 1.6;
}

#conteudo-pdf h1,
#conteudo-pdf h2,
#conteudo-pdf h3 {
  color: #1e40af;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

#conteudo-pdf p {
  margin-bottom: 1rem;
}

#conteudo-pdf ul,
#conteudo-pdf ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

#conteudo-pdf li {
  margin-bottom: 0.5rem;
}
