/* ========================================
   GRUPO METAL - Responsive CSS
   Material Design Inspired
   ======================================== */

/* ==================== Large Desktop (min-width: 1400px) ==================== */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}

/* ==================== Tablet Landscape (max-width: 1199px) ==================== */
@media (max-width: 1199px) {
    .container {
        max-width: 960px;
    }

    .section-title h2 {
        font-size: 32px;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 25px;
    }
}

/* ==================== Tablet (max-width: 991px) ==================== */
@media (max-width: 991px) {
    .container {
        max-width: 720px;
        padding-left: 15px;
        padding-right: 15px;
    }

    /* Garantir que o header não ultrapasse os limites da tela */
    header .container > div {
        max-width: 100%;
        overflow: visible;
    }

    /* Logo responsivo para tablets */
    .logo {
        flex: 1;
        max-width: 70%;
        flex-shrink: 1;
    }

    .logo img,
    .logo-img {
        max-height: 55px !important;
        max-width: 100% !important;
        width: auto !important;
        height: auto !important;
    }

    /* Esconder barra superior no tablet */
    #topBar {
        display: none !important;
    }

    /* Garantir que o botão do menu seja sempre visível em tablets */
    button[aria-label="Toggle menu"] {
        background-color: rgba(153, 18, 0, 0.08);
        border-radius: 6px;
        padding: 8px !important;
        border: none;
        min-width: 44px;
        min-height: 44px;
        width: 44px;
        height: 44px;
        margin-left: auto;
        flex-shrink: 0;
    }

    button[aria-label="Toggle menu"] span {
        background-color: #991200 !important;
        height: 2.5px !important;
        width: 24px !important;
    }

    /* Header Adjustments */
    .header-content {
        flex-wrap: wrap;
        position: relative;
    }

    .mobile-menu-toggle {
        display: flex;
        order: 2;
    }

    /* Mobile Navigation */
    .main-nav {
        order: 3;
        width: 100%;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--white);
        margin-top: 0;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        z-index: 1000;
    }

    .nav-menu {
        flex-direction: column;
        padding: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .nav-menu.active {
        max-height: 600px;
        padding: 10px 0;
    }

    .nav-menu > li {
        border-bottom: 1px solid var(--border-color);
    }

    .nav-menu > li:last-child {
        border-bottom: none;
    }

    .main-nav a {
        padding: 15px 20px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        transition: var(--transition);
    }

    .main-nav a:hover {
        background: var(--bg-light);
        padding-left: 30px;
    }

    /* Submenu Mobile */
    .has-submenu > a i {
        margin-left: auto;
        transform: rotate(0deg);
    }

    .has-submenu.active > a i {
        transform: rotate(180deg);
    }

    .submenu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        background: rgba(153, 18, 0, 0.05);
        margin: 0;
        border-radius: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .has-submenu.active .submenu {
        max-height: 400px;
        padding: 5px 0;
    }

    .submenu li {
        border-bottom: 1px solid rgba(153, 18, 0, 0.1);
    }

    .submenu li:last-child {
        border-bottom: none;
    }

    .submenu a {
        padding: 12px 20px 12px 40px;
        font-size: 14px;
    }

    .submenu a:hover {
        background: rgba(153, 18, 0, 0.1);
        padding-left: 45px;
    }

    /* Carousel */
    .hero-section {
        height: 400px;
    }

    .carousel-caption {
        padding: 20px 30px;
        bottom: 40px;
        max-width: 90%;
    }

    .carousel-caption h2 {
        font-size: 28px;
    }

    .carousel-caption p {
        font-size: 16px;
    }

    /* Sections */
    .section {
        padding: 50px 0;
    }

    .section-title h2 {
        font-size: 28px;
    }

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

    .footer-links {
        justify-content: center;
    }
}

/* ==================== Mobile Landscape / Small Tablet (max-width: 767px) ==================== */
@media (max-width: 767px) {
    .container {
        max-width: 540px;
        padding: 0 15px;
        width: 100%;
        box-sizing: border-box;
    }

    /* Logo à esquerda, botão à direita */
    .logo {
        margin-right: auto;
        max-width: 75%;
        flex-shrink: 1;
    }

    .logo img,
    .logo-img {
        max-width: 100% !important;
        max-height: 55px !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
    }

    /* Ajustar padding do header principal no mobile */
    header > div:last-child {
        padding-top: 15px;
        padding-bottom: 15px;
    }

    /* Botão do menu menor e à direita */
    button[aria-label="Toggle menu"] {
        order: 2;
        background-color: rgba(153, 18, 0, 0.1) !important;
        border-radius: 6px !important;
        padding: 8px !important;
        border: none;
        min-width: 42px !important;
        min-height: 42px !important;
        width: 42px !important;
        height: 42px !important;
        max-width: 42px !important;
        max-height: 42px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-shadow: 0 2px 4px rgba(153, 18, 0, 0.15) !important;
        flex-shrink: 0 !important;
        margin-left: auto !important;
        margin-right: 0 !important;
    }

    button[aria-label="Toggle menu"] span {
        background-color: #991200 !important;
        height: 2.5px !important;
        width: 22px !important;
    }

    /* Header - Esconder barra superior no mobile */
    #topBar {
        display: none !important;
    }

    .header-top-content {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .header-contact {
        display: flex;
        flex-direction: column;
        gap: 5px;
        font-size: 12px;
    }

    .header-contact span {
        margin-right: 0;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
    }

    .language-switcher {
        gap: 8px;
    }

    .btn-login {
        padding: 6px 15px;
        font-size: 12px;
    }

    .header-main {
        padding: 12px 0;
    }

    .logo img {
        max-height: 50px;
    }

    /* Mobile Nav Improvements */
    .nav-menu.active {
        max-height: 500px;
        animation: slideDown 0.4s ease-out;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Carousel */
    .hero-section {
        height: 350px;
    }

    .carousel-caption {
        padding: 15px 20px;
        bottom: 30px;
        max-width: 95%;
    }

    .carousel-caption h2 {
        font-size: 22px;
        margin-bottom: 8px;
    }

    .carousel-caption p {
        font-size: 14px;
    }

    .carousel-prev,
    .carousel-next {
        padding: 10px 15px;
        font-size: 18px;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .carousel-prev {
        left: 10px;
    }

    .carousel-next {
        right: 10px;
    }

    .carousel-controls {
        bottom: 15px;
        gap: 8px;
    }

    .carousel-dot {
        width: 10px;
        height: 10px;
    }

    /* Sections */
    .section {
        padding: 40px 0;
    }

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

    .section-title h2 {
        font-size: 26px;
    }

    .section-title p {
        font-size: 16px;
    }

    /* Cards */
    .cards-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .card-image {
        height: 180px;
    }

    /* Buttons */
    .btn {
        padding: 10px 20px;
        font-size: 15px;
    }

    /* Footer */
    .footer-top {
        padding: 40px 0;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .footer-column h3 {
        font-size: 18px;
        margin-bottom: 15px;
    }

    .footer-links {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }

    .social-links {
        justify-content: center;
    }

    /* Scroll to Top */
    .scroll-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
    }
}

/* ==================== Mobile Portrait (max-width: 575px) ==================== */
@media (max-width: 575px) {
    .container {
        padding: 0 12px;
    }

    /* Typography */
    body {
        font-size: 15px;
    }

    h1 {
        font-size: 28px;
    }

    h2 {
        font-size: 24px;
    }

    h3 {
        font-size: 20px;
    }

    /* Header - Esconder barra superior */
    #topBar {
        display: none !important;
    }

    .header-main {
        padding: 10px 0;
    }

    /* Logo à esquerda */
    .logo {
        
        margin-right: auto;
        max-width: 70%;
        flex-shrink: 1;
    }

    .logo img,
    .logo-img {
        max-height: 45px !important;
        max-width: 100% !important;
        height: auto !important;
        width: auto !important;
        object-fit: contain !important;
    }

    /* Aumentar padding do header */
    header > div:last-child {
        padding-top: 12px;
        padding-bottom: 12px;
    }

    /* Botão do menu menor */
    button[aria-label="Toggle menu"] {
        order: 2;
        background-color: rgba(153, 18, 0, 0.12) !important;
        border-radius: 6px !important;
        padding: 7px !important;
        border: none;
        min-width: 40px !important;
        min-height: 40px !important;
        width: 40px !important;
        height: 40px !important;
        max-width: 40px !important;
        max-height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-shadow: 0 2px 5px rgba(153, 18, 0, 0.18) !important;
        transition: all 0.3s ease !important;
        flex-shrink: 0 !important;
        margin-left: auto !important;
        margin-right: 0 !important;
    }

    button[aria-label="Toggle menu"]:active {
        background-color: rgba(153, 18, 0, 0.2) !important;
        transform: scale(0.95);
    }

    button[aria-label="Toggle menu"] span {
        background-color: #991200 !important;
        height: 2.5px !important;
        width: 20px !important;
    }

    /* Carousel */
    .hero-section {
        height: 280px;
    }

    .carousel-caption {
        padding: 12px 15px;
        bottom: 20px;
        border-radius: 6px;
    }

    .carousel-caption h2 {
        font-size: 18px;
        margin-bottom: 5px;
    }

    .carousel-caption p {
        font-size: 13px;
        line-height: 1.4;
    }

    .carousel-prev,
    .carousel-next {
        padding: 8px 12px;
        font-size: 16px;
        width: 36px;
        height: 36px;
    }

    .carousel-controls {
        bottom: 10px;
        gap: 6px;
    }

    .carousel-dot {
        width: 8px;
        height: 8px;
    }

    /* Sections */
    .section {
        padding: 35px 0;
    }

    .section-title {
        margin-bottom: 25px;
    }

    .section-title h2 {
        font-size: 22px;
    }

    .section-title p {
        font-size: 15px;
    }

    /* Cards */
    .cards-grid {
        gap: 15px;
    }

    .card {
        border-radius: 6px;
    }

    .card-image {
        height: 160px;
    }

    .card-content {
        padding: 15px;
    }

    .card-content h3 {
        font-size: 18px;
        margin-bottom: 8px;
    }

    .card-content p {
        font-size: 14px;
    }

    /* Buttons */
    .btn {
        padding: 10px 18px;
        font-size: 14px;
        width: 100%;
        text-align: center;
    }

    /* Forms */
    .form-control {
        padding: 10px 12px;
        font-size: 15px;
    }

    /* Footer */
    .footer-top {
        padding: 35px 0;
    }

    .footer-column {
        text-align: center;
    }

    .footer-column h3 {
        font-size: 17px;
    }

    .footer-column p,
    .footer-column li {
        font-size: 14px;
    }

    .contact-info li {
        justify-content: center;
        text-align: center;
    }

    .social-links a {
        width: 38px;
        height: 38px;
    }

    /* Scroll to Top */
    .scroll-to-top {
        bottom: 15px;
        right: 15px;
        width: 42px;
        height: 42px;
        font-size: 18px;
    }
}

/* ==================== Extra Small Mobile (max-width: 375px) ==================== */
@media (max-width: 375px) {
    .container {
        padding: 0 10px;
    }

    body {
        font-size: 14px;
    }

    /* Logo para telas muito pequenas */
    .logo {
        
        margin-right: auto;
        max-width: 65%;
        flex-shrink: 1;
    }

    .logo img,
    .logo-img {
        max-height: 38px !important;
        max-width: 100% !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
    }

    /* Botão do menu compacto */
    button[aria-label="Toggle menu"] {
        order: 2;
        min-width: 38px !important;
        min-height: 38px !important;
        width: 38px !important;
        height: 38px !important;
        max-width: 38px !important;
        max-height: 38px !important;
        padding: 6px !important;
        background-color: rgba(153, 18, 0, 0.12) !important;
        border: none;
    }

    button[aria-label="Toggle menu"] span {
        width: 18px !important;
        height: 2px !important;
    }

    .hero-section {
        height: 240px;
    }

    .carousel-caption {
        padding: 10px 12px;
        bottom: 15px;
    }

    .carousel-caption h2 {
        font-size: 16px;
        margin-bottom: 3px;
    }

    .carousel-caption p {
        font-size: 12px;
    }

    .section {
        padding: 30px 0;
    }

    .section-title h2 {
        font-size: 20px;
    }

    .section-title p {
        font-size: 14px;
    }

    .card-content h3 {
        font-size: 16px;
    }

    .btn {
        padding: 9px 16px;
        font-size: 13px;
    }
}

/* ==================== Landscape Orientation ==================== */
@media (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        height: 350px;
    }

    .carousel-caption {
        bottom: 20px;
        padding: 10px 20px;
    }

    .carousel-caption h2 {
        font-size: 20px;
        margin-bottom: 5px;
    }

    .carousel-caption p {
        font-size: 13px;
    }

    .header-top {
        display: none;
    }

    .section {
        padding: 35px 0;
    }
}

/* ==================== Touch Device Improvements ==================== */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch target sizes */
    .main-nav a {
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    .btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-menu-toggle {
        min-width: 44px;
        min-height: 44px;
    }

    /* Remove hover effects on touch devices */
    .card:hover {
        transform: none;
    }

    .card:active {
        transform: translateY(-5px);
    }

    /* Improve scroll behavior */
    * {
        -webkit-tap-highlight-color: rgba(153, 18, 0, 0.1);
    }
}

/* ==================== Print Styles ==================== */
@media print {
    .header-top,
    .mobile-menu-toggle,
    .carousel-controls,
    .carousel-prev,
    .carousel-next,
    .scroll-to-top,
    .main-footer {
        display: none !important;
    }

    .main-header {
        position: static;
        box-shadow: none;
    }

    body {
        font-size: 12pt;
    }

    a {
        text-decoration: underline;
    }
}

/* ==================== Reduced Motion ==================== */
@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;
    }

    .carousel-item {
        transition: none;
    }
}
