/* Header Unificado - Estilos Principales */

/* Header principal - estilos principales complementarios */
.header {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 0;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.header-top {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    gap: 12px;
    min-height: 56px;
    flex-wrap: nowrap;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: transform 0.2s ease;
    flex-shrink: 0;
    white-space: nowrap;
    z-index: 10;
}

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

.logo-image {
    height: 60px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    letter-spacing: -0.3px;
    line-height: 1;
    white-space: nowrap;
}

/* Search Container - Estilo Wallapop */
.search-container {
    flex: 1;
    max-width: 600px;
    margin: 0 12px;
}

.search-icon-left {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    pointer-events: none;
    z-index: 1;
}

.search-form {
    position: relative;
    width: 100%;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: none;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.95);
    color: #1f2937;
    font-size: 15px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.search-input::placeholder {
    color: #9ca3af;
}

.search-input:focus {
    outline: none;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Botón menú móvil */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.mobile-menu-btn:hover {
    opacity: 0.8;
    transform: scale(1.1);
}

/* Menú móvil lateral */
.mobile-menu-overlay {
    display: none !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10002;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.mobile-menu-content {
    position: absolute;
    top: 0;
    right: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    max-height: 100vh;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    display: none;
    flex-direction: column;
}

.mobile-menu-overlay.active .mobile-menu-content {
    transform: translateX(0);
}

.mobile-menu-header {
    display: none !important;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #1877f2 0%, #42a5f5 100%);
    color: white;
    flex-shrink: 0;
}

.mobile-menu-header .mobile-menu-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.mobile-menu-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.2s ease;
}

.mobile-menu-close:hover {
    transform: rotate(90deg);
}

.mobile-menu-body {
    display: none;
    padding: 12px 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: #1f2937;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 16px;
    font-weight: 500;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    position: relative;
}

.mobile-menu-item:hover,
.mobile-menu-item:active {
    background: #f3f4f6;
}

.mobile-menu-item i:first-child {
    width: 20px;
    text-align: center;
    color: #6b7280;
    font-size: 18px;
}

.mobile-menu-item span {
    flex: 1;
}

.mobile-menu-item i:last-child {
    color: #9ca3af;
    font-size: 14px;
}

.mobile-menu-badge {
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.mobile-menu-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 12px 20px;
}

.desktop-only {
    display: flex;
}

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

/* Categories Dropdown */
.categories-dropdown {
    position: relative;
}

.categories-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.categories-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.dropdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.dropdown-overlay.show {
    opacity: 1;
    visibility: visible;
}

.category-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-width: 300px;
    max-width: 500px;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.category-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 20px 25px 15px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.dropdown-close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: transparent;
    border: none;
    color: #6b7280;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.dropdown-close-btn:hover {
    background: #f3f4f6;
    color: #1f2937;
}

@media (max-width: 768px) {
    .dropdown-close-btn.mobile-only {
        display: flex !important;
    }
    
    .dropdown-title {
        padding-right: 40px;
    }
}

.dropdown-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
}

.auth-modal-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
}

/* Slider horizontal de categorías en móvil */
.categories-slider-container {
    display: none;
    padding: 15px 0;
    margin-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
}

.categories-slider {
    display: flex;
    gap: 12px;
    padding: 0 20px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.categories-slider::-webkit-scrollbar {
    display: none;
}

.category-slider-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    min-width: 80px;
    text-decoration: none;
    color: #374151;
    border-radius: 12px;
    background: #f9fafb;
    transition: all 0.2s ease;
    scroll-snap-align: start;
    flex-shrink: 0;
}

.category-slider-item:active {
    background: #f3f4f6;
    transform: scale(0.95);
}

.category-slider-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border-radius: 12px;
    color: white;
    font-size: 24px;
}

.category-slider-name {
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
    max-width: 80px;
}

.dropdown-categories {
    padding: 15px 25px 25px;
    max-height: 400px;
    overflow-y: auto;
}

.mobile-only {
    display: none;
}

.category-section {
    margin-bottom: 20px;
}

.category-section:last-child {
    margin-bottom: 0;
}

.category-section-title {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.category-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    color: #374151;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 14px;
    margin-bottom: 4px;
}

.category-link:hover {
    background: #f3f4f6;
    color: #1f2937;
    transform: translateX(4px);
}

.category-link i {
    width: 16px;
    text-align: center;
    color: #6b7280;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-dropdown {
    position: relative;
}

.user-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.user-name {
    font-weight: 600;
}

.user-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
    margin-top: 8px;
}

.user-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 45px 12px 20px;
    color: #374151;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    position: relative;
}

.dropdown-item:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.dropdown-item i {
    width: 16px;
    text-align: center;
    color: #6b7280;
}

/* Auth Buttons */
.auth-buttons {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-auth, .btn-publish {
    padding: 10px 18px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 14px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-auth {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-auth:hover {
    background: rgba(255, 255, 255, 0.25);
    color: white;
    transform: translateY(-1px);
}

.btn-publish {
    background: #10b981;
    color: white;
    border: 1px solid #10b981;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
}

.btn-publish:hover {
    background: #059669;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-publish-dropdown {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #10b981;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    margin-bottom: 8px;
}

.btn-publish-dropdown:hover {
    background: #059669;
    color: white;
    transform: translateY(-1px);
}

/* Cuando el usuario está logueado - layout con botón publicar y menú usuario */
.user-menu:has(.btn-publish) {
    display: flex;
    gap: 12px;
    align-items: center;
}

.user-menu:has(.btn-publish) .user-dropdown {
    margin-left: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .mobile-menu-overlay {
        display: block !important;
    }
    
    .mobile-menu-content {
        display: flex !important;
    }
    
    .header-top {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 8px;
        padding: 10px 0;
        align-items: center;
        justify-content: space-between;
    }
    
    .logo {
        flex-shrink: 0;
        min-width: fit-content;
    }
    
    .logo-image {
        height: 32px;
    }
    
    .logo-text {
        font-size: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100px;
    }
    
    .search-container {
        flex: 1;
        margin: 0 6px;
        min-width: 0;
        flex-shrink: 1;
    }
    
    .search-input {
        font-size: 14px;
        padding: 8px 12px 8px 36px;
    }
    
    .search-icon-left {
        left: 12px;
        font-size: 14px;
    }
    
    .mobile-menu-btn {
        display: block;
        flex-shrink: 0;
        min-width: 36px;
    }
    
    .desktop-only {
        display: none !important;
    }
    
    .category-dropdown-menu {
        min-width: 280px;
        max-width: 90vw;
        position: fixed !important;
        z-index: 10000 !important;
    }
    
    .category-dropdown-menu.show {
        transform: translate(-50%, -50%) !important;
    }
    
    .dropdown-overlay {
        display: block !important;
    }
    
    .mobile-only {
        display: block !important;
    }
    
    .desktop-only {
        display: none !important;
    }
    
    .mobile-menu-header {
        display: flex !important;
    }
    
    .mobile-menu-body {
        display: block !important;
    }
    
    .categories-slider-container {
        display: block !important;
    }
    
    .dropdown-categories {
        max-height: 50vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* El slider debe funcionar siempre en móvil */
    .categories-slider {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        scroll-behavior: smooth;
    }
    
    .user-dropdown-menu {
        right: -20px;
        min-width: 180px;
    }
}

@media (max-width: 480px) {
    .header-content {
        padding: 0 12px;
    }
    
    .header-top {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        padding: 8px 0;
        min-height: 52px;
        gap: 6px;
        align-items: center;
        justify-content: space-between;
    }
    
    .logo {
        flex-shrink: 0;
        min-width: fit-content;
    }
    
    .logo-image {
        height: 28px;
    }
    
    .logo-text {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 80px;
    }
    
    .search-container {
        flex: 1;
        margin: 0 4px;
        min-width: 0;
        flex-shrink: 1;
    }
    
    .search-input {
        font-size: 13px;
        padding: 7px 10px 7px 32px;
        border-radius: 18px;
    }
    
    .search-icon-left {
        left: 10px;
        font-size: 13px;
    }
    
    .mobile-menu-btn {
        font-size: 18px;
        padding: 6px;
        flex-shrink: 0;
        min-width: 32px;
    }
}
