/* ============================================================
 * HQS MOBILE V6 - iPhone Fixed + Scroll Infinito + Botão Topo
 * ============================================================ */

@media (max-width: 768px) {

    /* =====================
      DROPDOWN FULLSCREEN
      ===================== */
    #hqs-dropdown {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        background: #f8f9fa !important;
        z-index: 999999 !important;
        box-shadow: none !important;
        display: none;
        opacity: 0;
        transform: translateY(20px);
        transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        margin: 0 !important;
        padding: 0 !important;
    }

    #hqs-dropdown.hqs-open {
        display: flex !important;
        flex-direction: column !important;
        opacity: 1 !important;
        transform: translateY(0) !important;
    }

    /* =====================
      CONTAINER
      ===================== */
    #hqs-dropdown .hqs-container {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
        width: 100% !important;
        grid-template-columns: none !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* =====================
      HEADER MOBILE (iPhone Safe Areas)
      ===================== */
    #hqs-dropdown .hqs-mobile-header {
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: #fff;
        /* iPhone: Top + Right + Left */
        padding-top: calc(12px + env(safe-area-inset-top, 20px));
        padding-right: calc(14px + env(safe-area-inset-right, 0px));
        padding-bottom: 12px;
        padding-left: calc(14px + env(safe-area-inset-left, 0px));
        border-bottom: 1px solid #e5e5e5;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
        position: relative;
        z-index: 10;
        min-height: 60px;
        width: 100%;
    }

    #hqs-dropdown .hqs-mob-title {
        font-weight: 800;
        font-size: 14px;
        color: #1a1a1a;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        line-height: 1.2;
        flex: 1;
    }

    #hqs-dropdown .hqs-mob-close {
        background: rgba(0, 0, 0, 0.04);
        border: none;
        font-size: 28px;
        line-height: 1;
        color: #333;
        width: 44px;
        height: 44px;
        min-width: 44px;
        padding: 0;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 12px;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        flex-shrink: 0;
    }

    #hqs-dropdown .hqs-mob-close:active {
        background: rgba(0, 0, 0, 0.1);
        transform: scale(0.95);
    }

    /* =====================
      ZONA PRODUTOS (SCROLL INFINITO)
      ===================== */
    #hqs-dropdown .hqs-right {
        order: 2;
        flex: 1 1 auto;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        /* iPhone: Right + Bottom + Left */
        padding-top: 14px;
        padding-right: calc(12px + env(safe-area-inset-right, 0px));
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 20px)); /* EXTRA padding para não cortar */
        padding-left: calc(12px + env(safe-area-inset-left, 0px));
        background: #f8f9fa;
        scroll-behavior: smooth;
        position: relative;
        width: 100%;
        min-height: 0;
    }

    #hqs-dropdown .hqs-products-header {
        display: none !important;
    }

    /* Grid que não corta */
    #hqs-dropdown .hqs-products-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        min-height: 100px;
    }

    @media (max-width: 360px) {
        #hqs-dropdown .hqs-products-grid {
            grid-template-columns: 1fr !important;
        }
    }

    /* =====================
      BOTÃO VOLTAR AO TOPO
      ===================== */
    #hqs-scroll-to-top {
        position: fixed !important;
        bottom: calc(100px + env(safe-area-inset-bottom, 20px));
        right: calc(20px + env(safe-area-inset-right, 0px));
        width: 48px;
        height: 48px;
        background: #00526d;
        color: #fff;
        border: none;
        border-radius: 50%;
        box-shadow: 0 4px 12px rgba(0, 82, 109, 0.4);
        cursor: pointer;
        z-index: 100001;
        display: none;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        line-height: 1;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    #hqs-scroll-to-top.visible {
        display: flex !important;
    }

    #hqs-scroll-to-top:active {
        transform: scale(0.9);
        background: #004158;
    }

    /* =====================
      LOADING INDICATOR (Scroll Infinito)
      ===================== */
    #hqs-dropdown .hqs-scroll-loader {
        grid-column: 1 / -1;
        text-align: center;
        padding: 20px;
        display: none;
    }

    #hqs-dropdown .hqs-scroll-loader.loading {
        display: block;
    }

    #hqs-dropdown .hqs-scroll-loader .spinner {
        display: inline-block;
        width: 32px;
        height: 32px;
        border: 3px solid rgba(0, 82, 109, 0.2);
        border-top-color: #00526d;
        border-radius: 50%;
        animation: hqs-spin 0.8s linear infinite;
    }

    @keyframes hqs-spin {
        to { transform: rotate(360deg); }
    }

    /* =====================
      CARD MOBILE
      ===================== */
    #hqs-dropdown .hqs-card {
        border: none !important;
        background: #fff;
        border-radius: 12px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
        display: flex;
        flex-direction: column;
        padding-bottom: 10px;
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        animation: hqs-card-in 0.4s ease backwards;
        width: 100%;
        min-width: 0;
        overflow: hidden;
    }

    @keyframes hqs-card-in {
        from {
            opacity: 0;
            transform: scale(0.95) translateY(10px);
        }
        to {
            opacity: 1;
            transform: scale(1) translateY(0);
        }
    }

    #hqs-dropdown .hqs-card:active {
        transform: scale(0.98);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08) !important;
    }

    #hqs-dropdown .hqs-img {
        height: auto !important;
        aspect-ratio: 1 / 1 !important;
        width: 100% !important;
        background: #fff;
        margin-bottom: 8px;
        border-radius: 12px 12px 0 0;
        overflow: hidden;
    }

    #hqs-dropdown .hqs-img img {
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
        padding: 12px !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    #hqs-dropdown .hqs-card:active .hqs-img img {
        transform: scale(0.95);
    }

    #hqs-dropdown .hqs-info {
        padding: 0 12px !important;
    }

    #hqs-dropdown .hqs-title {
        font-size: 12px !important;
        line-height: 1.35 !important;
        height: auto !important;
        min-height: 2.7em !important;
        margin-bottom: 6px !important;
        font-weight: 600;
        color: #1a1a1a;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }

    #hqs-dropdown .hqs-desc,
    #hqs-dropdown .hqs-meta {
        display: none !important;
    }

    #hqs-dropdown .hqs-price-wrapper {
        margin-top: auto !important;
        padding-top: 4px;
    }

    #hqs-dropdown .hqs-price-wrapper .price-normal,
    #hqs-dropdown .hqs-price-wrapper .price-sale {
        font-size: 14px !important;
        color: #00526d !important;
        font-weight: 800 !important;
        display: inline-block !important;
    }

    #hqs-dropdown .hqs-price-wrapper .price-old {
        font-size: 11px !important;
        color: #999 !important;
        text-decoration: line-through;
        margin-left: 6px;
    }

    /* =====================
      CATEGORIAS (Bottom com Safe Areas)
      ===================== */
    #hqs-dropdown .hqs-left {
        order: 3;
        flex: 0 0 auto;
        background: #fff;
        border-top: 1px solid #e5e5e5;
        /* iPhone: Right + Bottom + Left */
        padding-top: 12px;
        padding-right: calc(12px + env(safe-area-inset-right, 0px));
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 20px));
        padding-left: calc(12px + env(safe-area-inset-left, 0px));
        border-right: none !important;
        z-index: 20;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.05);
        width: 100%;
    }

    #hqs-dropdown .hqs-left .hqs-scroll-area {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        white-space: nowrap;
        gap: 8px;
        padding-bottom: 2px;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }

    #hqs-dropdown .hqs-left .hqs-scroll-area::-webkit-scrollbar {
        display: none;
    }

    #hqs-dropdown .hqs-left h3 {
        display: none !important;
    }

    #hqs-dropdown .hqs-list {
        flex-direction: row !important;
        display: flex !important;
        gap: 8px !important;
        margin: 0 !important;
    }

    #hqs-dropdown .hqs-item {
        background: #f0f4f7;
        color: #00526d;
        border-radius: 24px !important;
        padding: 10px 16px !important;
        font-size: 12px !important;
        font-weight: 600;
        border: 1px solid #d0e0e8 !important;
        flex-shrink: 0;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        white-space: nowrap;
    }

    #hqs-dropdown .hqs-item:active {
        background: #d0e8f2;
        border-color: #00526d !important;
        transform: scale(0.96);
    }

    #hqs-dropdown .hqs-left-footer {
        display: none !important;
    }

    #hqs-dropdown .hqs-viewall {
        margin-top: 12px;
        width: 100%;
        padding: 14px;
        font-size: 13px;
        font-weight: 700;
        border-radius: 10px;
        background: #00526d;
        color: #fff;
        border: none;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    #hqs-dropdown .hqs-viewall:active {
        transform: scale(0.98);
        background: #004158;
    }

    /* =====================
      OTIMIZAÇÕES
      ===================== */
    #hqs-dropdown * {
        -webkit-tap-highlight-color: rgba(0, 82, 109, 0.1);
        -webkit-touch-callout: none;
    }

    #hqs-dropdown .hqs-right {
        overscroll-behavior: contain;
    }

    @media (hover: none) {
        #hqs-dropdown .hqs-card:hover,
        #hqs-dropdown .hqs-item:hover {
            transform: none;
            box-shadow: none;
        }
    }
}

/* =====================
  LANDSCAPE MOBILE
  ===================== */
@media (max-width: 896px) and (orientation: landscape) {
    #hqs-dropdown .hqs-mobile-header {
        padding-top: calc(8px + env(safe-area-inset-top, 10px));
        padding-bottom: 8px;
    }

    #hqs-dropdown .hqs-right {
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 10px));
    }

    #hqs-dropdown .hqs-products-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px !important;
    }

    #hqs-scroll-to-top {
        bottom: calc(80px + env(safe-area-inset-bottom, 10px));
    }
}
