/* =====================================================================
   Modernizacao visual + celular (out/2026).
   Carregado DEPOIS de app.css e do <style> critico: so sobrepoe.
   Tirar o <link> deste arquivo do index.html volta ao visual anterior.
   Nao muda IDs nem estrutura (REGRAS DE OURO).
   ===================================================================== */

:root {
  --shadow-soft: 0 1px 2px rgba(31, 31, 36, 0.04), 0 10px 28px rgba(47, 103, 199, 0.08);
  --shadow-card: 0 2px 6px rgba(31, 31, 36, 0.05), 0 22px 48px rgba(47, 103, 199, 0.12);
  --radius-md: 20px;
  --ring: 0 0 0 3px rgba(78, 143, 216, 0.28);
}

body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Link longo sem espaco (Instagram/Facebook na pagina Sobre) era cortado no celular */
  overflow-wrap: break-word;
}

h1, h2, h3 { text-wrap: balance; }
p, li { text-wrap: pretty; }

/* ---------- Titulos: letras estavam tao juntas que as palavras grudavam ---------- */
.hero-copy h1 {
  font-size: clamp(2.6rem, 3.6vw + 1rem, 4.6rem);
  line-height: 1.06;
  letter-spacing: -0.025em;
  word-spacing: 0.05em;
  max-width: 15ch;
}

.section-heading h2,
.two-column h2 {
  font-size: clamp(1.6rem, 1.6vw + 1rem, 2.4rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.home-cta-card h2 { letter-spacing: -0.015em; word-spacing: 0.04em; }
.section-heading h2, .two-column h2, .hero-card-content h2 { word-spacing: 0.03em; }

.section-heading p { color: var(--color-text-soft); margin: 6px 0 0; }

.eyebrow {
  width: fit-content;
  padding: 6px 12px;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
}

/* ---------- Cabecalho: menu cabia so em 2 linhas no computador ---------- */
.header-inner { min-height: 76px; gap: 16px; }
.brand img { width: 50px; height: 50px; border-radius: 14px; }
.primary-nav { gap: 2px; }
.nav-link { padding: 9px 12px; font-size: 0.93rem; white-space: nowrap; }
.nav-link.is-active { background: rgba(78, 143, 216, 0.12); }

@media (min-width: 901px) and (max-width: 1240px) {
  .brand small { display: none; }
  .nav-link { padding: 8px 9px; font-size: 0.88rem; }
}

@media (min-width: 901px) and (max-width: 1010px) {
  .brand > span { display: none; }
}

/* ---------- Botoes: btn-outline, btn-sm e section-footer nao tinham estilo ---------- */
.btn { min-height: 46px; letter-spacing: 0.01em; }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-outline {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(78, 143, 216, 0.45);
  color: var(--color-primary);
}
.btn-outline:hover { background: rgba(78, 143, 216, 0.08); border-color: var(--color-primary); }

.btn-sm { min-height: 40px; padding: 0 16px; font-size: 0.9rem; }

.section-footer {
  display: flex;
  justify-content: center;
  margin-top: 28px;
}

/* ---------- Cards ---------- */
.surface { border-color: rgba(224, 223, 221, 0.75); }

.animal-card,
.shop-card,
.donor-plan-card,
.summary-card,
.stat-card {
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

@media (hover: hover) {
  .animal-card:hover,
  .shop-card:hover,
  .donor-plan-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card);
  }
}

/* Foto do animal: altura e recorte NAO mudam. O dono ajusta o foco (foto_pos_x/y no
   painel) olhando o card de 220 px de app.css; mudar altura ou dar zoom desloca o enquadramento. */
.animal-content { padding: 18px 20px 20px; }
.animal-content h3 { font-size: 1.15rem; }
.animal-content .action-group { display: flex; flex-wrap: wrap; gap: 8px; }

.stat-card { min-height: 0; padding: 18px 20px; }
.stat-card strong { font-family: var(--font-heading); letter-spacing: -0.01em; }

.summary-card strong { letter-spacing: -0.01em; }

.shop-card-image { min-height: 0; aspect-ratio: 4 / 3; }

.site-footer { background: rgba(255, 255, 255, 0.9); }

/* Barra de rolagem discreta nas tabelas */
.table-container { scrollbar-width: thin; }

/* ---------- Painel (admin) ---------- */
/* Item de grid nao encolhia abaixo do conteudo: Configuracoes estourava 90 px no celular. */
.admin-grid > *, .admin-tab-panel .surface, .form-grid > *, .form-row > * { min-width: 0; }
input[type="range"] { margin: 0; }
input[type="file"] { max-width: 100%; }
.admin-tabs { scrollbar-width: none; }
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tab { white-space: nowrap; }
/* Formularios do painel nao tinham espaco entre os campos (rotulo colado no campo de cima) */
.admin-tab-panel form:not(.filter-inline):not(.conc-filtros) { display: grid; gap: 14px; }
.admin-tab-panel form .form-actions { margin-top: 4px; }

/* =====================================================================
   CELULAR
   ===================================================================== */
@media (max-width: 900px) {
  /* Cabecalho mais baixo: sobra mais tela para o conteudo */
  html body { padding-top: 64px; }
  .header-inner { min-height: 64px; }
  .brand { gap: 10px; }
  .brand img { width: 42px; height: 42px; border-radius: 12px; }
  .brand small { display: none; }
  .brand strong { font-size: 1rem; }

  .mobile-toggle {
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 16px;
    font-weight: 700;
    color: var(--color-text);
  }
  .mobile-toggle::before {
    content: "";
    width: 18px;
    height: 12px;
    background:
      linear-gradient(currentColor 0 0) top / 100% 2px no-repeat,
      linear-gradient(currentColor 0 0) center / 100% 2px no-repeat,
      linear-gradient(currentColor 0 0) bottom / 100% 2px no-repeat;
  }
  header .primary-nav { top: 70px; }
  header .primary-nav .nav-link { font-size: 1rem; padding: 13px 16px; }

  .section { padding: 36px 0; }
  .hero-section { padding: 24px 0 8px; }

  .hero-copy { gap: 16px; }
  .hero-copy h1 {
    font-size: clamp(2.05rem, 8.4vw, 2.9rem);
    line-height: 1.08;
    letter-spacing: -0.02em;
    max-width: none;
  }
  .hero-copy p { font-size: 1rem; line-height: 1.6; }
  .hero-actions .btn,
  .home-cta-actions .btn { flex: 1 1 auto; padding: 0 18px; white-space: nowrap; }

  .hero-card { padding: 18px; gap: 14px; }
  .hero-logo { max-height: 200px; width: auto; max-width: 100%; }
  .hero-card-content h2 { font-size: 1.3rem; }

  /* Numeros da home: 2 por linha, compactos */
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 22px; }
  .stat-card { padding: 14px; gap: 2px; }
  .stat-card strong { font-size: 1.25rem; }
  .stat-card span { font-size: 0.82rem; line-height: 1.35; }

  .home-cta-card { padding: 20px; gap: 10px; }
  .home-cta-card h2 { font-size: 1.35rem; line-height: 1.15; }

  .section-heading { margin-bottom: 16px; }
  .section-heading h2,
  .two-column h2 { font-size: 1.55rem; }

  /* Animais da home: carrossel deslizante em vez de 14 cards empilhados
     (a lista completa segue na pagina Animais, botao "Ver todos"). */
  #animalsGrid {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    margin: 0 -16px;
    padding: 4px 16px 16px;
    scroll-padding-left: 16px;
    scrollbar-width: none;
  }
  #animalsGrid::-webkit-scrollbar { display: none; }
  #animalsGrid > .animal-card { flex: 0 0 84%; scroll-snap-align: start; }
  #animalsGrid .animal-content > p:not(.animal-meta) {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .animal-content { padding: 16px; }
  .animal-content .action-group .btn { flex: 1 1 100%; }

  /* Resumos da transparencia: 2 por linha */
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .summary-card { padding: 14px; }
  .summary-card span { font-size: 0.8rem; }
  .summary-card strong { font-size: 1.12rem; }

  /* Lojinha: 2 produtos por linha */
  .shop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .shop-card { gap: 10px; padding: 10px; }
  .shop-card-body { gap: 6px; }
  .shop-card-body h3 { font-size: 0.98rem; line-height: 1.25; }
  .shop-card-body p {
    font-size: 0.85rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .shop-card-body small { font-size: 0.75rem; }
  .shop-card strong { font-size: 1.15rem; }
  .shop-card-body .btn { min-height: 40px; padding: 0 12px; width: 100%; }
  .shop-card-body .tag { min-height: 24px; font-size: 0.72rem; align-self: flex-start; }

  .chart-card, .table-card, .institution-card, .donate-card { padding: 18px; }

  /* Transparencia: filtros e resumos 2 por linha; movimentacoes rolam numa caixa
     (60 linhas viravam 4.400 px de pagina). Cabecalho fixo com fundo + z-index. */
  .dashboard-filter-bar,
  .mov-filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 14px; }
  .dashboard-filter-bar > :last-child,
  .mov-filter-bar .mov-filter-check,
  .mov-filter-bar .mov-filter-actions { grid-column: 1 / -1; }
  .mov-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .mov-table-container {
    max-height: 68vh;
    overflow: auto;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    -webkit-overflow-scrolling: touch;
  }
  .mov-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--color-surface);
    box-shadow: 0 1px 0 var(--color-border);
  }
  .report-table-container .table-container { max-height: 60vh; overflow: auto; }

  .site-footer { padding: 32px 0 40px; }
  .footer-grid { gap: 22px; }

  /* Painel no celular: 1 coluna, campos sem largura minima, abas deslizam */
  .admin-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-row { grid-template-columns: minmax(0, 1fr); }
  .admin-tab-panel .field { min-width: 0; }
  .admin-tab-panel .surface { padding: 16px; }
  .admin-header { padding: 18px; }
  .admin-header h2 { font-size: 1.25rem; }
  .admin-tabs {
    position: sticky;
    top: 64px;
    z-index: 5;
    margin: 0 -16px 14px;
    padding: 8px 16px;
    background: rgba(247, 246, 243, 0.92);
    backdrop-filter: blur(12px);
  }
  .admin-tab-panel .filter-inline > * { flex: 1 1 140px; }
}

/* Tablet: 2 animais visiveis no carrossel, resumos em 4 colunas */
@media (min-width: 600px) and (max-width: 900px) {
  #animalsGrid > .animal-card { flex-basis: 46%; }
  .summary-grid, .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .shop-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 380px) {
  .shop-grid { grid-template-columns: 1fr; }
  .stats-grid { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .animal-card, .shop-card, .donor-plan-card { transition: none; }
  .animal-card:hover, .shop-card:hover, .donor-plan-card:hover { transform: none; }
}
