/**
 * CORREÇÕES DE RESPONSIVIDADE
 * Cartório Elinalva Henrique - 2º Ofício de Pacatuba/CE
 *
 * Este arquivo corrige componentes específicos que não tinham media queries
 */

/* ========================================
   FOOTER GRID - RESPONSIVO
======================================== */
@media (max-width: 1024px) {
    .footer-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 30px !important;
    }
}

@media (max-width: 768px) {
    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 30px !important;
    }

    .footer-top {
        padding: 40px 0 30px !important;
    }

    .footer-bottom-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .footer-bottom-links {
        flex-direction: column;
        gap: 10px;
    }
}

/* ========================================
   SERVICES GRID - RESPONSIVO
======================================== */
@media (max-width: 1024px) {
    .services-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 25px !important;
    }
}

@media (max-width: 768px) {
    .services-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    .service-card {
        padding: 25px !important;
    }

    .service-icon {
        width: 50px !important;
        height: 50px !important;
        font-size: 1.5rem !important;
    }

    .service-card h3 {
        font-size: 1.3rem !important;
    }
}

/* ========================================
   GALLERY GRID - RESPONSIVO
======================================== */
@media (max-width: 1200px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 15px !important;
    }
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
}

/* ========================================
   HIGHLIGHTS GRID - RESPONSIVO
======================================== */
@media (max-width: 1024px) {
    .highlights-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 25px !important;
    }
}

@media (max-width: 768px) {
    .highlights-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    .highlight-card {
        padding: 30px 25px !important;
    }

    .highlight-icon {
        width: 60px !important;
        height: 60px !important;
        font-size: 2rem !important;
    }

    .highlight-card h3 {
        font-size: 1.5rem !important;
    }
}

/* ========================================
   HEADER E LOGO - AJUSTES MOBILE
======================================== */
@media (max-width: 768px) {
    .logo-img {
        height: 50px !important;
        margin-right: 10px !important;
    }

    .logo-text h1 {
        font-size: 1.1rem !important;
    }

    .logo-text span {
        font-size: 0.8rem !important;
    }

    .main-header {
        padding: 15px 0 !important;
    }
}

@media (max-width: 480px) {
    .logo-img {
        height: 40px !important;
    }

    .logo-text h1 {
        font-size: 0.95rem !important;
    }

    .logo-text span {
        font-size: 0.75rem !important;
        display: none;
    }
}

/* ========================================
   TOP BAR - MELHOR EMPILHAMENTO MOBILE
======================================== */
@media (max-width: 768px) {
    .top-bar {
        padding: 8px 0 !important;
    }

    .top-bar-content {
        gap: 10px;
    }

    .top-bar-left,
    .top-bar-right {
        flex-wrap: wrap;
        gap: 10px;
        font-size: 0.8rem;
    }

    .top-bar span,
    .top-bar a {
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .top-bar-left,
    .top-bar-right {
        width: 100%;
        justify-content: center;
    }

    .top-bar-left span:not(:first-child),
    .top-bar-right a:not(:first-child) {
        display: none;
    }
}

/* ========================================
   SECTION TITLES - RESPONSIVO
======================================== */
@media (max-width: 768px) {
    section {
        padding: 40px 0 !important;
    }

    .section-title h2 {
        font-size: 1.8rem !important;
    }

    .section-title p {
        font-size: 1rem !important;
    }
}

@media (max-width: 480px) {
    section {
        padding: 30px 0 !important;
    }

    .section-title {
        margin-bottom: 30px !important;
    }

    .section-title h2 {
        font-size: 1.5rem !important;
    }
}

/* ========================================
   TABELAS - RESPONSIVAS (SCROLL HORIZONTAL)
======================================== */
@media (max-width: 768px) {
    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table td,
    table th {
        white-space: nowrap;
        min-width: 120px;
    }
}

/* ========================================
   BOTÕES - EMPILHAMENTO MOBILE
======================================== */
@media (max-width: 480px) {
    .btn {
        width: 100%;
        justify-content: center;
        text-align: center;
        padding: 12px 20px !important;
    }

    .header-actions {
        flex-direction: column;
        width: 100%;
        gap: 10px !important;
    }
}

/* ========================================
   CARDS - AJUSTES MOBILE
======================================== */
@media (max-width: 480px) {
    .card {
        margin-bottom: 20px;
    }

    .card-body {
        padding: 15px !important;
    }

    .card-title {
        font-size: 1.1rem !important;
    }

    .card-text {
        font-size: 0.9rem !important;
    }
}

/* ========================================
   FORMS - AJUSTES MOBILE
======================================== */
@media (max-width: 480px) {
    .form-group {
        margin-bottom: 15px !important;
    }

    .form-control {
        padding: 10px 12px !important;
        font-size: 0.95rem !important;
    }

    .form-label {
        font-size: 0.9rem !important;
    }
}

/* ========================================
   BREADCRUMB - RESPONSIVO
======================================== */
@media (max-width: 480px) {
    .breadcrumb {
        font-size: 0.85rem;
        flex-wrap: wrap;
        gap: 5px;
    }

    .breadcrumb-item + .breadcrumb-item::before {
        padding: 0 5px;
    }
}

/* ========================================
   ALERTS - RESPONSIVO
======================================== */
@media (max-width: 480px) {
    .alert {
        padding: 12px 15px !important;
        font-size: 0.9rem !important;
    }
}

/* ========================================
   ORGANOGRAMA - RESPONSIVO
======================================== */
@media (max-width: 768px) {
    .organogram-card {
        padding: 20px 15px !important;
    }

    .organogram-image {
        max-width: 100% !important;
        height: auto !important;
        border-radius: 8px !important;
    }

    .organogram-image-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .organogram-info {
        padding: 15px !important;
        font-size: 0.9rem !important;
        margin-top: 20px !important;
    }

    .modal-content {
        max-width: 98% !important;
        max-height: 80vh !important;
    }

    .empty-state-icon {
        width: 80px !important;
        height: 80px !important;
        font-size: 3rem !important;
    }
}

@media (max-width: 480px) {
    .organogram-card {
        padding: 15px 10px !important;
    }

    .organogram-image {
        border-radius: 6px !important;
    }

    .organogram-info {
        padding: 12px !important;
        font-size: 0.85rem !important;
    }

    .organogram-meta {
        font-size: 0.8rem !important;
    }

    .empty-state-icon {
        width: 60px !important;
        height: 60px !important;
        font-size: 2.5rem !important;
    }
}

/* ========================================
   LIGHTBOX - AJUSTES MOBILE
======================================== */
@media (max-width: 768px) {
    .lightbox-content {
        max-width: 95% !important;
    }

    .lightbox-close {
        top: 10px !important;
        right: 10px !important;
        font-size: 30px !important;
        background: rgba(0, 0, 0, 0.5);
        border-radius: 50%;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ========================================
   CONTAINER - AJUSTE DE PADDING MOBILE
======================================== */
@media (max-width: 768px) {
    .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
}

@media (max-width: 480px) {
    .container {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
}

/* ========================================
   MENU MOBILE - MELHORIAS
======================================== */
@media (max-width: 768px) {
    /* Menu mobile aberto deve aparecer abaixo do nav fixo */
    .nav-menu.active {
        background: var(--color-white);
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        padding: 10px 0;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }

    /* Garante que o menu fixo mobile funcione bem */
    .main-nav {
        position: sticky !important;
        top: 0 !important;
    }

    .nav-menu > li > a {
        padding: 12px 20px !important;
        font-size: 0.9rem !important;
    }

    .submenu {
        background: var(--color-light) !important;
        padding: 10px 0;
    }

    .submenu li a {
        padding: 10px 30px !important;
        font-size: 0.85rem !important;
    }

    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
}

/* ========================================
   IMAGENS - RESPONSIVAS (APENAS MOBILE)
======================================== */
/* Regra global básica mantida para compatibilidade */
img {
    max-width: 100%;
    height: auto;
}

/* Ajustes específicos para galeria em mobile */
@media (max-width: 768px) {
    /* Imagens dentro de cards e containers devem se adaptar em mobile */
    .card img,
    .gallery-item img,
    .organogram-image {
        max-width: 100%;
        height: auto !important;
        object-fit: cover;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .gallery-item > div:first-of-type {
        height: 180px !important;
    }

    .gallery-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    .gallery-item > div:first-of-type {
        height: 220px !important;
    }
}

/* Ajustes específicos para seção de atendimento online */
@media (max-width: 768px) {
    /* Background images em divs devem ajustar */
    div[style*="background-image"] {
        background-size: cover !important;
        background-position: center !important;
    }

    /* Reduz ícones decorativos muito grandes em mobile */
    .grid-2 > div:last-child i.fa-laptop[style*="font-size: 200px"] {
        font-size: 120px !important;
    }
}

@media (max-width: 480px) {
    .grid-2 > div:last-child i.fa-laptop[style*="font-size: 200px"] {
        display: none !important;
    }
}

/* ========================================
   IFRAME - RESPONSIVO (VÍDEOS, MAPAS)
======================================== */
iframe {
    max-width: 100%;
}

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ========================================
   ÍCONES GRANDES - RESPONSIVOS
======================================== */
@media (max-width: 768px) {
    /* Ícones grandes em seções (como o laptop na página inicial) */
    i.fa-laptop,
    i.fa-newspaper,
    section i[style*="font-size: 200px"],
    section i[style*="font-size: 4rem"],
    section i[style*="font-size: 5rem"] {
        font-size: 100px !important;
    }

    /* Ícones em cards de notícias */
    .grid-3 > div i.fa-newspaper {
        font-size: 3rem !important;
    }
}

@media (max-width: 480px) {
    /* Ícones grandes ainda menores em mobile */
    i.fa-laptop,
    i.fa-newspaper,
    section i[style*="font-size: 200px"],
    section i[style*="font-size: 4rem"],
    section i[style*="font-size: 5rem"] {
        font-size: 80px !important;
    }

    /* Ícones em cards de notícias */
    .grid-3 > div i.fa-newspaper {
        font-size: 2.5rem !important;
    }
}

/* ========================================
   CARDS DE NOTÍCIAS - RESPONSIVOS
======================================== */
@media (max-width: 768px) {
    /* Container das imagens placeholder de notícias */
    .grid-3 > div > div[style*="height: 200px"] {
        height: 150px !important;
    }

    .grid-3 > div {
        min-height: auto !important;
    }

    .grid-3 > div h3 {
        min-height: auto !important;
        font-size: 1.1rem !important;
    }

    .grid-3 > div p {
        min-height: auto !important;
        font-size: 0.9rem !important;
    }
}

@media (max-width: 480px) {
    .grid-3 > div > div[style*="height: 200px"] {
        height: 120px !important;
    }
}

/* ========================================
   UTILITY - HIDE/SHOW ELEMENTOS
======================================== */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    .show-mobile {
        display: block !important;
    }
}

@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }

    .show-desktop {
        display: block !important;
    }
}

/* ========================================
   ACESSIBILIDADE - FOCUS VISÍVEL
======================================== */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--color-secondary) !important;
    outline-offset: 2px !important;
}

/* ========================================
   PREVENÇÃO DE OVERFLOW - APENAS MOBILE
======================================== */
@media (max-width: 768px) {
    /* Previne overflow horizontal em mobile */
    body {
        overflow-x: hidden;
    }

    /* Imagens e mídia sempre responsivos em mobile */
    img,
    video,
    svg {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Força object-fit em imagens dentro de containers em mobile */
    .card img,
    .gallery-item img,
    .news-item img,
    .service-card img {
        object-fit: cover;
        width: 100%;
    }

    /* Evita que elementos fixos ultrapassem a tela */
    .container,
    .container-fluid,
    section,
    article,
    main {
        max-width: 100vw !important;
        overflow-x: hidden;
    }

    /* Ajusta padding dos containers em mobile */
    .container {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* Força imagens inline com estilos a serem responsivas */
    img[style*="width"],
    img[style*="height"] {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* ========================================
   PERFORMANCE - SCROLL SMOOTH
======================================== */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* Remove scroll suave se usuário preferir menos movimento */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
