/* =================================================
   Custom Header — Tienda Globus v6.0
   ================================================= */

:root {
    --ch-accent:          #1a3a5c;
    --ch-nav-bg:          #ffffff;
    --ch-nav-text:        #222222;
    --ch-top-bg:          #ffffff;
    --ch-top-text:        #222222;
    --ch-top-h:           70px;
    --ch-max-w:           1280px;
    --ch-todo-bg:         #1a3a5c;
    --ch-todo-text:       #ffffff;
    --ch-panel-bg:        #ffffff;
    --ch-panel-text:      #1a2a3a;
    --ch-panel-head-bg:   #1a3a5c;
    --ch-panel-head-text: #ffffff;
    --ch-open-bg:         #1a3a5c;
    --ch-open-text:       #ffffff;
    --ch-active-bg:       #1a3a5c;
    --ch-active-text:     #ffffff;
    --ch-transition:      .18s ease;
    --ch-radius:          8px;
}

/* ── Admin bar ── */
.admin-bar #ch { top: 32px; }
@media screen and (max-width: 782px) {
    .admin-bar #ch { top: 46px; }
}

/* ══════════════════════
   HEADER
══════════════════════ */
#ch {
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    background: var(--ch-top-bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1;
    color: var(--ch-top-text);
    transition: box-shadow .3s;
}

#ch.is-scrolled {
    box-shadow: 0 1px 0 rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.07);
}

#ch .ch-wrap {
    max-width: var(--ch-max-w, 1280px);
    margin: 0 auto;
    padding: 0 28px;
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

/* Fila 1 */
#ch .ch-bar--top {
    height: var(--ch-top-h);
    background: var(--ch-top-bg);
    border-bottom: 1px solid rgba(0,0,0,.06);
}

#ch .ch-bar--top .ch-wrap { height: 100%; gap: 24px; }

/* Logo */
#ch .ch-logo {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    text-decoration: none;
    line-height: 0;
}

#ch .ch-logo__img {
    display: block;
    height: calc(var(--ch-top-h) * .55);
    width: auto;
    max-width: 200px;
    object-fit: contain;
}

#ch .ch-logo__text {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--ch-accent);
    letter-spacing: -.02em;
    white-space: nowrap;
}

/* Buscador */
#ch .ch-search {
    flex: 1;
    min-width: 0;
    max-width: 560px;
    margin: 0 auto;
    display: flex;
    align-items: center;
}

/*
 * FiboSearch inyecta estilos inline con alta especificidad.
 * Estos !important son el único lugar justificado en todo el plugin.
 */
#ch .ch-search .dgwt-wcas-search-wrapp { width: 100% !important; margin: 0 !important; display: block !important; }
#ch .ch-search .dgwt-wcas-sf-wrapp    { width: 100% !important; display: flex !important; align-items: center !important; }
#ch .ch-search .dgwt-wcas-search-input,
#ch .ch-search input[type="search"],
#ch .ch-search input[type="text"]      { width: 100% !important; box-sizing: border-box !important; margin: 0 !important; float: none !important; }
#ch .ch-search form                    { width: 100% !important; margin: 0 !important; display: flex !important; align-items: center !important; }
#ch .ch-search .search-field           { flex: 1 !important; width: 100% !important; }

/* Acciones */
#ch .ch-actions { flex-shrink: 0; display: flex; align-items: center; gap: 4px; }

#ch .ch-icon-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: var(--ch-radius);
    color: var(--ch-top-text);
    text-decoration: none;
    background: transparent;
    border: none;
    box-shadow: none;
    cursor: pointer;
    transition: background var(--ch-transition), color var(--ch-transition);
}

#ch .ch-icon-btn::before, #ch .ch-icon-btn::after { display: none; }
#ch .ch-icon-btn:hover { background: rgba(0,0,0,.055); color: var(--ch-accent); }
#ch .ch-icon-btn svg { display: block; flex-shrink: 0; }

/* Badge */
#ch .ch-badge {
    position: absolute;
    top: 4px; right: 4px;
    min-width: 18px; height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--ch-accent);
    color: #fff;
    font-size: 10px; font-weight: 700; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
    border: 2px solid var(--ch-top-bg);
}
#ch .ch-badge[hidden] { display: none; }

/* Hamburguesa */
#ch .ch-burger {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 44px; height: 44px;
    padding: 10px;
    background: none; border: none; box-shadow: none;
    border-radius: var(--ch-radius);
    cursor: pointer;
}
#ch .ch-burger::before, #ch .ch-burger::after { display: none; }
#ch .ch-burger span {
    display: block;
    width: 20px; height: 2px;
    background: var(--ch-top-text);
    border-radius: 2px;
    transition: transform .22s ease, opacity .22s ease;
}
#ch .ch-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#ch .ch-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; transform: scaleX(0); }
#ch .ch-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Fila 2: nav */
#ch .ch-bar--nav {
    height: 44px;
    background: var(--ch-nav-bg);
    border-bottom: 1px solid rgba(0,0,0,.06);
}
#ch .ch-bar--nav .ch-wrap { height: 100%; gap: 0; overflow: hidden; }

/* Botón Todo */
html body #ch .ch-todo-btn {
    flex-shrink: 0;
    display: flex; align-items: center; gap: 8px;
    height: 44px; padding: 0 16px;
    background: var(--ch-todo-bg);
    color: var(--ch-todo-text);
    border: none; border-radius: 0; box-shadow: none;
    cursor: pointer;
    font-size: .87rem; font-weight: 600; font-family: inherit; line-height: 1;
    white-space: nowrap;
    transition: filter var(--ch-transition);
}
#ch .ch-todo-btn::before, #ch .ch-todo-btn::after { display: none; }
html body #ch .ch-todo-btn:hover,
html body #ch .ch-todo-btn[aria-expanded="true"] { filter: brightness(.82); }
#ch .ch-todo-btn svg  { stroke: var(--ch-todo-text); flex-shrink: 0; }
#ch .ch-todo-btn span { color: var(--ch-todo-text); }

/* Separador */
#ch .ch-nav-sep { flex-shrink: 0; width: 1px; height: 20px; margin: 0 6px; background: rgba(128,128,128,.2); }

/* Categorías fijas */
#ch .ch-cats { flex: 1; min-width: 0; display: flex; align-items: stretch; height: 100%; list-style: none; margin: 0; padding: 0; overflow: hidden; }
#ch .ch-cat  { display: flex; align-items: stretch; flex-shrink: 0; list-style: none; margin: 0; padding: 0; }

#ch .ch-cat__link {
    display: flex; align-items: center; gap: 5px;
    padding: 0 10px; height: 100%;
    color: var(--ch-nav-text);
    text-decoration: none; font-size: .83rem; white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: background var(--ch-transition), border-color var(--ch-transition);
}
#ch .ch-cat__link:hover           { background: rgba(128,128,128,.1); border-bottom-color: var(--ch-nav-text); }
#ch .ch-cat.is-active .ch-cat__link { font-weight: 600; border-bottom-color: var(--ch-nav-text); }
#ch .ch-cat__icon { width: 18px; height: 18px; object-fit: contain; flex-shrink: 0; display: block; }

/* ══════════════════════
   OVERLAY
══════════════════════ */
.ch-overlay {
    position: fixed; inset: 0;
    z-index: 1001;
    background: rgba(10,20,40,.48);
    backdrop-filter: blur(2px);
    opacity: 0; visibility: hidden;
    transition: opacity .28s ease, visibility .28s ease;
}
.ch-overlay.is-visible { opacity: 1; visibility: visible; }

/* ══════════════════════
   PANEL LATERAL
══════════════════════ */
.ch-panel {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1002;
    width: 300px; max-width: 88vw;
    display: flex; flex-direction: column;
    background: var(--ch-panel-bg);
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    box-shadow: 2px 0 24px rgba(0,0,0,.12);
}
.ch-panel.is-open { transform: translateX(0); }
.ch-panel[hidden] { display: none; }
.ch-panel.is-open { display: flex; }

/* Cabecera del panel */
.ch-panel__head {
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: space-between;
    height: 56px; padding: 0 14px 0 20px;
    background: var(--ch-panel-head-bg);
}
.ch-panel__title { font-size: .9rem; font-weight: 600; color: var(--ch-panel-head-text); letter-spacing: .01em; }

html body .ch-panel__close {
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; width: 32px; height: 32px; padding: 0;
    background: rgba(255,255,255,.12); border: none; border-radius: 6px; box-shadow: none;
    cursor: pointer; color: var(--ch-panel-head-text); font-size: 0;
    transition: background var(--ch-transition);
}
.ch-panel__close::before, .ch-panel__close::after { display: none; }
.ch-panel__close svg { display: block; }
html body .ch-panel__close:hover { background: rgba(255,255,255,.24); }

/* Cuerpo */
.ch-panel__body {
    flex: 1; overflow-y: auto; overscroll-behavior: contain;
    padding: 4px 0 48px;
    scrollbar-width: thin; scrollbar-color: #e0e0e0 transparent;
}
.ch-panel__body::-webkit-scrollbar       { width: 3px; }
.ch-panel__body::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }

/* Reset listas */
.ch-panel ul, .ch-panel ol, .ch-panel li { list-style: none; margin: 0; padding: 0; }

/* Ítems */
.ch-panel__item { border-bottom: 1px solid #f0f0f0; }
.ch-panel__item:last-child { border-bottom: none; }

.ch-panel__row { display: flex; align-items: stretch; min-height: 52px; }

/* Enlace de navegación */
.ch-panel__link {
    flex: 1; display: flex; align-items: center; gap: 12px;
    padding: 12px 8px 12px 20px;
    color: var(--ch-panel-text);
    text-decoration: none; font-size: .88rem; font-weight: 500; line-height: 1.3;
    min-width: 0;
    transition: background var(--ch-transition), color var(--ch-transition);
}
.ch-panel__link:hover { background: #f4f7fb; color: var(--ch-accent); }
.ch-panel__link img { display: block; flex-shrink: 0; width: 24px; height: 24px; object-fit: contain; opacity: .85; }
.ch-panel__link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Botón toggle */
html body .ch-panel__toggle {
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    width: 48px; height: auto; padding: 0;
    background: transparent; border: none; border-left: 1px solid #efefef;
    border-radius: 0; box-shadow: none;
    cursor: pointer; color: #c0c8d4; font-size: 0;
    transition: background var(--ch-transition), color var(--ch-transition);
}
.ch-panel__toggle::before, .ch-panel__toggle::after { display: none; }
.ch-panel__toggle svg { display: block; transition: transform .25s ease; }
html body .ch-panel__toggle:hover { background: #f4f7fb; color: var(--ch-accent); }

/* ── Estado: ítem desplegado (is-open) ── */
.ch-panel__item.is-open > .ch-panel__row > .ch-panel__link {
    background: var(--ch-open-bg);
    color: var(--ch-open-text);
    font-weight: 600;
}
.ch-panel__item.is-open > .ch-panel__row > .ch-panel__link:hover {
    filter: brightness(.9);
}
.ch-panel__item.is-open > .ch-panel__row > .ch-panel__toggle {
    background: var(--ch-open-bg);
    color: var(--ch-open-text);
    border-left-color: rgba(255,255,255,.15);
}
.ch-panel__item.is-open > .ch-panel__row > .ch-panel__toggle svg {
    transform: rotate(180deg);
}

/* ── Estado: categoría activa (página actual) ── */
.ch-panel__item.is-current-cat > .ch-panel__row > .ch-panel__link,
.ch-panel__item.current-menu-item > .ch-panel__row > .ch-panel__link,
.ch-panel__item.current-menu-ancestor > .ch-panel__row > .ch-panel__link {
    background: var(--ch-active-bg);
    color: var(--ch-active-text);
    font-weight: 600;
}
.ch-panel__item.is-current-cat > .ch-panel__row > .ch-panel__toggle,
.ch-panel__item.current-menu-item > .ch-panel__row > .ch-panel__toggle,
.ch-panel__item.current-menu-ancestor > .ch-panel__row > .ch-panel__toggle {
    background: var(--ch-active-bg);
    color: var(--ch-active-text);
    border-left-color: rgba(255,255,255,.15);
}

/* Subcategorías nivel 1 */
.ch-acc-body { overflow: hidden; max-height: 0; transition: max-height .28s ease; }
.ch-acc-item.is-open > .ch-acc-row .ch-acc-btn svg { transform: rotate(180deg); }
.ch-panel__subs-wrap { border-top: 1px solid #efefef; }
.ch-acc-body .ch-acc-item { border-bottom: 1px solid #efefef; }
.ch-acc-body .ch-acc-item:last-child { border-bottom: none; }

.ch-panel__item.depth-1 { border-bottom: none; }
.ch-panel__item.depth-1 > .ch-acc-row { background: #f8f9fb; }
.ch-panel__item.depth-1 .ch-panel__link { padding-left: 32px; font-size: .855rem; font-weight: 400; color: #4a5568; }
.ch-panel__item.depth-1 .ch-panel__link:hover { color: var(--ch-accent); background: #edf2f8; }

.ch-panel__item.depth-2 > .ch-acc-row { background: #f2f4f8; }
.ch-panel__item.depth-2 .ch-panel__link { padding-left: 44px; font-size: .83rem; font-weight: 400; color: #5a6880; }
.ch-panel__item.depth-2 .ch-panel__link:hover { color: var(--ch-accent); background: #e4eaf4; }

/* Búsqueda móvil */
#ch .ch-bar--search {
    display: none;
    background: var(--ch-top-bg);
    border-bottom: 1px solid rgba(0,0,0,.06);
    padding: 8px 0;
}
#ch .ch-bar--search .ch-wrap { height: auto; padding: 0 16px; }
#ch .ch-bar--search .ch-search { max-width: 100%; margin: 0; width: 100%; }

/* Iconos */
.ch-icons-off .ch-cat__icon,
.ch-icons-off .ch-panel__link img { display: none; }

/* ══════════════════════
   RESPONSIVE
══════════════════════ */
@media (max-width: 960px) {
    #ch .ch-wrap { padding: 0 16px; }
    #ch .ch-search { max-width: none; }
}

@media (max-width: 640px) {
    .admin-bar #ch { top: 0; }
    #ch .ch-bar--nav { display: none; }
    #ch .ch-bar--top .ch-search { display: none; }
    #ch .ch-bar--search { display: block; }
    #ch .ch-bar--top .ch-wrap { gap: 0; justify-content: space-between; }
    #ch .ch-burger { display: flex; order: 1; flex-shrink: 0; }
    #ch .ch-logo { order: 2; position: absolute; left: 50%; transform: translateX(-50%); }
    #ch .ch-actions { order: 3; margin-left: auto; }
    #ch .ch-actions .ch-burger { display: none; }
    .ch-panel { width: 100%; max-width: 100%; }
}
