/* ==========================================================================
   Buscaditos UI · Layout: Header global (prefijo .bd-header)
   Requiere tokens.css + components.css. Se carga en todas las páginas de la tienda.
   ========================================================================== */

/* El header es fijo (legacy: header { position: fixed } en shop.css).
   El body se desplaza exactamente la altura real del header; header.js la mide
   y la guarda en --bd-header-h. Los valores de aquí son solo el respaldo sin JS. */
body {
    padding-top: var(--bd-header-h, 127px) !important;
}

@media (max-width: 767px) {
    body {
        padding-top: var(--bd-header-h, 169px) !important;
    }
}

header.bd-header {
    box-shadow: 0 4px 16px rgba(15, 23, 41, .12);
}

/* .bd-actions y .bd-nav__list llevan .nav (la necesita el JS legacy):
   anulamos .nav > li > a { display:block; padding:10px 15px } de Bootstrap */
.bd-actions > li > a,
.bd-nav__list > li > a {
    display: inline-flex;
}

.bd-actions > li > a { padding: 0; }

.bd-actions > li > a:hover,
.bd-actions > li > a:focus,
.bd-actions.nav .open > a,
.bd-actions.nav .open > a:hover,
.bd-actions.nav .open > a:focus {
    background: rgba(255, 255, 255, .14);
}

.bd-nav__list > li > a:hover,
.bd-nav__list > li > a:focus,
.bd-nav__list.nav .open > a,
.bd-nav__list.nav .open > a:hover,
.bd-nav__list.nav .open > a:focus,
.bd-nav__list > li.active > a {
    background: var(--bd-brand-50);
}

.bd-nav__list > li > a.bd-nav__link--promo,
.bd-nav__list > li > a.bd-nav__link--promo:focus {
    background: var(--bd-accent);
}

.bd-nav__list > li > a.bd-nav__link--promo:hover {
    background: #ec7f00;
}
.bd-nav__list > li > a { padding: 0 14px; }

@media (max-width: 767px) {
    .bd-nav__list > li > a { padding: 0 8px; }
}

/* ---------- Barra superior (azul) ---------- */
.bd-topbar {
    background: var(--bd-brand);
    color: var(--bd-white);
}

.bd-topbar__inner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "logo search actions";
    align-items: center;
    gap: 32px;
    min-height: 76px;
    padding-top: 10px;
    padding-bottom: 10px;
}

@media (max-width: 767px) {
    .bd-topbar__inner {
        grid-template-columns: auto 1fr;
        grid-template-areas: "logo actions" "search search";
        gap: 8px 12px;
        padding-top: 8px;
        padding-bottom: 12px;
    }
}

.bd-logo { grid-area: logo; display: block; line-height: 0; }

.bd-logo img {
    width: auto;
    height: 52px;
}

@media (max-width: 767px) {
    .bd-logo img { height: 44px; }
}

/* ---------- Buscador ---------- */
.bd-search {
    grid-area: search;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
}

.bd-search form { margin: 0; }

.bd-search__box {
    display: flex;
    align-items: center;
    height: 44px;
    padding: 4px 4px 4px 18px;
    border-radius: var(--bd-r-md);
    background: var(--bd-white);
    box-shadow: 0 4px 14px rgba(15, 23, 41, .12);
}

.bd-search__input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    background: transparent;
    font-family: var(--bd-font);
    font-size: 14px;
    color: var(--bd-ink);
}

.bd-search__input::placeholder { color: var(--bd-muted); }
.bd-search__input:focus { outline: none; }
.bd-search__input::-webkit-search-cancel-button { display: none; }

.bd-search__mic,
.bd-search__submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}

.bd-search__mic {
    margin-right: 4px;
    background: transparent;
    color: var(--bd-muted);
    font-size: 16px;
}

.bd-search__mic:hover { color: var(--bd-brand); }
.bd-search__mic.listening { color: var(--bd-danger); }

.bd-search__submit {
    background: var(--bd-accent);
    color: var(--bd-white);
    font-size: 15px;
}

.bd-search__submit:hover { background: #ec7f00; }

/* ---------- Acciones (iconos) ---------- */
.bd-actions {
    grid-area: actions;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bd-actions > li { position: relative; }

.bd-action {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: var(--bd-r-md);
    background: transparent;
    color: var(--bd-white);
    cursor: pointer;
    transition: background-color .15s;
}

.bd-action:hover,
.bd-action:focus,
.open > .bd-action {
    background: rgba(255, 255, 255, .14);
    color: var(--bd-white);
    text-decoration: none;
}

.bd-action svg { width: 22px; height: 22px; }

.bd-action .badge {
    position: absolute;
    top: 2px;
    right: 0;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border: 2px solid var(--bd-brand);
    border-radius: var(--bd-r-pill);
    background: var(--bd-accent);
    color: var(--bd-white);
    font-family: var(--bd-font);
    font-size: 10px;
    font-weight: 800;
    line-height: 14px;
    transform: translate(35%, -20%);
}

.bd-action .badge:empty { display: none; }

@media (max-width: 767px) {
    .bd-actions { gap: 0; }
    .bd-action { width: 36px; height: 36px; }
    .bd-actions .bd-actions__admin { display: none; }
}

/* Menús desplegables del header (Bootstrap 3) */
.bd-header .dropdown-menu {
    margin-top: 8px;
    padding: 8px;
    border: 1px solid var(--bd-line);
    border-radius: var(--bd-r-lg);
    box-shadow: var(--bd-shadow-card);
    font-family: var(--bd-font);
    font-size: 13.5px;
}

.bd-header .dropdown-menu > li > a {
    padding: 8px 12px;
    border-radius: var(--bd-r-sm);
    color: var(--bd-ink-2);
}

.bd-header .dropdown-menu > li > a:hover {
    background: var(--bd-brand-50);
    color: var(--bd-brand);
}

.bd-header .dropdown-menu .mi { width: 18px; color: var(--bd-muted); }

/* Mini carrito */
.bd-header .dropdown-cart {
    width: min(380px, 94vw);
    transform: none;
}

.bd-header #cart-contents {
    min-width: 0;
    padding: 4px;
}

.bd-header #cart-empty {
    padding: 16px;
    color: var(--bd-muted);
    text-align: center;
}

@media (max-width: 767px) {
    .bd-header .dropdown-cart {
        position: fixed;
        top: var(--bd-header-h, 169px);
        right: 3vw;
        left: auto;
        margin-top: 0;
    }
}

/* ---------- Navegación (blanca) ---------- */
.bd-nav {
    background: var(--bd-white);
    border-bottom: 1px solid var(--bd-line);
}

.bd-nav__list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-height: 51px;
    margin: 0;
    padding: 6px 0;
    list-style: none;
}

.bd-nav__link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 14px;
    border-radius: 10px;
    color: var(--bd-ink);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color .15s, color .15s;
}

.bd-nav__link svg { width: 16px; height: 16px; flex-shrink: 0; }

.bd-nav__link:hover,
.bd-nav__link:focus,
.bd-nav li.active > .bd-nav__link,
.bd-nav li.open > .bd-nav__link {
    background: var(--bd-brand-50);
    color: var(--bd-brand);
    text-decoration: none;
}

.bd-nav__link--promo,
.bd-nav__link--promo:hover,
.bd-nav__link--promo:focus,
.bd-nav li.active > .bd-nav__link--promo {
    background: var(--bd-accent);
    color: var(--bd-white);
    box-shadow: 0 6px 14px rgba(255, 138, 0, .28);
}

.bd-nav__link--promo:hover { background: #ec7f00; }

@media (max-width: 767px) {
    .bd-nav__list { flex-wrap: nowrap; min-height: 49px; gap: 0; }
    .bd-nav__link { gap: 6px; padding: 0 8px; font-size: 13px; }
    .bd-nav__link svg { width: 14px; height: 14px; }
}

/* Categorías: submenús (dropdown-submenu legacy) */
.bd-nav .dropdown-menu {
    min-width: 240px;
    /* Sin hueco: el menú abre por hover sobre el <li> (general.js); un espacio lo cerraría */
    margin-top: 0;
}

/* Carrito / cuenta también abren por hover en desktop (ul.nav li.dropdown) */
.bd-actions .dropdown-menu {
    margin-top: 0;
}

/* Puente invisible que extiende el área de hover hasta el menú */
.bd-actions > li.dropdown::after,
.bd-nav__list > li.dropdown::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 8px;
}

.bd-nav .dropdown-submenu > .dropdown-menu {
    margin-left: 0;
}

/* ---------- Mini carrito (dropdown) ----------
   El HTML lo genera update_mini_cart() en scripts.min.js (tabla #cart-items):
   tbody > tr = [imagen | nombre + "qty x precio" | subtotal], tfoot = [artículos, total].
   Se rediseña solo con CSS para no tocar el JS legacy. */
.bd-header .dropdown-cart {
    padding: 0;
    overflow: hidden;
    color: var(--bd-ink);
}

.bd-header .dropdown-cart #cart-contents {
    max-height: none;
    padding: 0;
    overflow: visible;
}

.bd-header .dropdown-cart #cart-items {
    display: block;
    width: 100%;
    margin: 0;
    border: 0;
    background: transparent;
}

/* Lista de productos */
.bd-header .dropdown-cart #cart-items tbody {
    display: block;
    max-height: 320px;
    overflow-y: auto;
    padding: 8px;
}

.bd-header .dropdown-cart #cart-items tbody tr {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--bd-r-md);
    background: transparent !important;
}

.bd-header .dropdown-cart #cart-items tbody tr + tr {
    margin-top: 4px;
}

.bd-header .dropdown-cart #cart-items tbody tr:hover {
    background: var(--bd-surface) !important;
}

.bd-header .dropdown-cart #cart-items td {
    display: block;
    padding: 0;
    border: 0;
    background: transparent !important;
    color: var(--bd-muted) !important;
    font-size: 12px;
    line-height: 1.4;
}

.bd-header .dropdown-cart #cart-items td:first-child a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border: 1px solid var(--bd-line);
    border-radius: var(--bd-r-md);
    background: var(--bd-white);
    overflow: hidden;
}

.bd-header .dropdown-cart #cart-items td:first-child img {
    max-width: 48px;
    max-height: 48px;
    object-fit: contain;
}

.bd-header .dropdown-cart #cart-items td:nth-child(2) a {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    margin-bottom: 2px;
    color: var(--bd-ink) !important;
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
}

.bd-header .dropdown-cart #cart-items td:nth-child(2) a:hover {
    color: var(--bd-brand) !important;
}

.bd-header .dropdown-cart #cart-items td:last-child {
    color: var(--bd-ink) !important;
    font-size: 13.5px;
    font-weight: 800;
    white-space: nowrap;
}

/* Resumen */
.bd-header .dropdown-cart #cart-items tfoot {
    display: block;
    padding: 12px 18px;
    border-top: 1px solid var(--bd-line);
    background: var(--bd-surface);
}

.bd-header .dropdown-cart #cart-items tfoot tr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent !important;
}

.bd-header .dropdown-cart #cart-items tfoot tr + tr {
    margin-top: 4px;
}

.bd-header .dropdown-cart #cart-items tfoot td {
    display: block;
    padding: 0;
    border: 0;
    background: transparent !important;
    color: var(--bd-muted) !important;
    font-size: 13px;
    font-weight: 500;
}

.bd-header .dropdown-cart #cart-items tfoot tr:last-child td {
    color: var(--bd-ink) !important;
    font-size: 16px;
    font-weight: 800;
}

.bd-header .dropdown-cart #cart-items tfoot tr:last-child td:last-child {
    color: var(--bd-brand) !important;
    font-size: 18px;
}

/* Botones */
.bd-header .dropdown-cart #cart-links {
    margin: 0 !important;
    padding: 12px 18px 16px;
    background: var(--bd-surface);
}

.bd-header .dropdown-cart #cart-links .btn-group-justified {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.bd-header .dropdown-cart #cart-links .btn-group-justified > .btn-group {
    display: block !important;
    width: auto !important;
    float: none !important;
}

.bd-header .dropdown-cart #cart-links .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 42px;
    padding: 0 10px;
    border: 1px solid var(--bd-line) !important;
    border-radius: var(--bd-r-md) !important;
    background: var(--bd-white) !important;
    color: var(--bd-ink) !important;
    font-family: var(--bd-font);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.bd-header .dropdown-cart #cart-links .btn:hover {
    border-color: var(--bd-brand) !important;
    color: var(--bd-brand) !important;
}

.bd-header .dropdown-cart #cart-links .btn-group-justified > .btn-group:last-child > .btn {
    border-color: var(--bd-brand) !important;
    background: var(--bd-brand) !important;
    color: var(--bd-white) !important;
    box-shadow: 0 6px 14px rgba(46, 74, 178, .25);
}

.bd-header .dropdown-cart #cart-links .btn-group-justified > .btn-group:last-child > .btn:hover {
    background: #263e98 !important;
    color: var(--bd-white) !important;
}

/* Vacío */
.bd-header .dropdown-cart #cart-empty {
    padding: 28px 20px;
    color: var(--bd-muted);
    font-size: 13.5px;
    text-align: center;
}

.bd-header .dropdown-cart #cart-empty::before {
    content: "\f07a";
    display: block;
    margin-bottom: 10px;
    font-family: FontAwesome;
    font-size: 28px;
    color: var(--bd-line);
}
