/*
Theme Name: Altokeapp Theme
Description: Tema liviano hecho a medida para Altokeapp — cabecera de app, selector de ciudad y comercios locales, fusionando la lógica probada del plugin altokeapp-home directamente en el tema.
Author: Mauro Zaragoza
Version: 2.2.1
Text Domain: altokeapp-theme
*/

:root {
    --atk-yellow: #FFD400;
    --atk-yellow-dark: #FFB800;
    --atk-text: #1a1a1a;
    --atk-muted: #777;
    --atk-line: #ececec;
    --atk-accent: #3483FA;
    --atk-radius: 16px;
    --atk-shadow: 0 2px 8px rgba(0,0,0,0.08);
    --atk-shadow-hover: 0 6px 16px rgba(0,0,0,0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f4f5f7;
    color: #1a1a1a;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    text-rendering: optimizeLegibility;
}

a { text-decoration: none; color: inherit; }
h1, h2, h3 { font-weight: 800; letter-spacing: -0.005em; line-height: 1.2; }
button { font-family: inherit; }

/* ============================= */
/* CABECERA — sin position:fixed a propósito (scrollea con la página,        */
/* como en el diseño ya probado en producción, para no arriesgar conflicto   */
/* de z-index/stacking-context con el modal de selección de ciudad)          */
/* ============================= */

.atk-app-header {
    background: linear-gradient(115deg, var(--atk-yellow) 0%, var(--atk-yellow-dark) 100%);
    padding: 12px 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    position: relative;
}
.atk-app-header__row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.atk-back-btn {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(0,0,0,0.1);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 900;
    color: #222;
    flex-shrink: 0;
}
.atk-app-header__brand {
    display: flex;
    align-items: center;
    gap: 9px;
}
.atk-app-header__icon { font-size: 24px; }
.atk-app-header__text {
    font-weight: 800;
    font-size: 17px;
    line-height: 1.15;
    color: #1a1a1a;
}
.atk-app-header__text small {
    display: block;
    font-weight: 600;
    font-size: 11px;
    opacity: 0.7;
}

.atk-subpage-title {
    font-weight: 800;
    font-size: 15px;
    color: #1a1a1a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.atk-location-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,0.12);
    border: none;
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 12.5px;
    font-weight: 700;
    color: #1a1a1a;
    cursor: pointer;
}

/* ============================= */
/* TABS */
/* ============================= */

.atk-tabs {
    display: flex;
    gap: 8px;
    padding: 8px 16px 12px;
    background: linear-gradient(115deg, var(--atk-yellow) 0%, var(--atk-yellow-dark) 100%);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.atk-tab {
    flex: 1;
    padding: 9px 4px;
    border-radius: 999px;
    text-align: center;
    font-weight: 700;
    font-size: 13.5px;
    border: 1.5px solid rgba(0,0,0,0.18);
    color: rgba(0,0,0,0.6);
}
.atk-tab.is-active {
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}

/* ============================= */
/* BUSCADOR */
/* ============================= */

.atk-search-wrap {
    padding: 12px 16px 8px;
    position: relative;
}
.atk-search-input {
    width: 100%;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 14px;
    padding: 11px 14px;
    color: #1a1a1a;
    font-size: 13.5px;
    outline: none;
}
.atk-search-input { box-shadow: 0 1px 3px rgba(0,0,0,0.05); transition: border-color .2s, box-shadow .2s; }
.atk-search-input:focus { border-color: var(--atk-accent); box-shadow: 0 0 0 3px rgba(52,131,250,0.15); }
.atk-search-input::placeholder { color: #888; }

.atk-search-results {
    position: absolute;
    left: 16px; right: 16px;
    top: calc(100% - 2px);
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 20;
    padding: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.atk-search-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
    font-size: 12.5px;
}
.atk-search-row:active { background: #f5f5f5; }
.atk-search-row__n { font-weight: 700; }
.atk-search-row__p { font-weight: 800; white-space: nowrap; }
.atk-search-row small { color: var(--atk-muted); display: block; }

/* ============================= */
/* SECCIONES */
/* ============================= */

.atk-section { padding: 16px 16px 8px; }
.atk-section-title { font-weight: 800; font-size: 15px; margin-bottom: 10px; color: #1a1a1a; }
.atk-empty { color: #777; font-size: 13px; padding: 20px 4px; text-align: center; }

/* Circulitos de categoría */
.atk-circle-row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.atk-circle-item {
    flex-shrink: 0;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    width: 62px;
    background: none; border: none;
    color: #777;
}
.atk-circle-badge {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: #fff;
    border: 1.5px solid #e5e5e5;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
}
.atk-circle-item.is-active .atk-circle-badge { border-color: #3483FA; }
.atk-circle-item span:last-child { font-size: 10.5px; text-align: center; line-height: 1.2; color: #444; }

/* ============================= */
/* GRID DE PRODUCTOS — parejo, tipo Mercado Libre */
/* ============================= */

.atk-local-grid, .atk-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.atk-pcard {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--atk-shadow);
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.atk-pcard:active { transform: scale(0.98); }
.atk-pcard__img {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #f8f8f8;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.atk-pcard__img img { width: 100%; height: 100%; object-fit: cover; }
.atk-pcard__placeholder { font-size: 40px; }
.atk-pcard__info { padding: 12px 10px; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.atk-pcard__name {
    font-size: 12.5px;
    font-weight: 600;
    color: #444;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
}
.atk-pcard__price { font-size: 16px; font-weight: 900; color: #0f8a6d; }
.atk-pcard__seller { font-size: 11px; color: var(--atk-muted); margin-top: auto; font-weight: 600; }

/* ============================= */
/* CATEGORÍA DE PRODUCTO / SHOP */
/* ============================= */

.atk-category__title {
    font-size: 20px;
    font-weight: 800;
    color: #1a1a1a;
    margin-bottom: 14px;
}

.atk-pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.atk-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 10px;
    background: #fff;
    color: #444;
    font-weight: 700;
    font-size: 13px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.atk-pagination .page-numbers.current { background: #3483FA; color: #fff; }

/* ============================= */
/* PRODUCTO: FLECHA FLOTANTE (sin cabecera) */
/* ============================= */

.atk-floating-back {
    position: sticky;
    top: 0;
    height: 0;
    z-index: 30;
    padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
    padding-left: 12px;
}
.atk-back-btn-minimal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,0.96);
    color: var(--atk-text);
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
    transition: transform .15s ease, background .15s ease;
}
.atk-back-btn-minimal:active { transform: scale(0.92); background: #fff; }

/* Páginas con texto arriba: dejar lugar para que la flecha no tape el título */
body:not(.single-product):not(.single-atk_store) .atk-floating-back ~ main { padding-top: 64px !important; }

/* Producto: el breadcrumb de WooCommerce quedaba tapado por la flecha */
.single-product .woocommerce-breadcrumb { display: none; }

/* ============================= */
/* GALERÍA DE PRODUCTO (miniaturas que cambian la foto principal) */
/* ============================= */

.single-product .woocommerce-product-gallery__image img { width: 100%; height: auto; display: block; }
.single-product .woocommerce-product-gallery__image:nth-child(n+2) {
    width: calc(25% - 10px) !important;
    margin: 10px 0 0 10px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--atk-shadow);
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color .15s ease, transform .15s ease;
}
.single-product .woocommerce-product-gallery__image:nth-child(n+2):active { transform: scale(0.95); }
.single-product .woocommerce-product-gallery__image.is-selected:nth-child(n+2) { border-color: var(--atk-accent); }

/* Estados de foco (accesibilidad) */
.atk-back-btn:focus-visible,
.atk-back-btn-minimal:focus-visible,
.atk-location-btn:focus-visible,
.atk-tab:focus-visible {
    outline: 2px solid var(--atk-accent);
    outline-offset: 2px;
}
.atk-back-btn:active,
.atk-location-btn:active { transform: scale(0.96); }

/* Hover solo en dispositivos con mouse */
@media (hover: hover) {
    .atk-back-btn:hover { background: rgba(0,0,0,0.18); }
    .atk-location-btn:hover { background: rgba(0,0,0,0.18); }
    .atk-tab:hover { border-color: rgba(0,0,0,0.3); }
    .atk-pcard:hover { box-shadow: var(--atk-shadow-hover); transform: translateY(-2px); }
}

/* ============================= */
/* FOOTER */
/* ============================= */

footer.atk-footer {
    background: #1a1a1a;
    color: #999;
    text-align: center;
    padding: 24px;
    font-size: 12px;
    margin-top: 30px;
}
footer.atk-footer strong { color: #FFD400; }


/* ============================= */
/* RESPONSIVE (tablet / desktop) */
/* ============================= */

@media (min-width: 640px) {
    .atk-local-grid, .atk-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 14px;
    }
    .atk-section, .atk-search-wrap { padding-left: 24px; padding-right: 24px; }
}
@media (min-width: 1024px) {
    .atk-local-grid, .atk-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 16px;
    }
    .atk-section, .atk-search-wrap { max-width: 1200px; margin-left: auto; margin-right: auto; }
    .atk-tabs { justify-content: center; }
    .atk-tab { flex: 0 1 180px; }
}
