@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@700;900&family=Inter:wght@400;600;800&display=swap');

/* ==========================================
   VARIÁVEIS DE CORES
   ========================================== */
:root {
    --bg: #f0f4f8;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --primary: #0ea5e9;
    --card-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    --icon-bg: #f1f5f9;
}

body.dark {
    --bg: #020617;
    --card-bg: #0f172a;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --primary: #38bdf8;
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    --icon-bg: #1e293b;
}

/* ==========================================
   RESET E ESTILOS GLOBAIS
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    /* ✅ Previne scroll horizontal */
}

body {
    background-color: var(--bg);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    transition: background 0.3s ease, color 0.3s ease;
    padding: 40px clamp(15px, 5vw, 30px);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    overflow-x: hidden;
    /* ✅ Previne scroll horizontal */
    width: 100%;
    /* ✅ Garante largura total */
}

.main-wrapper {
    width: 100%;
    max-width: 500px;
    overflow-x: hidden;
    /* ✅ Previne overflow dentro do wrapper */
}

/* ==========================================
   HEADER DO CATÁLOGO
   ========================================== */
.cat-header {
    display: grid;
    grid-template-columns: 45px 1fr 45px;
    align-items: center;
    margin-bottom: 30px;
    gap: 10px;
}

.back-btn,
.theme-toggle {
    background: var(--card-bg);
    color: var(--primary);
    border: none;
    outline: none;
    width: clamp(40px, 10vw, 45px);
    height: clamp(40px, 10vw, 45px);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--card-shadow);
    text-decoration: none;
    font-size: clamp(16px, 4vw, 18px);
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.back-btn:hover,
.theme-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(14, 165, 233, 0.2);
}

.back-btn:active,
.theme-toggle:active {
    transform: scale(0.95);
}

.cat-header h1 {
    font-family: 'Montserrat', sans-serif;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: center;
    line-height: 1;
}

.cat-header h1 .label {
    font-size: clamp(0.6rem, 3vw, 0.7rem);
    font-weight: 600;
    letter-spacing: 3px;
    color: var(--text-muted);
    opacity: 0.7;
    text-transform: uppercase;
}

.cat-header h1 .sky {
    font-size: clamp(1.3rem, 6vw, 1.6rem);
    font-weight: 900;
    color: var(--primary);
    letter-spacing: 4px;
    text-transform: uppercase;
}

/* ==========================================
   DROPDOWN DE CATEGORIAS
   ========================================== */
.category-dropdown-wrapper {
    position: relative;
    margin-bottom: 25px;
    width: 100%;
}

.category-dropdown-btn {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid rgba(0, 0, 0, 0.08);
    /* ✅ Borda sutil */
    color: var(--text-main);
    padding: 14px 16px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    box-shadow: var(--card-shadow);
}

body.dark .category-dropdown-btn {
    border: 1px solid rgba(255, 255, 255, 0.1);
    /* ✅ Borda sutil no dark mode */
}

.category-dropdown-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(14, 165, 233, 0.15);
    border-color: var(--primary);
    /* ✅ Borda azul só no hover */
}

.category-dropdown-btn:active {
    transform: translateY(0);
}

.category-dropdown-btn i:first-child {
    color: var(--primary);
    font-size: 1rem;
}

.category-dropdown-btn span {
    flex: 1;
    text-align: left;
}

.category-dropdown-btn .arrow {
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.category-dropdown-btn.active {
    border-color: var(--primary);
    /* ✅ Borda azul quando aberto */
}

.category-dropdown-btn.active .arrow {
    transform: rotate(180deg);
}

/* Menu Dropdown */
.category-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 100;
    border: 1px solid rgba(0, 0, 0, 0.08);
    /* ✅ Borda sutil */
}

body.dark .category-dropdown-menu {
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.category-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 14px 16px;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

body.dark .dropdown-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item i {
    color: var(--primary);
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.dropdown-item:hover {
    background: rgba(14, 165, 233, 0.08);
    /* ✅ Fundo azul claro no hover */
    color: var(--primary);
}

.dropdown-item:hover i {
    color: var(--primary);
}

.dropdown-item.active {
    background: var(--primary);
    color: white;
}

.dropdown-item.active i {
    color: white;
}

/* Overlay para fechar dropdown ao clicar fora */
.dropdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99;
    display: none;
}

.dropdown-overlay.show {
    display: block;
}

/* ==========================================
   GRADE DE PRODUTOS
   ========================================== */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    width: 100%;
    max-width: 100%;
    /* ✅ Garante que não ultrapasse */
}

/* ==========================================
   CARD DO PRODUTO
   ========================================== */
.product-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.product-img {
    background: var(--icon-bg);
    border-radius: 15px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 35px;
    color: var(--primary);
    margin-bottom: 12px;
    transition: transform 0.2s ease;
}

.product-card:hover .product-img {
    transform: scale(1.05);
}

.category-tag {
    font-size: 9px;
    text-transform: uppercase;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 5px;
    letter-spacing: 0.5px;
}

.product-info h3 {
    font-size: 0.9rem;
    margin: 0 0 8px 0;
    line-height: 1.3;
    font-weight: 700;
}

.price {
    font-weight: 800;
    font-size: 1.1rem;
    margin-top: auto;
    margin-bottom: 15px;
    color: var(--primary);
}

/* ==========================================
   BOTÃO PEDIR NO ZAP
   ========================================== */
.buy-btn {
    display: block;
    width: 100%;
    background: #22c55e;
    color: white;
    text-align: center;
    padding: 12px 5px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(34, 197, 94, 0.2);
}

.buy-btn:hover {
    background: #16a34a;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(34, 197, 94, 0.3);
}

.buy-btn:active {
    transform: translateY(0);
}

/* ==========================================
   RESPONSIVIDADE - TABLETS
   ========================================== */
@media (max-width: 500px) {
    /* Categorias agora são dropdown, sem ajustes necessários */
}

/* ==========================================
   RESPONSIVIDADE - MOBILE
   ========================================== */
@media (max-width: 380px) {
    body {
        padding: 30px 12px;
        /* ✅ Reduzido de 15px para 12px */
    }

    .cat-header {
        margin-bottom: 25px;
    }

    .category-dropdown-wrapper {
        margin-bottom: 20px;
    }

    .category-dropdown-btn {
        padding: 12px 14px;
        font-size: 0.85rem;
    }

    .dropdown-item {
        padding: 12px 14px;
        font-size: 0.8rem;
    }

    /* Cards mantém 2 colunas até telas muito pequenas */
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        /* ✅ Reduzido de 12px para 10px */
    }

    .product-card {
        padding: 12px;
        /* ✅ Reduzido de 15px para 12px */
    }

    .product-img {
        height: 110px;
    }

    .product-info h3 {
        font-size: 0.85rem;
    }

    .price {
        font-size: 1rem;
        margin-bottom: 12px;
    }

    .buy-btn {
        font-size: 0.8rem;
        padding: 10px 5px;
    }
}

/* ==========================================
   RESPONSIVIDADE - TELAS MUITO PEQUENAS
   ========================================== */
@media (max-width: 320px) {
    .cat-header {
        grid-template-columns: 40px 1fr 40px;
    }

    .cat-header h1 {
        font-size: 0.8rem;
        letter-spacing: 2px;
    }

    .category-dropdown-btn {
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    .dropdown-item {
        padding: 10px 12px;
        font-size: 0.75rem;
    }

    /* Somente aqui vai para 1 coluna */
    .product-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .product-img {
        height: 140px;
    }

    .product-info h3 {
        font-size: 0.95rem;
    }

    .price {
        font-size: 1.1rem;
    }
}