/* ============================================
   NAVBAR STYLES
   ============================================ */

/* Top Bar */
.hm-topbar {
    background: var(--bg-footer);
    padding: 6px 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.hm-topbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hm-topbar-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hm-topbar-left svg {
    color: var(--accent);
    width: 14px;
    height: 14px;
}

.hm-topbar-right {
    display: flex;
    gap: 16px;
    align-items: center;
}

.hm-topbar-right a {
    color: var(--text-muted);
    transition: color var(--transition-fast);
}

.hm-topbar-right a:hover {
    color: var(--accent);
}

/* Main Navbar */
.hm-navbar {
    background: var(--bg-primary);
    height: var(--navbar-height);
    position: sticky;
    top: 0;
    z-index: 1100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    transition: all var(--transition-normal);
}

.hm-navbar.scrolled {
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.hm-navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    gap: 20px;
}

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

.hm-logo-img {
    height: 80px;
    width: auto;
    display: block;
    transition: transform var(--transition-normal);
}

.hm-logo:hover .hm-logo-img {
    transform: scale(1.05);
}

/* Categories Button (desktop only) */
.hm-categories-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.hm-categories-trigger:hover {
    border-color: var(--accent);
    background: rgba(249, 115, 22, 0.1);
}

.hm-categories-trigger svg {
    width: 18px;
    height: 18px;
    transition: transform var(--transition-fast);
}

.hm-categories-trigger.active svg {
    transform: rotate(180deg);
}

/* Search Bar */
.hm-search {
    flex: 1;
    max-width: 500px;
    position: relative;
}

.hm-search::before,
.hm-search::after {
    display: none !important;
    content: none !important;
}

.hm-search-input-field {
    width: 100%;
    padding: 12px 48px 12px 20px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    outline: none;
}

.hm-search-input-field::placeholder {
    color: var(--text-muted);
}

.hm-search-input-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

.hm-search-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--accent);
    border: none;
    border-radius: 6px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.hm-search-btn:hover {
    background: var(--accent-hover);
}

.hm-search-btn svg {
    width: 18px;
    height: 18px;
    color: white;
}

/* Search Backdrop Overlay */
.hm-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.hm-search-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Premium Search Layout */
.hm-search-results {
    position: absolute;
    top: calc(100% + 12px);
    left: -50px;
    right: -50px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 15px 50px -10px rgba(0, 0, 0, 0.5);
    z-index: 1100;
    display: none;
    padding: 0;
    overflow: hidden;
    min-width: 800px;
}

.hm-search-results.active {
    display: block;
    animation: fadeInScale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.hm-search-results-grid {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 350px;
}

/* Left Column: Categories */
.hm-search-results-left {
    background: rgba(0, 0, 0, 0.15);
    border-right: 1px solid var(--border-color);
    padding: 24px 20px;
}

.hm-search-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
    display: block;
}

.hm-search-cat-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color var(--transition-fast);
}

.hm-search-cat-link:hover {
    color: var(--accent);
}

.hm-search-cat-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Right Column: Products */
.hm-search-results-right {
    padding: 24px 24px;
}

.hm-search-product-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.hm-search-result-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    transition: background var(--transition-fast);
}

.hm-search-result-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.hm-search-result-image {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 6px;
    background: var(--bg-primary);
    flex-shrink: 0;
}

.hm-search-result-info {
    flex: 1;
}

.hm-search-result-title {
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    display: block;
    margin-bottom: 4px;
    /* Allow wrapping for long names */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hm-search-result-price {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
}

/* Empty/Loading States */
.hm-search-results-empty {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    grid-column: span 2;
}

.hm-search-results-loading {
    padding: 40px;
    text-align: center;
    grid-column: span 2;
}

.hm-search-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(249, 115, 22, 0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

/* Desktop Clipping Fix */
.hm-navbar, .hm-navbar .container, .hm-search {
    overflow: visible !important;
}

@media (max-width: 768px) {
    .hm-search-results {
        left: 0;
        right: 0;
        width: calc(100vw - 40px);
        min-width: 0;
        margin: 0 auto;
        max-height: 70vh;
        overflow-y: auto;
    }
    .hm-search-results-grid {
        grid-template-columns: 1fr;
    }
    .hm-search-results-left {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 16px;
    }
    .hm-search-product-grid {
        grid-template-columns: 1fr;
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeInScale {
    from { opacity: 0; transform: translateY(-10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Nav Actions */
.hm-nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.hm-nav-action {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all var(--transition-fast);
    position: relative;
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--font-body);
    font-size: 0.85rem;
    text-decoration: none;
}

.hm-nav-action:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

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

.hm-nav-action-label {
    display: none;
}

.hm-cart-count {
    position: absolute;
    top: 0px;
    left: 18px;
    background: var(--accent);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Mega Menu */
.hm-mega-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 2px solid var(--accent);
    padding: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-lg);
    z-index: 999;
}

.hm-mega-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.hm-mega-menu-layout {
    display: flex;
    min-height: 380px;
}

.hm-mega-menu-categories {
    width: 340px;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.15);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hm-mega-menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    color: var(--text);
    transition: all var(--transition-fast);
    cursor: pointer;
    position: relative;
}

.hm-mega-menu-item-link {
    display: flex;
    align-items: center;
    gap: 14px;
    color: inherit;
    text-decoration: none;
    flex: 1;
}

.hm-mega-menu-item:hover,
.hm-mega-menu-item.active {
    background: rgba(249, 115, 22, 0.1);
    color: var(--text);
}

.hm-mega-menu-item.active {
    border-left: 3px solid var(--accent);
    padding-left: 13px;
}

.hm-mega-menu-chevron {
    color: var(--text-muted);
    flex-shrink: 0;
    transition: all var(--transition-fast);
    opacity: 0;
}

.hm-mega-menu-item:hover .hm-mega-menu-chevron,
.hm-mega-menu-item.active .hm-mega-menu-chevron {
    opacity: 1;
    color: var(--accent);
}

.hm-mega-menu-icon {
    width: 42px;
    height: 42px;
    background: rgba(249, 115, 22, 0.12);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.hm-mega-menu-item:hover .hm-mega-menu-icon,
.hm-mega-menu-item.active .hm-mega-menu-icon {
    background: var(--accent);
}

.hm-mega-menu-icon svg {
    width: 22px;
    height: 22px;
    color: var(--accent);
    transition: color var(--transition-fast);
}

.hm-mega-menu-item:hover .hm-mega-menu-icon svg,
.hm-mega-menu-item.active .hm-mega-menu-icon svg {
    color: white;
}

.hm-mega-menu-info h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1px;
}

.hm-mega-menu-info span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.hm-mega-menu-subcategories {
    flex: 1;
    position: relative;
    padding: 32px 40px;
}

.hm-mega-subcategory-panel {
    display: none;
    animation: fadeIn 0.25s ease;
}

.hm-mega-subcategory-panel.active {
    display: block;
}

.hm-mega-subcategory-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.hm-mega-subcategory-header h4 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-heading);
    font-size: 1.3rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text);
}

.hm-mega-subcategory-header h4 svg {
    width: 28px;
    height: 28px;
    color: var(--accent);
}

.hm-mega-subcategory-viewall {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.hm-mega-subcategory-viewall:hover {
    color: var(--accent-hover);
    gap: 10px;
}

.hm-mega-subcategory-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.hm-mega-subcategory-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.88rem;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.hm-mega-subcategory-link:hover {
    background: rgba(249, 115, 22, 0.08);
    color: var(--accent);
    transform: translateX(4px);
}

.hm-mega-subcategory-link svg {
    width: 12px;
    height: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: color var(--transition-fast);
}

.hm-mega-subcategory-link:hover svg {
    color: var(--accent);
}

.hm-mega-subcategory-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

.hm-mega-subcategory-empty {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 20px 0;
    color: var(--text-muted);
}

/* Mobile toggle — oculto en escritorio */
.hm-mobile-toggle {
    display: none;
}

.hm-hamburger {
    width: 24px;
    height: 18px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-shrink: 0;
}

.hm-hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: all var(--transition-fast);
}

.hm-mobile-toggle.active .hm-hamburger span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hm-mobile-toggle.active .hm-hamburger span:nth-child(2) {
    opacity: 0;
}

.hm-mobile-toggle.active .hm-hamburger span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Mobile Nav Overlay */
.hm-mobile-nav {
    display: none;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 998;
    overflow-y: auto;
    padding: 24px;
}

.hm-mobile-nav.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.hm-mobile-search {
    margin-bottom: 24px;
}

.hm-mobile-search .hm-search-input {
    width: 100%;
}

.hm-mobile-nav-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hm-mobile-nav-group {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.hm-mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.hm-mobile-nav-link:hover {
    background: rgba(249, 115, 22, 0.1);
    color: var(--accent);
}

.hm-mobile-nav-link svg {
    width: 24px;
    height: 24px;
    color: var(--accent);
}

.hm-mobile-chevron {
    margin-left: auto;
    transition: transform var(--transition-fast);
    color: var(--text-muted) !important;
}

.hm-mobile-nav-group.open .hm-mobile-chevron {
    transform: rotate(180deg);
    color: var(--accent) !important;
}

.hm-mobile-sub-links {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
    padding-left: 56px;
}

.hm-mobile-nav-group.open .hm-mobile-sub-links {
    max-height: 2000px;
}

.hm-mobile-sub-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.hm-mobile-sub-link:hover {
    color: var(--accent);
    background: rgba(249, 115, 22, 0.06);
}

.hm-mobile-sub-link--all {
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 4px;
}

.hm-mobile-sub-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .hm-mega-subcategory-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .hm-mega-menu-categories {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .hm-topbar {
        display: none;
    }

    .hm-navbar {
        height: auto;
        padding: 12px 0;
    }

    /*
     * CSS GRID — 3 filas
     *
     * Orden real en el HTML:
     *   1. .hm-logo
     *   2. .hm-categories-trigger  ← se oculta (display:none), no ocupa área
     *   3. .hm-search
     *   4. .hm-nav-actions
     *   5. .hm-mobile-toggle
     *
     * Resultado visual:
     *   ┌──────────────────────────┐
     *   │   HERRAMIENTAS MAIT...   │  logo (centrado)
     *   ├──────────────────────────┤
     *   │  [Buscar...          🔍] │  search (ancho completo)
     *   ├──────────────────┬───────┤
     *   │ ☰  Categorías   │ 👤 🛒 │  toggle izq | acciones der
     *   └──────────────────┴───────┘
     */
    .hm-navbar .container {
        display: grid;
        grid-template-areas:
            "logo    logo    logo"
            "search  search  search"
            "cattrig cattrig actions";
        grid-template-columns: 1fr 1fr auto;
        grid-template-rows: auto auto auto;
        gap: 10px;
        height: auto;
        align-items: center;
    }

    /* ─── Asignación de áreas (clave que faltaba) ─── */
    .hm-logo          { grid-area: logo;    }
    .hm-search        { grid-area: search;  }
    .hm-mobile-toggle { grid-area: cattrig; }
    .hm-nav-actions   { grid-area: actions; }

    /* Botón escritorio y mega menú: fuera del grid */
    .hm-categories-trigger { display: none !important; }
    .hm-mega-menu          { display: none !important; }

    /* ── Fila 1: Logo centrado ── */
    .hm-logo {
        justify-content: center;
        gap: 8px;
    }

    .hm-logo-img {
        height: 55px;
    }

    /* ── Fila 2: Barra de búsqueda ── */
    .hm-search {
        display: block !important;
        width: 100%;
        max-width: 100%;
    }

    /* ── Fila 3 izquierda: Botón Categorías móvil ── */
    .hm-mobile-toggle {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        padding: 9px 14px;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        color: var(--text);
        font-family: var(--font-body);
        font-size: 0.88rem;
        font-weight: 600;
        cursor: pointer;
        transition: all var(--transition-fast);
        justify-content: flex-start;
    }

    .hm-mobile-toggle:hover {
        border-color: var(--accent);
        background: rgba(249, 115, 22, 0.1);
    }

    .hm-mobile-toggle-text {
        font-size: 0.88rem !important;
        margin-left: 0 !important;
    }

    /* ── Fila 3 derecha: Carrito + Usuario ── */
    .hm-nav-actions {
        display: flex !important;
        align-items: center;
        gap: 4px;
        justify-content: flex-end;
    }

    .hm-nav-action {
        padding: 6px;
    }

    .hm-nav-action svg {
        width: 26px;
        height: 26px;
    }

    .hm-nav-action-label {
        display: none;
    }

    .hm-cart-count {
        min-width: 18px;
        height: 18px;
        font-size: 0.65rem;
        left: 14px;
        top: 0;
    }
}

@media (min-width: 1200px) {
    .hm-nav-action-label {
        display: inline;
    }
}