/* ==========================================================================
   Angola Transparente — Camada Responsiva Global
   Carregada por último em todas as páginas. Nenhum componente é removido:
   apenas reorganizado (empilhado, em grelha ou em menu) por breakpoint.
   Breakpoints: 1280 · 1100 · 900 · 640 · 420
   ========================================================================== */

html, body { max-width: 100%; }
body { overflow-x: clip; }

/* Evita que filhos de grelhas forcem largura (gráficos/tabelas) */
.grid-2 > *, .grid-3 > *, .kpis > *, .detail-grid > *, .detail-side > *,
.map-layout > *, .news-composite-grid > *, .pub-steps-grid > *,
.futuristic-stat-strip > *, .telemetry-grid > * { min-width: 0; }

.card-head { flex-wrap: wrap; }
.chart svg { max-width: 100%; }
.sidebar { overflow-y: auto; scrollbar-width: none; }
.sidebar::-webkit-scrollbar { display: none; }

/* ==========================================================================
   LANDING (index.html)
   ========================================================================== */

/* Botão hambúrguer da navbar pública (só aparece em ecrãs pequenos) */
.pub-menu-btn {
  display: none;
  width: 40px; height: 40px;
  border: 1px solid rgba(0, 0, 0, .08); border-radius: 12px;
  background: rgba(255, 255, 255, .9);
  align-items: center; justify-content: center;
  color: #0b1a15;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .05);
  transition: background .2s, transform .15s;
}
.pub-menu-btn:hover { background: #fff; transform: scale(1.04); }
.pub-menu-btn svg { width: 20px; height: 20px; }
.pub-menu-btn .i-close { display: none; }
body.pubnav-open .pub-menu-btn .i-open { display: none; }
body.pubnav-open .pub-menu-btn .i-close { display: block; }
.pub-nav .pub-nav-mobile { display: none; }

@media (max-width: 1280px) {
  .pub-nav { gap: 22px; }
  .pub-header { padding: 0 32px; }
}

/* ---------- ≤1100: menu hambúrguer + hero empilhado ---------- */
@media (max-width: 1100px) {
  .pub-header { padding: 0 24px; height: 72px; }
  .pub-menu-btn { display: inline-flex; }

  .pub-nav {
    display: none;
    position: absolute; top: 72px; left: 16px; right: 16px;
    flex-direction: column; align-items: stretch; gap: 2px;
    padding: 10px;
    background: rgba(255, 255, 255, .97);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border: 1px solid #e6eeea; border-radius: 18px;
    box-shadow: 0 24px 50px -16px rgba(6, 43, 34, .28);
    animation: fadeUp .25s var(--ease) both;
  }
  body.pubnav-open .pub-nav { display: flex; }
  .pub-nav a { display: block; padding: 12px 14px; border-radius: 12px; font-size: 15px; }
  .pub-nav a:hover { background: #f2f8f5; }
  .pub-nav a.active { background: #eaf7f1; color: #10875c; }
  .pub-nav a.active::after { display: none; }

  /* Hero: texto em cima, banner completo por baixo */
  .pub-hero {
    flex-direction: column; align-items: stretch;
    min-height: 0;
    padding: 100px 24px 28px;
    background: linear-gradient(180deg, #f2f9f5 0%, #ffffff 100%);
  }
  .pub-hero-grid { order: 1; }
  .pub-hero-copy { max-width: 640px; }
  .pub-hero-bg {
    order: 2; position: relative; inset: auto;
    width: 100%; aspect-ratio: 2172 / 724;
    margin-top: 28px;
    border-radius: 20px; overflow: hidden;
    box-shadow: 0 20px 44px -18px rgba(6, 43, 34, .35);
  }
  .pub-hero-bg img {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: cover; object-position: center;
    -webkit-mask-image: none; mask-image: none;
  }
  .pub-hero-overlay { background: linear-gradient(0deg, rgba(2, 36, 26, .12), transparent 40%); }

  /* Faixas */
  .pub-features-container, .pub-stats-wrapper, .pub-steps-sec, .pub-news-sec { padding-left: 24px; padding-right: 24px; }
  .pub-features-container { margin-top: 8px; }

  .pub-stats-pill {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px 16px; padding: 22px 26px; border-radius: 22px;
  }
  .stat-divider { display: none; }
  .btn-stats-link { grid-column: 1 / -1; justify-self: center; }

  .steps-cards-flow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .step-arrow-divider { display: none; }
  .step-card-box { min-height: 0; }
}

/* ---------- ≤900 ---------- */
@media (max-width: 900px) {
  .pub-features-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 10px; }
  .feat-item { border-right: none !important; border-bottom: 1px solid #f1f5f3; }
  .feat-item:nth-last-child(-n+1) { border-bottom: none; }
  .feat-item:last-child { grid-column: 1 / -1; }

  .news-items-row { grid-template-columns: 1fr; gap: 6px; }
  .news-item-content h3 { -webkit-line-clamp: 3; }

  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; }
  .footer-grid > div:first-child { grid-column: 1 / -1; }
  .pub-footer { padding: 44px 24px 28px; }
}

/* ---------- ≤640: telemóvel ---------- */
@media (max-width: 640px) {
  .pub-header { padding: 0 16px; height: 66px; }
  .pub-nav { top: 66px; left: 12px; right: 12px; }
  .pub-brand { gap: 9px; min-width: 0; }
  .pub-brand .brand-mark svg { width: 28px; height: 28px; }
  .pub-brand .brand-name { font-size: 15px; }
  .pub-brand .brand-sub { font-size: 8px; }
  .pub-actions { gap: 8px; }
  .pub-search-btn { width: 36px; height: 36px; }
  .pub-btn-entrar { padding: 8px 16px; font-size: 13px; }
  .pub-btn-criar { display: none; }           /* passa para o menu */
  .pub-nav .pub-nav-mobile { display: block; }
  .pub-nav .pub-nav-cta {
    margin-top: 6px; text-align: center;
    background: #023826; color: #fff !important; font-weight: 700;
  }
  .pub-nav .pub-nav-cta:hover { background: #01291b; }

  .pub-hero { padding: 88px 16px 22px; }
  .pub-hero-pill { font-size: 11.5px; padding: 5px 11px; }
  .pub-hero-copy h1 { font-size: clamp(28px, 8.4vw, 34px); }
  .pub-hero-copy p { font-size: 14px; }
  .pub-hero-actions { flex-direction: column; align-items: stretch; gap: 10px; }
  .hero-btn-primary, .hero-btn-secondary { justify-content: center; padding: 13px 20px; }
  .pub-hero-sub { text-align: center; }
  .pub-hero-bg { aspect-ratio: 4 / 3; margin-top: 22px; border-radius: 18px; }
  .pub-hero-bg img { object-position: 72% center; }

  .pub-features-container, .pub-stats-wrapper, .pub-steps-sec, .pub-news-sec { padding-left: 16px; padding-right: 16px; }
  .pub-features-bar { grid-template-columns: 1fr; }
  .feat-item:last-child { grid-column: auto; }
  .feat-item:nth-last-child(-n+1) { border-bottom: none; }

  .pub-stats-wrapper { margin: 24px auto 32px; }
  .pub-stats-pill { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 20px; gap: 18px 12px; }
  .stat-pill-item b { font-size: 16px; }
  .btn-stats-link { width: 100%; justify-content: center; }

  .pub-steps-sec { margin: 28px auto 32px; }
  .steps-copy h2 { font-size: 26px; }
  .steps-cards-flow { grid-template-columns: 1fr; }

  .pub-news-sec { margin: 28px auto 40px; }
  .news-white-card { padding: 18px 16px; }
  .news-head-row { flex-wrap: wrap; gap: 12px; }
  .news-head-row h2 { font-size: 17px; }

  /* Banner memorial: imagem em cima, texto por baixo */
  .news-memorial-banner { flex-direction: column; align-items: stretch; }
  .memorial-banner-bg {
    position: relative; width: 100%; height: 170px;
    -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 55%, transparent 100%);
    background-position: center 30%;
  }
  .memorial-banner-content { padding: 4px 20px 24px; max-width: none; }

  .footer-grid { grid-template-columns: 1fr 1fr; gap: 26px 18px; }
  .pub-footer { padding: 36px 16px 24px; }
  .footer-bottom { flex-direction: column; gap: 12px; text-align: center; }
  .footer-bottom > div { flex-wrap: wrap; justify-content: center; }
}

@media (max-width: 420px) {
  .pub-brand .brand-sub { display: none; }
  .pub-stats-pill { grid-template-columns: 1fr 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   APLICAÇÃO (shell + páginas)
   ========================================================================== */
@media (max-width: 1280px) {
  .detail-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .futuristic-stat-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .futuristic-stat-strip > div:first-child { grid-column: 1 / -1; }
  .futuristic-stat-strip > div { border-top: 1px solid rgba(227, 235, 231, .8); }
  .futuristic-stat-strip > div:nth-child(2) { border-left: 0; }
  .futuristic-stat-strip > div:nth-child(5) { border-left: 0; }
}

@media (max-width: 1100px) {
  .telemetry-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-float { right: 4%; }
}

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .page-head { flex-wrap: wrap; }
  .page-actions { flex-wrap: wrap; }
  .futuristic-stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .futuristic-stat-strip > div:nth-child(n) { border-left: 0; }
  .futuristic-stat-strip > div:nth-child(odd):not(:first-child) { border-left: 1px solid rgba(227, 235, 231, .8); }
  .futuristic-stat-strip > div:nth-child(5) { border-left: 1px solid rgba(227, 235, 231, .8); }
  .map-stage { min-height: 460px; }
}

@media (max-width: 640px) {
  /* Topbar compacta: pesquisa flexível, avatar sempre visível */
  .topbar { gap: 10px; height: 60px; padding-left: 14px !important; padding-right: 14px !important; }
  .topbar .search { flex: 1; width: auto; min-width: 0; }
  .topbar-right { gap: 6px; flex-shrink: 0; }
  .user img { width: 34px; height: 34px; }

  .content { padding: 20px 14px 36px !important; }
  .page-title { font-size: 23px; }
  .page-head { gap: 14px; margin-bottom: 18px; }
  .page-head > div:first-child { min-width: 0; }
  .page-actions { width: 100%; }
  .page-actions .btn:not(.btn-icon) { flex: 1; }

  .card-pad { padding: 16px; }
  .future-card .card-head { padding: 14px 16px; }

  /* Pesquisa e filtros em grelha */
  .search-row .btn { width: 100%; }
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .spacer { display: none; }
  .filters > * { min-width: 0; }
  .filters .select, .filters .select select { width: 100%; }
  .filters .btn { width: 100%; }

  .table th { padding: 10px 12px; }
  .table td { padding: 12px; }
  .list-foot { justify-content: center; text-align: center; }
  .pagination { flex-wrap: wrap; justify-content: center; }

  /* Painel */
  .hero-inner { padding: 6px 16px 0 !important; min-height: 0; }
  .hero-copy h1 { font-size: 32px; }
  .hero-copy p { font-size: 14.5px; }
  .hero-actions .btn { flex: 1; }
  .hero-map { height: 300px; }
  .stat-float { right: 0; padding: 10px 14px; min-width: 0; }
  .stat-float .v { font-size: 22px; }
  .luanda-card { left: auto; right: 0; }
  .luanda-card::before { display: none; }
  .kpis { gap: 12px; margin-top: -56px; }
  .kpi { padding: 16px; }
  .prov-row { grid-template-columns: 90px 1fr 48px; }
  .donut, .donut-wrap .chart.donut { width: 190px !important; height: 190px !important; }

  /* Fornecedor */
  .telemetry-grid { gap: 10px; }
  .telemetry-card { padding: 14px; }
  .telemetry-card .big { font-size: 22px; }
  .futuristic-stat-strip > div { padding: 16px; }
  .futuristic-stat-strip b { font-size: 21px; }
  .doc-item { flex-wrap: wrap; }
  .doc-item:hover { transform: none; }
  .org-logo { width: 48px; height: 48px; border-radius: 14px; }

  /* Contrato */
  .detail-side { grid-template-columns: 1fr; }
  .gallery-thumbs { gap: 6px; }
  .play { width: 54px; height: 54px; }

  /* Mapa */
  .map-stage { min-height: 380px; }
  .map-stage .glass { max-width: calc(100% - 24px); }

  /* Toast e modal */
  #toast { max-width: calc(100% - 28px); }
}

@media (max-width: 420px) {
  .telemetry-grid { grid-template-columns: 1fr; }
  .futuristic-stat-strip { grid-template-columns: 1fr; }
  .futuristic-stat-strip > div:nth-child(n) { border-left: 0; }
  .filters { grid-template-columns: 1fr; }
  .topbar .kbd { display: none; }
}
