/* ================================================================
   SuporteGO — Responsive Design System
   Mobile-first. Breakpoints: 1280 / 1024 / 768 / 480 / 360
   ================================================================ */

/* ── TOKENS RESPONSIVOS ────────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --header-height: 60px;
    --sp-hero-v: var(--sp-8);
  }
}
@media (max-width: 480px) {
  :root {
    --header-height: 56px;
  }
}

/* ================================================================
   SITE PÚBLICO — index, contato, downloads, knowledge-base, post
   ================================================================ */

/* ── Header público ─────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
}
@media (max-width: 768px) {
  .site-header .container {
    padding: 0 var(--sp-4);
  }
  .main-nav { display: none !important; }
  .hamburger { display: flex !important; }

  /* Oculta btn-crm do header — fica disponível no menu mobile */
  .header-actions .btn-crm { display: none !important; }

  /* Logo: esconde tagline para economizar espaço */
  .logo-text .tagline { display: none; }
  .logo-img { height: 36px; }

  .mobile-nav {
    position: fixed;
    top: var(--header-height);
    left: 0; right: 0;
    background: var(--primary-dark);
    padding: var(--sp-4);
    display: none;
    flex-direction: column;
    gap: var(--sp-2);
    z-index: 99;
    box-shadow: var(--shadow-lg);
    max-height: calc(100vh - var(--header-height));
    overflow-y: auto;
  }
  .mobile-nav.open { display: flex; }
  .mobile-nav a {
    color: white;
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-sm);
    font-size: 1rem;
  }
  .mobile-nav a:hover { background: rgba(255,255,255,0.1); }
}

/* ── Hero ───────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .hero { padding: var(--sp-9) 0; }
}
@media (max-width: 768px) {
  .hero { padding: var(--sp-8) 0 var(--sp-7); text-align: center; }
  .hero-content { align-items: center; }
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-3);
  }
  .hero-actions .btn { width: 100%; justify-content: center; }
  .hero-visual { display: none; }
}

/* ── Grids de serviços / cards ──────────────────────────────────── */
@media (max-width: 1024px) {
  .services-grid,
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 600px) {
  .services-grid,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ── Seção de benefícios ────────────────────────────────────────── */
@media (max-width: 768px) {
  .benefits-grid { grid-template-columns: 1fr; }
  .benefits-visual { display: none; }
}

/* ── Seção about ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .about-grid { grid-template-columns: 1fr; }
  .about-visual { display: none; }
  .about-highlights { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .about-highlights { grid-template-columns: 1fr; }
}

/* ── Contato ────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .contact-grid { grid-template-columns: 1fr !important; }
}

/* ── Downloads ──────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .dl-layout,
  .kb-layout { grid-template-columns: 1fr !important; }
  .dl-sidebar,
  .kb-sidebar { order: -1; }
}

/* ── Knowledge base / Post ──────────────────────────────────────── */
@media (max-width: 768px) {
  .post-hero { padding: var(--sp-7) 0 var(--sp-5); }
  .post-hero h1 { font-size: clamp(1.4rem, 5vw, 2rem); }
  .post-content { padding: var(--sp-5) var(--sp-4); }
}

/* ── Footer ─────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .footer-grid { grid-template-columns: 1fr; }
  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: var(--sp-2);
  }
}

/* ── Botões — mobile full-width ─────────────────────────────────── */
@media (max-width: 480px) {
  .hero-actions .btn,
  .cta-actions .btn { width: 100%; justify-content: center; }
}

/* ================================================================
   PAINEL ADMIN
   ================================================================ */

/* ── Admin Header ───────────────────────────────────────────────── */
.admin-header {
  position: sticky;
  top: 0;
  z-index: 150;
}
.admin-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--sp-2);
  color: white;
  font-size: 1.25rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  align-items: center;
  justify-content: center;
}
.admin-hamburger:hover { background: rgba(255,255,255,0.12); }

@media (max-width: 900px) {
  .admin-hamburger { display: flex; }
}

/* ── Sidebar off-canvas drawer ──────────────────────────────────── */
@media (max-width: 900px) {
  .admin-layout {
    display: block !important;
    grid-template-columns: unset !important;
  }

  .admin-sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 280px !important;
    height: 100dvh !important;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    gap: 0 !important;
    padding: var(--sp-5) var(--sp-4) var(--sp-6) !important;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--primary-dark);
    box-shadow: var(--shadow-xl);
  }

  .admin-sidebar.sidebar-open {
    transform: translateX(0);
  }

  /* Mostrar título e seções no drawer mobile */
  .admin-sidebar h2,
  .admin-sidebar .sidebar-title { display: block !important; }

  /* Overlay escuro atrás do drawer */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 199;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    cursor: pointer;
  }
  .sidebar-overlay.sidebar-open { display: block; }

  .admin-content {
    padding: var(--sp-4) !important;
    min-height: 100vh;
  }
}

/* ── Summary / Stats grid ───────────────────────────────────────── */
.summary-grid {
  grid-template-columns: repeat(4, 1fr) !important;
}
@media (max-width: 1100px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 480px) {
  .summary-grid { grid-template-columns: 1fr !important; }
}

/* ── Gateway cards (gw-stats / gw-stat-row 3 colunas) ──────────── */
.gw-cards {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) !important;
}
@media (max-width: 600px) {
  .gw-cards { grid-template-columns: 1fr !important; }
  .gw-stats,
  .gw-stat-row {
    grid-template-columns: 1fr 1fr !important;
    gap: var(--sp-2) !important;
  }
  .gw-stat-val { font-size: 0.75rem !important; }
  .gw-footer { flex-direction: column; gap: var(--sp-1); }
}

/* ── Admin stats cards ──────────────────────────────────────────── */
.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 360px) {
  .stats-grid { grid-template-columns: 1fr !important; }
}

/* ── Tabelas admin ──────────────────────────────────────────────── */
.admin-table-wrap,
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}
@media (max-width: 768px) {
  .admin-table th,
  .admin-table td {
    padding: var(--sp-2) var(--sp-3) !important;
    font-size: 0.8rem !important;
    white-space: nowrap;
  }
  /* Esconde colunas menos prioritárias no mobile */
  .admin-table .col-hide-mobile { display: none !important; }
}

/* ── Formulários admin ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .form-grid-2,
  .form-row {
    grid-template-columns: 1fr !important;
  }
}

/* ── Modais admin ───────────────────────────────────────────────── */
.admin-modal-box,
.modal-box {
  width: 90vw !important;
  max-width: 640px !important;
  max-height: 90dvh !important;
  overflow-y: auto !important;
}
@media (max-width: 600px) {
  .admin-modal-box,
  .modal-box {
    width: 95vw !important;
    margin: var(--sp-4) auto !important;
    border-radius: var(--radius-md) !important;
  }
}

/* ── Filtros / toolbar ──────────────────────────────────────────── */
@media (max-width: 600px) {
  .admin-toolbar,
  .filter-bar {
    flex-direction: column !important;
    gap: var(--sp-3) !important;
  }
  .admin-toolbar input[type="text"],
  .admin-toolbar input[type="search"],
  .filter-bar input {
    width: 100% !important;
  }
}

/* ── Admin header right (links e avatar) ───────────────────────── */
@media (max-width: 600px) {
  .admin-header-right a:not(.avatar-link) { display: none; }
}

/* ================================================================
   PORTAL DO CLIENTE
   ================================================================ */

/* ── Portal layout sidebar ──────────────────────────────────────── */
@media (max-width: 900px) {
  .portal-layout {
    display: block !important;
    grid-template-columns: unset !important;
  }
  .portal-sidebar {
    position: fixed !important;
    top: 0; left: 0;
    width: 260px !important;
    height: 100dvh !important;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--primary-dark);
    padding: var(--sp-5) var(--sp-4) !important;
    box-shadow: var(--shadow-xl);
  }
  .portal-sidebar.sidebar-open { transform: translateX(0); }
  .portal-sidebar h2,
  .portal-sidebar .sidebar-title { display: block !important; }
  .portal-content,
  .portal-main {
    padding: var(--sp-4) !important;
  }
}

/* ── Portal header ──────────────────────────────────────────────── */
.portal-header { position: sticky; top: 0; z-index: 150; }
.portal-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--sp-2);
  color: white;
  font-size: 1.25rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  align-items: center;
  justify-content: center;
}
.portal-hamburger:hover { background: rgba(255,255,255,0.12); }
@media (max-width: 900px) {
  .portal-hamburger { display: flex; }
}

/* ── Portal cards de resumo ─────────────────────────────────────── */
@media (max-width: 768px) {
  .portal-summary-grid,
  .fatura-summary { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 480px) {
  .portal-summary-grid,
  .fatura-summary { grid-template-columns: 1fr !important; }
}

/* ── Fatura / cobrança cards ────────────────────────────────────── */
@media (max-width: 600px) {
  .fatura-card {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: var(--sp-3) !important;
  }
  .fatura-card .fatura-actions { width: 100%; }
  .fatura-card .fatura-actions .btn { width: 100%; justify-content: center; }
}

/* ================================================================
   UTILITÁRIOS RESPONSIVOS GLOBAIS
   ================================================================ */

/* Esconde visualmente em mobile */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
}
@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}

/* Texto truncado uma linha */
.text-truncate {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Container responsivo */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--sp-5);
}
@media (max-width: 768px) {
  .container { padding: 0 var(--sp-4); }
}
@media (max-width: 480px) {
  .container { padding: 0 var(--sp-3); }
}

/* Scroll horizontal suave em tabelas e cards */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.scroll-x::-webkit-scrollbar { height: 4px; }
.scroll-x::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}

/* ── Summary card valor não cortar ──────────────────────────────── */
.summary-card {
  min-width: 0;
  overflow: hidden;
}
.summary-card .amount,
.summary-card h2,
.summary-card .val {
  font-size: clamp(1rem, 2.5vw, 1.5rem) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Imagens responsivas ────────────────────────────────────────── */
img { max-width: 100%; height: auto; }

/* ── Smooth focus ring acessível ────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
