/* ============================================
   Kauthus Motors — Responsive (mobile-first)
   Cobre celulares de 320px até tablets
   ============================================ */

/* --- Base global --- */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

img,
video,
svg {
    max-width: 100%;
    height: auto;
}

.container {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
}

/* Hero: legibilidade no fundo claro */
.hero .hero-title,
.hero .title-highlight,
.hero .title-accent {
    color: var(--text-dark);
    text-shadow: none;
}

.hero .hero-description {
    color: var(--text-medium);
}

.hero .hero-description strong {
    color: var(--text-dark);
}

.hero .btn-secondary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.hero .btn-secondary:hover {
    color: white;
}

/* Compensar header fixo */
.hero {
    padding-top: calc(4.5rem + env(safe-area-inset-top));
    box-sizing: border-box;
}

/* Overlay do menu mobile */
.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.nav-overlay.active {
    display: block;
    opacity: 1;
}

/* --- Tablet e celular (até 1024px) --- */
@media (max-width: 1024px) {
    .header .container {
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
    }

    .navbar {
        flex-wrap: nowrap;
        gap: 0.5rem;
        padding: 0.5rem 0;
        min-height: 56px;
    }

    .logo h1 {
        font-size: 1.15rem;
    }

    .logo-icon {
        width: 36px;
        height: 36px;
    }

    .nav-actions .btn-visita {
        min-width: auto;
        padding: 0.55rem 0.85rem;
        font-size: 0.8rem;
    }

    .nav-menu {
        display: flex !important;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: 0;
        width: min(300px, 88vw);
        height: 100%;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        padding: calc(4.5rem + env(safe-area-inset-top)) 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
        gap: 0;
        background: var(--background-white);
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.15);
        z-index: 1001;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateX(100%);
        visibility: hidden;
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2,  1), visibility 0.35s;
        list-style: none;
    }

    [data-theme="dark"] .nav-menu {
        background: var(--background-primary);
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.45);
    }

    .nav-menu.active {
        transform: translateX(0);
        visibility: visible;
    }

    .nav-menu li {
        width: 100%;
        border-bottom: 1px solid var(--border-light);
    }

    .nav-menu li:last-child {
        border-bottom: none;
    }

    .nav-link {
        display: block;
        padding: 1rem 0.25rem;
        font-size: 1.05rem;
    }

    .nav-link::after {
        display: none;
    }

    .mobile-menu-toggle {
        display: flex;
        z-index: 1002;
        flex-shrink: 0;
    }

    .mobile-menu-toggle.active span:nth-child(1) {
        transform: translateY(6px) rotate(45deg);
    }

    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-toggle.active span:nth-child(3) {
        transform: translateY(-6px) rotate(-45deg);
    }

    body.menu-open {
        overflow: hidden;
        touch-action: none;
    }

    /* Hero */
    .hero {
        min-height: auto;
        padding: calc(4.5rem + env(safe-area-inset-top)) 0 3rem;
        box-sizing: border-box;
    }

    .hero-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 0;
        text-align: center;
    }

    .hero-text {
        max-width: 100%;
    }

    .hero-title {
        font-size: clamp(1.65rem, 6vw, 2.5rem) !important;
        text-align: center;
        line-height: 1.15;
    }

    .hero-description {
        font-size: clamp(0.95rem, 3.5vw, 1.125rem);
        text-align: center;
    }

    .hero-actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .hero-actions .btn-primary,
    .hero-actions .btn-secondary,
    .hero-actions .btn-enhanced {
        width: 100%;
        max-width: none;
        justify-content: center;
    }

    .hero-visual {
        order: -1;
        width: 100%;
    }

    .main-car {
        max-height: min(220px, 40vh);
        width: 100%;
        object-fit: contain;
    }

    /* Filtros */
    .filter-section {
        margin-top: -2rem;
        padding-bottom: 2rem;
    }

    .filter-card {
        padding: 1.25rem;
        margin: 0;
    }

    .filter-header h3 {
        font-size: 1.2rem;
    }

    .filter-grid {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        flex-direction: column;
    }

    .filter-actions .btn-search,
    .filter-actions .btn-clear {
        width: 100%;
        max-width: none;
    }

    /* Ofertas */
    .offers-grid {
        grid-template-columns: 1fr;
    }

    .offer-card.featured {
        transform: none;
    }

    .offer-card.featured:hover {
        transform: translateY(-6px);
    }

    .offer-new-price {
        font-size: 1.65rem;
    }

    /* Serviços */
    .services-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .service-card {
        padding: 1.5rem;
    }

    /* Marcas */
    .brands-carousel {
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 0.5rem;
        margin-left: -0.25rem;
        margin-right: -0.25rem;
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }

    .brands-carousel::-webkit-scrollbar {
        display: none;
    }

    .brand-logo {
        scroll-snap-align: start;
    }

    /* Catálogo */
    .vehicle-grid {
        grid-template-columns: 1fr;
    }

    .category-tabs {
        flex-wrap: nowrap;
        justify-content: flex-start;
        gap: 0.5rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .category-tabs::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        padding: 0.6rem 1rem;
        font-size: 0.875rem;
        flex-shrink: 0;
    }

    /* Features / Sobre */
    .features-grid {
        grid-template-columns: 1fr;
    }

    .about-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .about-stats {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Depoimentos */
    .testimonials-grid {
        grid-template-columns: 1fr;
    }

    .testimonial-card.featured {
        transform: none;
    }

    /* Calculadora */
    .calculator-wrapper {
        grid-template-columns: 1fr;
    }

    .calculator-result {
        position: static;
    }

    .calculator-content h2 {
        font-size: 1.75rem;
    }

    /* Contato */
    .contact-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .contact-form {
        padding: 1.5rem;
    }

    /* Footer */
    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }

    .social-links {
        justify-content: center;
    }

    /* Modal veículo */
    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        max-height: 100dvh;
        border-radius: 0;
        min-height: 100dvh;
    }

    .modal-header {
        padding: 1rem 1rem 1rem 3.5rem;
        border-radius: 0;
        position: sticky;
        top: 0;
        z-index: 2;
    }

    .modal-header h2 {
        font-size: 1.1rem;
        line-height: 1.3;
    }

    .modal-close {
        position: absolute;
        left: 0.75rem;
        top: 50%;
        transform: translateY(-50%);
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    .modal-body {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 1.25rem;
    }

    .modal-footer {
        flex-direction: column;
        padding: 1rem;
        gap: 0.75rem;
        position: sticky;
        bottom: 0;
        background: var(--background-white);
        border-top: 1px solid var(--border-light);
    }

    [data-theme="dark"] .modal-footer {
        background: var(--background-secondary);
    }

    .modal-btn {
        width: 100%;
    }

    .image-thumbnails {
        display: flex;
        overflow-x: auto;
        gap: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .thumbnail {
        width: 64px;
        height: 48px;
        flex-shrink: 0;
        object-fit: cover;
    }

    .specs-grid,
    .features-list {
        grid-template-columns: 1fr;
    }

    /* Notificações */
    .notification {
        left: 1rem !important;
        right: 1rem !important;
        max-width: none !important;
    }
}

/* --- Celulares médios (até 768px) --- */
@media (max-width: 768px) {
    .section-title {
        font-size: clamp(1.35rem, 5vw, 1.85rem);
    }

    .section-subtitle {
        font-size: 0.95rem;
    }

    .nav-actions .btn-visita span {
        display: none;
    }

    .nav-actions .btn-visita {
        padding: 0.55rem;
        min-width: 44px;
        width: 44px;
        height: 44px;
        border-radius: 0.75rem;
    }

    .nav-actions .btn-visita i {
        margin: 0;
        font-size: 1rem;
    }

    .hero-stats {
        flex-direction: column;
        align-items: center;
    }

    .stat-item {
        width: 100%;
        max-width: 280px;
    }

    .vehicle-card .vehicle-features {
        flex-wrap: wrap;
    }

    .price-value {
        font-size: 1.35rem;
    }

    .faq-question h3 {
        font-size: 1rem;
        padding-right: 0.5rem;
    }

    .faq-item.active .faq-answer {
        max-height: 500px;
    }
}

/* --- Celulares pequenos (até 480px) --- */
@media (max-width: 480px) {
    .logo h1 span {
        display: inline;
    }

    .logo h1 {
        font-size: 1rem;
    }

    .hero {
        padding-top: calc(4rem + env(safe-area-inset-top));
    }

    .hero-title {
        font-size: clamp(1.45rem, 7.5vw, 1.85rem) !important;
    }

    .filter-card {
        padding: 1rem;
        border-radius: 0.75rem;
    }

    .offer-content h3 {
        font-size: 1.2rem;
    }

    .brand-circle {
        width: 52px;
        height: 52px;
    }

    .brand-logo-img {
        width: 36px;
        height: 36px;
    }

    .vehicle-name {
        font-size: 1.1rem;
    }

    .contact-card {
        padding: 1.25rem;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* evita zoom automático no iOS */
    }

    .footer-credits p,
    .footer-bottom p {
        font-size: 0.8rem;
    }

    .modal-header h2 {
        font-size: 1rem;
    }

    .result-value {
        font-size: 1.65rem;
    }
}

/* --- Telas muito estreitas (iPhone SE, etc.) --- */
@media (max-width: 360px) {
    .nav-actions {
        gap: 0.35rem;
    }

    .logo h1 {
        font-size: 0.9rem;
    }

    .hero-actions .btn-primary,
    .hero-actions .btn-secondary {
        padding: 0.85rem 1rem;
        font-size: 0.9rem;
    }
}

/* --- Landscape em celulares --- */
@media (max-width: 896px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding-top: calc(3.5rem + env(safe-area-inset-top));
        padding-bottom: 1.5rem;
    }

    .hero-content {
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
        text-align: left;
    }

    .hero-title {
        font-size: 1.5rem !important;
        text-align: left;
    }

    .hero-description {
        font-size: 0.85rem;
        text-align: left;
    }

    .hero-visual {
        order: 0;
    }

    .main-car {
        max-height: 160px;
    }

    .hero-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .hero-actions .btn-primary,
    .hero-actions .btn-secondary {
        width: auto;
        flex: 1;
        min-width: 140px;
    }
}

/* --- Tablets em retrato (481px–768px): 2 colunas no catálogo --- */
@media (min-width: 481px) and (max-width: 768px) {
    .vehicle-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .services-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* --- Desativar efeitos pesados no touch --- */
@media (hover: none) and (pointer: coarse) {
    .magnetic-btn,
    .vehicle-card:hover,
    .offer-card:hover,
    .service-card:hover {
        transform: none !important;
    }

    .brand-logo:hover {
        transform: none;
    }
}
