/**
 * SAMA VINTAGE - Header
 * Navegación principal, logo, acciones y menú responsive
 * Versión: 1.0.0
 */

/* ============================================
   VARIABLES DEL HEADER
   ============================================ */

:root {
    --header-bg: #ffffff;
    --header-border: #e5e5e5;
    --header-text: #1a1a1a;
    --header-text-light: #666666;
    --header-primary: #8B1E2D;
    --header-height: 70px;
    --header-z-index: 1000;
    --transition-fast: 150ms ease;
    --transition-base: 300ms ease;
}

/* ============================================
   HEADER PRINCIPAL
   ============================================ */

.sama-header {
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    position: sticky;
    top: 0;
    z-index: var(--header-z-index);
    width: 100%;
    transition: box-shadow var(--transition-base);
}

.sama-header.scrolled {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    position: relative;
}

/* ============================================
   BOTÓN MENÚ HAMBURGUESA
   ============================================ */

.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 30px;
    height: 30px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
    order: -1;
}

.hamburger-line {
    width: 100%;
    height: 2px;
    background: var(--header-text);
    transition: all var(--transition-base);
    transform-origin: center;
    display: block;
    border-radius: 1px;
}

/* Animación a X */
.menu-toggle.active .hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active .hamburger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ============================================
   NAVEGACIÓN PRINCIPAL
   ============================================ */

.main-nav {
    flex: 1;
    display: block;
}

.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 2rem;
}

.nav-menu li {
    margin: 0;
    padding: 0;
}

.nav-menu a {
    text-decoration: none;
    color: var(--header-text);
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    transition: color var(--transition-base);
    display: block;
    padding: 0.5rem 0;
}

.nav-menu a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--header-primary);
    transition: width var(--transition-base);
}

.nav-menu a:hover {
    color: var(--header-primary);
}

.nav-menu a:hover::after {
    width: 100%;
}

/* Botón cerrar (solo móvil) */
.menu-close {
    display: none;
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--header-text);
    width: 40px;
    height: 40px;
    line-height: 1;
    padding: 0;
    z-index: 1002;
}

/* ============================================
   LOGO
   ============================================ */

.logo {
    flex-shrink: 0;
}

.logo a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--header-text);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--header-text);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    font-weight: 600;
    flex-shrink: 0;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-name {
    font-family: 'Playfair Display', serif;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    line-height: 1;
    color: var(--header-text);
}

.logo-tagline {
    font-size: 0.6875rem;
    color: var(--header-text-light);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 2px;
}

/* ============================================
   ACCIONES DEL HEADER
   ============================================ */

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--header-text);
    transition: color var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    position: relative;
    border-radius: 4px;
}

.icon-btn:hover {
    color: var(--header-primary);
    background: rgba(139, 30, 45, 0.05);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

/* Carrito con contador */
.cart-btn {
    position: relative;
}

.cart-count {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--header-primary);
    color: #fff;
    font-size: 0.65rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    opacity: 0;
    transform: scale(0);
    transition: all var(--transition-fast);
}

.cart-count.visible {
    opacity: 1;
    transform: scale(1);
}

/* ============================================
   OVERLAY DE BÚSQUEDA
   ============================================ */

.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.98);
    z-index: 2000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 20vh;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

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

.search-container {
    width: 90%;
    max-width: 600px;
    position: relative;
}

.search-form {
    display: flex;
    gap: 1rem;
    border-bottom: 2px solid var(--header-text);
    padding-bottom: 1rem;
}

.search-input {
    flex: 1;
    border: none;
    background: none;
    font-size: 1.5rem;
    font-family: 'Playfair Display', serif;
    outline: none;
    color: var(--header-text);
}

.search-input::placeholder {
    color: var(--header-text-light);
}

.search-submit {
    background: var(--header-primary);
    color: #fff;
    border: none;
    padding: 0.75rem 2rem;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.875rem;
    transition: background var(--transition-base);
    font-weight: 500;
    border-radius: 4px;
}

.search-submit:hover {
    background: var(--header-primary-dark);
}

.search-close {
    position: absolute;
    top: -3rem;
    right: 0;
    background: none;
    border: none;
    font-size: 2.5rem;
    cursor: pointer;
    color: var(--header-text);
    line-height: 1;
    padding: 0;
    width: 40px;
    height: 40px;
    transition: color var(--transition-fast);
}

.search-close:hover {
    color: var(--header-primary);
}

/* ============================================
   RESPONSIVE: TABLET Y MÓVIL
   ============================================ */

@media screen and (max-width: 1024px) {
    .header-container {
        padding: 0 1rem;
        gap: 1rem;
    }
    
    /* Mostrar hamburguesa */
    .menu-toggle {
        display: flex;
    }
    
    /* Ocultar navegación normal, convertir en drawer */
    .main-nav {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 320px;
        height: 100vh;
        height: 100dvh;
        background: var(--header-bg);
        z-index: 999;
        transition: left var(--transition-base);
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.2);
        padding: 4rem 2rem 2rem;
        flex: none;
        display: block;
        overflow-y: auto;
    }
    
    .main-nav.active {
        left: 0;
    }
    
    /* Overlay oscuro */
    .main-nav::after {
        content: '';
        position: fixed;
        top: 0;
        left: 100%;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: opacity var(--transition-base);
        z-index: -1;
        pointer-events: none;
    }
    
    .main-nav.active::after {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
    
    /* Menú en vertical */
    .nav-menu {
        flex-direction: column;
        gap: 0;
        width: 100%;
    }
    
    .nav-menu li {
        width: 100%;
        border-bottom: 1px solid var(--header-border);
    }
    
    .nav-menu li:last-child {
        border-bottom: none;
    }
    
    .nav-menu a {
        font-size: 1.1rem;
        display: block;
        padding: 1.25rem 0;
        width: 100%;
    }
    
    .nav-menu a::after {
        display: none;
    }
    
    /* Botón cerrar visible */
    .menu-close {
        display: block;
    }
    
    /* Ajustes logo */
    .logo-icon {
        width: 35px;
        height: 35px;
        font-size: 1.125rem;
    }
    
    .logo-name {
        font-size: 1rem;
        letter-spacing: 1px;
    }
    
    /* Ajustes acciones */
    .header-actions {
        gap: 0.5rem;
    }
    
    .icon-btn svg {
        width: 22px;
        height: 22px;
    }
}

@media screen and (max-width: 480px) {
    .header-container {
        padding: 0 0.75rem;
        height: 60px;
    }
    
    .logo-tagline {
        display: none;
    }
    
    .logo-name {
        font-size: 0.9rem;
        letter-spacing: 1px;
    }
    
    .logo-icon {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    
    .menu-toggle {
        width: 25px;
        height: 25px;
        gap: 4px;
    }
    
    .hamburger-line {
        height: 1.5px;
    }
    
    .header-actions {
        gap: 0.25rem;
    }
    
    .icon-btn {
        padding: 0.35rem;
    }
    
    .icon-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .cart-count {
        width: 16px;
        height: 16px;
        font-size: 0.65rem;
        top: -1px;
        right: -1px;
    }
    
    .main-nav {
        width: 85%;
        padding: 3.5rem 1.5rem 1.5rem;
    }
    
    .nav-menu a {
        font-size: 1rem;
        padding: 1rem 0;
    }
    
    .search-form {
        flex-direction: column;
        gap: 1rem;
        border-bottom: none;
    }
    
    .search-input {
        font-size: 1.25rem;
        text-align: center;
        border-bottom: 2px solid var(--header-text);
        padding-bottom: 0.5rem;
    }
    
    .search-submit {
        width: 100%;
    }
    
    .search-close {
        top: -2.5rem;
    }
}