/* ═══════════════════════════════════════════════════════════════════
   Free Tecnologia — Responsive Overrides v2
   Unifica breakpoints e consertos mobile-first em todo o site.
   Carregado DEPOIS de app.css e dos CSS scoped das páginas, por isso
   vence nos conflitos sem precisar editar cada página.
   
   Breakpoints oficiais:
     ≤ 1024px → tablet landscape / desktop pequeno
     ≤  768px → tablet portrait
     ≤  520px → mobile
     ≤  380px → mobile pequeno
   ═══════════════════════════════════════════════════════════════════ */

/* ============================================================
   FIX BASE — preveni overflow horizontal e box-sizing
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

img, svg, video, canvas, iframe { max-width: 100%; height: auto; }

/* Container responsivo unificado */
.container {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: clamp(1rem, 4vw, 1.5rem);
    padding-right: clamp(1rem, 4vw, 1.5rem);
}

/* ============================================================
   TIPOGRAFIA FLUIDA
   ============================================================ */
h1 { font-size: clamp(2rem, 5vw, 3rem) !important; line-height: 1.12 !important; }
h2 { font-size: clamp(1.6rem, 4vw, 2.4rem) !important; line-height: 1.2 !important; }
h3 { font-size: clamp(1.15rem, 2.5vw, 1.5rem) !important; }
h4 { font-size: clamp(1rem, 2vw, 1.25rem) !important; }

.hero-title        { font-size: clamp(2rem, 5vw, 3.5rem) !important; }
.section-title     { font-size: clamp(1.6rem, 4vw, 2.5rem) !important; }
.cta-title         { font-size: clamp(1.5rem, 4vw, 2.4rem) !important; }

/* ============================================================
   HERO — layout responsivo robusto
   ============================================================ */
@media (max-width: 1024px) {
    .hero-section { min-height: auto !important; padding-top: 4rem !important; padding-bottom: 3rem !important; }
    .hero-layout {
        grid-template-columns: 1fr !important;
        gap: 2.5rem !important;
    }
    .hero-content { text-align: left; }
    .hero-visual { max-width: 560px; margin: 0 auto; width: 100%; }
    .hero-description { max-width: 100%; }
    .hero-stats { max-width: 100% !important; }
}

@media (max-width: 768px) {
    .hero-section::before { opacity: 0.28 !important; }
    .hero-actions { flex-direction: column; align-items: stretch; width: 100%; }
    .hero-actions .btn, .hero-actions a {
        width: 100%;
        justify-content: center;
    }
    .hero-trust { font-size: 0.82rem; gap: 0.4rem; }
    .hero-trust-sep { display: none; }
    .hero-trust-item { width: 100%; }

    /* Stats empilhando em 2 colunas */
    .hero-stats {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem !important;
        padding: 1.25rem !important;
    }
    .hero-stats .stat-divider { display: none; }
    .hero-stats-caption { font-size: 0.7rem; }

    /* Painel menor */
    .hero-panel { padding: 1.25rem !important; }
    .panel-metric-value { font-size: 1.6rem !important; }
    .panel-bar-row {
        grid-template-columns: 1fr auto auto !important;
        gap: 0.5rem !important;
    }
    .bar-track { max-width: 100px; }

    /* Floating card — recolocado de forma segura */
    .hero-floating-card {
        bottom: -1rem !important;
        left: 0 !important;
        right: auto !important;
        padding: 0.7rem 1rem !important;
        gap: 0.6rem !important;
    }
    .hero-floating-card strong { font-size: 0.85rem !important; }
    .hero-floating-card span  { font-size: 0.72rem !important; }
}

@media (max-width: 520px) {
    .hero-stats { grid-template-columns: 1fr !important; }
    .hero-stats .stat-item { border-bottom: 1px solid var(--border-subtle); padding-bottom: 0.65rem; }
    .hero-stats .stat-item:last-child { border-bottom: none; padding-bottom: 0; }
    .hero-title-accent { display: inline; }
}

/* ============================================================
   SEÇÕES — padding vertical adaptativo em todas
   ============================================================ */
section {
    padding-top: clamp(2.5rem, 6vw, 5rem) !important;
    padding-bottom: clamp(2.5rem, 6vw, 5rem) !important;
}

.section-header {
    margin-bottom: clamp(1.5rem, 4vw, 3rem) !important;
}

/* ============================================================
   GRIDS — forçar colapso adequado
   ============================================================ */
@media (max-width: 768px) {
    .steps-grid,
    .services-grid,
    .verticals-grid,
    .models-grid,
    .testimonials-grid,
    .cases-grid,
    .techstack-strip,
    .partners-logos {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .techstack-strip,
    .partners-logos {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: flex-start !important;
    }

    .step-card, .service-card, .vertical-card, .model-card,
    .testimonial-card, .case-card {
        padding: 1.5rem 1.25rem !important;
    }

    /* Modelos — remover o "-8px" do featured no mobile */
    .model-card--featured { transform: none !important; }

    /* CTA card */
    .cta-card { padding: 2rem 1.25rem !important; }
    .cta-actions { flex-direction: column; align-items: stretch; width: 100%; }
    .cta-actions a { width: 100%; justify-content: center; }
}

/* ============================================================
   VERTICAIS/MODELOS — páginas internas
   ============================================================ */
@media (max-width: 768px) {
    .ind-block-grid,
    .mod-grid {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
    }

    .ind-block-cta,
    .mod-cta {
        flex-direction: column !important;
        align-items: stretch !important;
        text-align: left !important;
        gap: 0.75rem !important;
    }
    .ind-block-cta .btn-primary,
    .mod-cta .btn-primary { justify-content: center; }

    .mod-ribbon {
        position: static !important;
        display: inline-block !important;
        margin-bottom: 1rem !important;
    }

    /* Compare table colapsa */
    .compare-row {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }
    .compare-row.compare-header { display: none !important; }
    .compare-row > div:first-child {
        color: var(--brand-cyan-light) !important;
        text-transform: uppercase;
        font-size: 0.72rem !important;
        letter-spacing: 0.08em;
        padding-bottom: 0.35rem;
        border-bottom: 1px solid var(--border-subtle);
    }
    .compare-row > div:not(:first-child) { text-align: left !important; }
    .compare-row .featured {
        border-left: 3px solid var(--brand-cyan) !important;
        border-right: none !important;
        padding-left: 0.75rem !important;
    }
}

/* ============================================================
   DIAGNÓSTICO — formulário mobile-first
   ============================================================ */
@media (max-width: 640px) {
    .diag-section { padding: 2rem 0 3rem !important; }
    .diag-card { padding: 1.75rem 1.25rem 1.5rem !important; }

    .diag-progress {
        gap: 0.2rem !important;
        padding: 0 !important;
    }
    .diag-step-pill {
        padding: 0.25rem 0.4rem !important;
    }
    .diag-step-pill .pill-label { display: none !important; }
    .pill-sep { max-width: 18px !important; }

    .diag-options--grid { grid-template-columns: 1fr !important; }

    .diag-option { padding: 0.85rem !important; gap: 0.75rem !important; }
    .diag-option .opt-icon { width: 38px !important; height: 38px !important; }
    .diag-option .opt-text strong { font-size: 0.9rem !important; }
    .diag-option .opt-text span { font-size: 0.78rem !important; }

    .diag-actions {
        flex-direction: column-reverse !important;
        gap: 0.5rem;
    }
    .diag-actions .btn-primary,
    .diag-actions .btn-outline {
        width: 100%;
        justify-content: center;
        margin-left: 0 !important;
    }

    .diag-channel {
        padding: 1rem !important;
        gap: 0.75rem !important;
    }
    .diag-channel .ch-icon { width: 42px !important; height: 42px !important; }
    .diag-channel strong { font-size: 0.95rem !important; }
}

/* ============================================================
   LOGOS STRIP — animação mais rápida em telas pequenas
   ============================================================ */
@media (max-width: 768px) {
    .logos-marquee { animation-duration: 22s !important; gap: 1rem !important; }
    .logo-chip { padding: 0.55rem 1rem !important; font-size: 0.82rem !important; }
}

/* ============================================================
   FOOTER — empilhamento mobile
   ============================================================ */
@media (max-width: 768px) {
    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
        padding-bottom: 2rem !important;
    }
    .footer-brand { max-width: 100% !important; }
    .footer-bottom { margin-top: 1rem !important; }
}

/* ============================================================
   PÁGINAS ANTIGAS (Sobre/Servicos/Portfolio/Contact/Chat)
   Normalizar grids internos
   ============================================================ */
@media (max-width: 768px) {
    /* Reset de grids de página antiga que possam estar rígidos */
    [class*="-grid"]:not(.hero-stats):not(.footer-grid):not(.compare-row):not(.hero-layout):not(.diag-progress):not(.panel-bar-row) {
        grid-template-columns: 1fr !important;
    }
    /* Padding em containers de card genéricos das páginas antigas */
    .service-detail,
    .differential-item,
    .portfolio-item,
    .contact-card,
    .contact-form-wrapper {
        padding: 1.5rem 1.25rem !important;
    }
    /* Botões largura completa em páginas antigas */
    .btn-lg,
    .btn-primary,
    .btn-whatsapp,
    .btn-outline {
        padding: 0.85rem 1.5rem;
    }

    /* Formulário de contato em 1 coluna */
    .contact-form-grid,
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
}

/* ============================================================
   ACESSIBILIDADE — reduzir motion se usuário preferir
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .logos-marquee,
    .hero-floating-card,
    .badge-dot {
        animation: none !important;
    }
}

/* ============================================================
   TOUCH — aumentar áreas clicáveis
   ============================================================ */
@media (hover: none) and (pointer: coarse) {
    a, button, .nav-item, .btn-primary, .btn-outline, .btn-whatsapp,
    .vertical-card, .model-card, .service-card, .step-card,
    .diag-option, .diag-channel, .faq-item {
        min-height: 44px;
    }
    /* Desabilitar transforms on hover em touch */
    *:hover { transform: none !important; }
    .card:hover, .vertical-card:hover, .model-card:hover, .service-card:hover {
        transform: none !important;
    }
}


/* ============================================================
   CHAT — refactor mobile (tela cheia em ≤768px)
   ============================================================ */
@media (max-width: 1024px) {
    .chat-layout {
        grid-template-columns: 1fr !important;
    }
    .chat-sidebar {
        order: 2;
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.75rem !important;
    }
}

@media (max-width: 768px) {
    .chat-page {
        padding: 1rem 0 0 !important;
        min-height: calc(100dvh - 60px);
    }
    .chat-page-header {
        text-align: left !important;
        margin-bottom: 1rem !important;
        max-width: 100% !important;
    }
    .chat-eyebrow { display: none !important; }
    .chat-headline {
        font-size: 1.4rem !important;
        margin-bottom: 0.4rem !important;
    }
    .chat-subhead { display: none !important; }

    .chat-sidebar { display: none !important; }

    .chat-shell {
        display: flex;
        flex-direction: column;
        min-height: calc(100dvh - 120px);
        max-height: calc(100dvh - 120px);
        border-radius: 14px !important;
        overflow: hidden;
    }

    .chat-toolbar {
        padding: 0.75rem 1rem !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 0.6rem !important;
    }
    .chat-toolbar-badges { display: none !important; }
    .chat-toolbar-main { gap: 0.6rem !important; }
    .chat-toolbar-title { font-size: 0.95rem !important; }
    .chat-toolbar-status {
        font-size: 0.72rem !important;
        display: flex;
        align-items: center;
        gap: 0.35rem;
    }

    .avatar-circle { width: 38px !important; height: 38px !important; }
    .avatar-icon { font-size: 0.85rem !important; }

    .messages-area {
        flex: 1;
        min-height: 0 !important;
        max-height: none !important;
        padding: 0.85rem !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .message { gap: 0.55rem !important; }
    .message-avatar {
        width: 32px !important;
        height: 32px !important;
        font-size: 0.72rem !important;
    }
    .message-content { max-width: calc(100% - 44px) !important; }
    .message-bubble { padding: 0.75rem 0.9rem !important; font-size: 0.92rem; }
    .message-time { font-size: 0.7rem !important; }

    .quick-actions {
        padding: 0.75rem !important;
        background: rgba(11, 44, 69, 0.4);
        border-radius: 10px;
        margin-bottom: 0.75rem;
    }
    .quick-buttons {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.4rem !important;
    }
    .quick-btn {
        padding: 0.6rem 0.5rem !important;
        font-size: 0.78rem !important;
        min-height: 44px;
    }

    .input-area {
        padding: 0.65rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom)) !important;
        position: sticky;
        bottom: 0;
        background: rgba(6, 24, 39, 0.92);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid var(--border-subtle);
        z-index: 2;
    }
    .input-meta {
        flex-direction: row !important;
        justify-content: space-between;
        align-items: center !important;
        margin-bottom: 0.45rem !important;
    }
    .input-hint { font-size: 0.7rem !important; }
    .input-counter { font-size: 0.72rem !important; }

    .input-container {
        gap: 0.5rem !important;
    }
    .chat-input {
        min-height: 48px !important;
        font-size: 16px !important;  /* evita zoom do iOS */
        padding: 0.75rem 1rem !important;
        border-radius: 12px !important;
    }
    .send-btn {
        width: 48px !important;
        height: 48px !important;
        flex-shrink: 0;
        border-radius: 12px !important;
    }
}

@media (max-width: 480px) {
    .chat-page-header { margin-bottom: 0.6rem !important; }
    .chat-headline { font-size: 1.2rem !important; }
    .message-content { max-width: calc(100% - 38px) !important; }
    .quick-buttons { grid-template-columns: 1fr !important; }
}

@media (max-width: 380px) {
    .chat-headline { font-size: 1.1rem !important; }
    .avatar-circle { width: 34px !important; height: 34px !important; }
    .chat-toolbar { padding: 0.65rem 0.8rem !important; }
    .message-avatar { width: 28px !important; height: 28px !important; }
}
