:root {
    --headerYfooter: linear-gradient(90deg, #00a3e0, #002b5c);
    --primary: #002b5c;
    --secondary: #00a3e0;
    --accent: #0fd4ff;
    --bg: #f0f7ff;
    --text: #111;
    --sidebar-width: 260px;
    --header-height: 70px;
    --subheader-height: 38px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial;
}

html,
body {
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* HEADER */
header {
    position: fixed;
    top: 0;
    width: 100%;
    height: var(--header-height);
    min-height: var(--header-height);
    overflow: hidden;
    background: var(--headerYfooter);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    z-index: 1000;
}

.sub-header {
    position: fixed;
    top: 70px;
    left: 0;
    width: 100%;
    background-color: var(--accent);
    padding: 10px 0;
    z-index: 900;
    transition: transform 0.25s ease;
    transform: translateY(0);
}

.sub-header.hidden {
    transform: translateY(-100%);
}

.sub-header .sub-toggle {
    display: none;
}

.sub-nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 40px;
    margin: 0;
    padding: 0;
}

.sub-nav a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.sub-nav a:hover {
    color: white;
}

nav#nav-menu {
    display: flex;
    align-items: center;
    gap: 20px;
}

nav#nav-menu ul {
    display: flex;
    align-items: center;
    gap: 20px;
    margin: 0;
    padding: 0;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
}

.menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: white;
    border-radius: 2px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0;
    height: 70px;
}

.logo .imagen-logo {
    width: 55px;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0;
}

.logo .imagen-letras {
    width: 200px;
    height: auto;
    object-fit: contain;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 20px;
}

nav a {
    color: white;
    text-decoration: none;
    transition: color 0.2s;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
}

.menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: white;
    border-radius: 2px;
}

.sub-nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 40px;
    margin: 0;
    padding: 0;
}

.sub-nav a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.sub-nav a:hover {
    color: white;
}

/* LAYOUT PRINCIPAL */
.catalogo-layout {
    display: flex;
    margin-top: calc(var(--header-height) + var(--subheader-height));
    min-height: calc(100vh - var(--header-height) - var(--subheader-height) - 100px);
    position: relative;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: white;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    position: sticky;
    top: calc(var(--header-height) + var(--subheader-height));
    height: calc(100vh - var(--header-height) - var(--subheader-height) - 100px);
    overflow-y: auto;
    z-index: 800;
}

/* Si el sub-header está oculto, el sidebar sube al nivel del header para evitar espacio en blanco */
.sub-header.hidden + .catalogo-layout .sidebar {
    top: var(--header-height);
    height: calc(100vh - var(--header-height) - 100px);
}

@media (min-width: 769px) {
    .sub-header.hidden + .catalogo-layout .sidebar {
        top: var(--header-height);
        height: calc(100vh - var(--header-height) - 100px);
    }
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.sidebar-header h2 {
    font-size: 14px;
    color: var(--primary);
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    font-size: 16px;
    padding: 4px;
}

/* OVERLAY MÓVIL */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 799;
}

.sidebar-overlay.active {
    display: block;
}

/* NAVEGACIÓN CATEGORÍAS */
.cat-item {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.cat-label {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    color: var(--primary);
    text-align: left;
    transition: background 0.15s;
}

.cat-label:hover {
    background: var(--bg);
}

.cat-label .arrow {
    font-size: 10px;
    transition: transform 0.2s;
    color: var(--secondary);
}

.cat-label.open .arrow {
    transform: rotate(90deg);
}

.sub-list {
    display: none;
}

.sub-list.open {
    display: block;
}

.sub-label {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 16px 9px 24px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: var(--text);
    text-align: left;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    transition: background 0.15s;
}

.sub-label:hover {
    background: var(--bg);
}

.sub-label .sub-arrow {
    font-size: 9px;
    transition: transform 0.2s;
    color: var(--secondary);
}

.sub-label.open .sub-arrow {
    transform: rotate(90deg);
}

.sub-label.active,
.sub-label.leaf.active {
    color: var(--secondary);
    font-weight: bold;
}

.sub-sub-list {
    display: none;
    background: #f8fbff;
}

.sub-sub-list.open {
    display: block;
}

.sub-sub-label {
    display: block;
    width: 100%;
    padding: 8px 16px 8px 36px;
    background: none;
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    cursor: pointer;
    font-size: 11px;
    color: #555;
    text-align: left;
    transition: background 0.15s;
}

.sub-sub-label:hover {
    background: var(--bg);
    color: var(--primary);
}

.sub-sub-label.active {
    color: var(--secondary);
    font-weight: bold;
    background: #e8f6ff;
}

/* ÁREA DE PRODUCTOS */
.productos-area {
    flex: 1;
    padding: 24px 24px 124px 24px;
    min-width: 0;
}

.productos-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.prod-modelo {
    font-size: 11px;
    color: var(--secondary);
    font-weight: bold;
}

.prod-price-original {
    font-size: 11px;
    color: #999;
    text-decoration: line-through;
    margin-top: auto;
}

.prod-price-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.prod-descuento {
    font-size: 11px;
    font-weight: bold;
    color: white;
    background: #e63946;
    padding: 2px 5px;
    border-radius: 4px;
}

.search-container {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 560px;
    margin-top: 8px;
}

.search-container input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    background: white;
    color: #111;
}

.search-container button {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.search-container button:hover {
    background: var(--secondary);
}

.sidebar-toggle-mobile {
    display: none;
    align-items: center;
    gap: 6px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

/* BREADCRUMB */
.breadcrumb {
    font-size: 11px;
    color: #888;
    margin-bottom: 4px;
}

.breadcrumb-link {
    color: var(--secondary);
    cursor: pointer;
    font-size: 11px;
}

.breadcrumb-link:hover {
    text-decoration: underline;
}

.breadcrumb-sep {
    color: #aaa;
    font-size: 11px;
    margin: 0 2px;
}

.breadcrumb-actual {
    color: #888;
    font-size: 11px;
}

.productos-titulo {
    font-size: 20px;
    color: var(--primary);
}

.productos-placeholder {
    color: #999;
    font-size: 14px;
    margin-top: 40px;
    text-align: center;
}

/* GRID DE PRODUCTOS */
.productos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    padding-bottom: 124px;
}

.prod-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
}

.prod-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.prod-img {
    width: 100%;
    height: 130px;
    object-fit: contain;
    background: #f5f5f5;
    padding: 8px;
}

.prod-info {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.prod-title {
    font-size: 12px;
    color: var(--text);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    line-clamp: 3;
    /* propiedad estándar */
    overflow: hidden;
    text-overflow: ellipsis;
}

.prod-price {
    font-size: 14px;
    font-weight: bold;
    color: var(--primary);
    margin-top: auto;
}

/* FOOTER */
footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: var(--headerYfooter);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 0;
    font-size: 0.9rem;
    line-height: 1.2;
}

.footer-copy {
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.75rem;
    margin-top: 4px;
}

.footer-info {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.footer-info h3 {
    margin: 0 0 4px;
    font-size: 1rem;
}

.footer-info .redes {
    display: flex;
    justify-content: center;
}

.footer-info i {
    display: block;
    font-size: 10.5px;
    line-height: 1.2;
    margin: 2px 0;
}

.fb-icon {
    font-size: 22px;
    color: white;
    position: relative;
}

.footer-info .correo:link,
.footer-info .ubicacion:link,
.footer-info .correo:visited,
.footer-info .ubicacion:visited {
    color: var(--bg);
    text-decoration: underline;
}

.footer-info .correo:hover,
.footer-info .ubicacion:hover {
    color: var(--primary);
    text-decoration: underline;
}

.fb-icon {
    font-size: 30px;
    color: white;
    position: relative;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {

    /* Header */
    header {
        padding: 0 16px;
        height: auto;
        min-height: 70px;
        overflow: visible;
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: 70px auto;
        align-items: center;
    }

    .logo .imagen-letras{
        grid-column: 1;
        grid-row: 1;
    }

    .menu-toggle {
        grid-column: 2;
        grid-row: 1;
        display: flex;
    }

    nav#nav-menu {
        grid-column: 1 / -1;
        grid-row: 2;
        position: static;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        flex-direction: column;
        align-items: center;
    }

    nav#nav-menu.open {
        max-height: 200px;
    }

    nav#nav-menu ul {
        flex-direction: column;
        gap: 0;
        padding: 8px 0 12px 0;
        width: 100%;
    }

    nav ul li a {
        display: block;
        padding: 10px 4px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        text-align: center;
    }

    /* Sub header */
    .sub-header {
        top: var(--header-height);
        z-index: 901;
    }

    .sub-header .sub-toggle {
        display: block;
        width: 100%;
        color: white;
        background: transparent;
        border: none;
        text-align: center;
        padding: 8px 0;
        font-weight: 600;
        cursor: pointer;
    }

    .sub-nav {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.2s ease;
    }

    .sub-nav.open {
        max-height: 220px;
    }

    .sub-nav ul {
        flex-direction: column;
        gap: 10px;
        padding: 8px;
    }

    .sub-nav a {
        display: block;
        text-align: center;
    }

    /* Layout */
    .catalogo-layout {
        margin-top: calc(var(--header-height) + var(--subheader-height) + 8px);
        min-height: calc(100vh - var(--header-height) - var(--subheader-height) - 100px);
    }

    /* Sidebar */
    .sidebar {
        position: fixed;
        top: calc(var(--header-height) + var(--subheader-height));
        left: 0;
        width: 280px;
        min-width: 280px;
        height: calc(100vh - var(--header-height) - var(--subheader-height));
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
        background: white;
        overflow-y: auto;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: block;
    }

    .sidebar-toggle-mobile {
        display: flex;
        position: relative;
        z-index: 1;
        margin-bottom: 8px;
        margin-top: 8px;
    }

    /* Productos */
    .productos-area {
        padding: 8px 16px 180px 16px;
    }

    .productos-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
        padding-bottom: 160px;
    }

    /* Footer */
    footer {
        transform: translateY(100%);
        transition: transform 0.2s ease;
        padding: 12px 16px;
    }

    footer.show-footer {
        transform: translateY(0);
    }

    .footer-info {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
        width: 100%;
        padding: 0 8px;
    }

    .footer-info div {
        width: 100%;
    }

    .footer-info i {
        display: block;
        margin: 4px 0;
        font-size: 0.85rem;
    }
}

@media (min-width: 769px) {
    footer {
        transform: translateY(0);
    }

    .sub-header .sub-toggle {
        display: none;
    }

    .sub-nav {
        max-height: none;
        overflow: visible;
    }

    /* Escritorio: sidebar fijo al viewport para evitar cambio de altura con scroll */
    .sidebar {
        position: fixed;
        top: calc(var(--header-height) + var(--subheader-height));
        left: 0;
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
        height: calc(100vh - var(--header-height) - var(--subheader-height) - 100px);
        overflow-y: auto;
        z-index: 900;
    }

    .catalogo-layout {
        margin-left: var(--sidebar-width);
        min-width: calc(100% - var(--sidebar-width));
    }

    .productos-area {
        padding-left: 24px;
        width: calc(100% - var(--sidebar-width));
    }
}
