/* Marketplace Generalista - Estilos Principales */

:root {
    --primary-color: #02101f;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --border-radius: 0.375rem;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --transition: all 0.3s ease;
}

/* Reset y Base */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background-color: transparent;
    transition: transform 0.3s ease-in-out;
}

.header.header-hidden {
    transform: translateY(-100%);
}

/* Compensar el espacio del header fijo */
body {
    padding-top: 0;
}

body.has-fixed-header {
    padding-top: 180px; /* Desktop: header con nav */
}

@media (max-width: 991px) {
    body.has-fixed-header {
        padding-top: 200px; /* Tablet: header más alto */
    }
}

@media (max-width: 767px) {
    body.has-fixed-header {
        padding-top: 210px; /* Mobile: header completo */
    }
}

@media (max-width: 576px) {
    body.has-fixed-header {
        padding-top: 190px; /* Small mobile */
    }
}

/* Asegurar que el main-content no tenga margen negativo */
.main-content {
    position: relative;
    z-index: 1;
}

/* Proteger el footer de cambios de layout */
.footer .row {
    display: flex !important;
    flex-wrap: wrap !important;
}

.footer .col-4,
.footer .col-6,
.footer .col-md-6,
.footer .col-lg-2,
.footer .col-lg-4 {
    flex-shrink: 0 !important;
}

.top-bar {
    font-size: 0.875rem;
    position: relative;
    z-index: 1030;
    background: linear-gradient(135deg, #02101f 0%, #001a3d 100%);
}

.main-header {
    border-bottom: 1px solid #dee2e6;
    position: relative;
    z-index: 1020;
    background-color: white;
}

.navbar {
    position: relative;
    background-color: #f8f9fa;
}

/* Dropdowns del header - máxima prioridad */
.header .dropdown-menu {
    z-index: 9999 !important;
    position: absolute !important;
    will-change: transform;
    transform: translate3d(0, 0, 0);
}

/* Dropdowns del top-bar (idioma, país) */
.top-bar .dropdown-menu {
    z-index: 10000 !important;
}

/* Dropdown del menú de usuario - SOLUCIÓN SIMPLE */
.user-dropdown {
    position: relative !important;
    z-index: 99999 !important;
}

.user-dropdown-menu {
    z-index: 99999 !important;
    position: absolute !important;
    top: 100% !important;
    right: 0 !important;
    min-width: 200px !important;
    margin-top: 0 !important;
    border: 1px solid rgba(0,0,0,.15) !important;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.175) !important;
}

.main-header .dropdown-menu {
    z-index: 10001 !important;
}

/* Forzar que el dropdown del usuario esté siempre visible */
.user-dropdown-menu.show {
    display: block !important;
    z-index: 99999 !important;
    position: absolute !important;
}

/* SOBRESCRIBIR BOOTSTRAP COMPLETAMENTE */
.user-dropdown-menu[data-bs-popper] {
    z-index: 99999 !important;
    position: absolute !important;
    top: 100% !important;
    right: 0 !important;
    left: auto !important;
    transform: none !important;
    margin: 0 !important;
}

/* Asegurar que no se vea afectado por ningún contenedor */
.header .user-dropdown,
.main-header .user-dropdown {
    position: relative !important;
    z-index: 99999 !important;
}

.header .user-dropdown-menu,
.main-header .user-dropdown-menu {
    z-index: 99999 !important;
    position: absolute !important;
}

/* Evitar layout shift en dropdowns */
.header .dropdown {
    position: relative;
}

.header .dropdown-toggle {
    position: relative;
    z-index: 1;
}

/* Prevenir movimiento al abrir dropdown */
.header .dropdown-toggle::after {
    display: inline-block;
    margin-left: 0.5em;
    vertical-align: middle;
    content: "";
    border-top: 0.3em solid;
    border-right: 0.3em solid transparent;
    border-bottom: 0;
    border-left: 0.3em solid transparent;
}

/* Hacer que el dropdown aparezca sin animación que cause shift */
.header .dropdown-menu.show {
    display: block;
    animation: none !important;
    transform: translate3d(0, 0, 0) !important;
}

.navbar-brand img {
    max-height: 70px;
}

.search-form .input-group {
    max-width: 500px;
}

/* Menú multinivel de categorías */
.dropdown-submenu {
    position: relative;
}

.dropdown-submenu > .dropdown-menu {
    top: 0;
    left: 100%;
    margin-top: -1px;
    min-width: 200px;
    z-index: 1050 !important;
}

.dropdown-submenu:hover > .dropdown-menu {
    display: block;
}

.dropdown-submenu > .dropdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dropdown-submenu > .dropdown-item:hover {
    background-color: #f8f9fa;
}

/* Prevenir layout shift en dropdowns - global */
.dropdown-menu {
    margin-top: 0 !important;
    animation: none !important;
    margin-bottom: 0 !important;
}

.dropdown-toggle::after {
    vertical-align: middle;
    transition: none !important;
}

/* Asegurar posicionamiento absoluto de dropdowns */
.dropdown-menu[data-bs-popper] {
    position: absolute !important;
    inset: auto !important;
}

/* Responsive: en móvil el submenú se muestra debajo */
@media (max-width: 992px) {
    .dropdown-submenu > .dropdown-menu {
        position: static;
        float: none;
        width: 100%;
        margin-left: 1rem;
        border: none;
        box-shadow: none;
    }
    
    .dropdown-submenu > .dropdown-item i {
        transform: rotate(90deg);
    }
}

/* Product Cards */
.product-card {
    transition: var(--transition);
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    overflow: hidden;
    position: relative;
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.2);
    border-color: var(--primary-color);
}

.product-card .card-img-top {
    height: 220px;
    object-fit: contain;
    transition: var(--transition);
    padding: 1rem;
    background: #fff;
}

.product-card:hover .card-img-top {
    transform: scale(1.08);
}

.product-actions {
    opacity: 0;
    transition: var(--transition);
}

.product-card:hover .product-actions {
    opacity: 1;
}

.product-actions .btn {
    backdrop-filter: blur(10px);
}

.price {
    font-weight: 600;
}

.add-to-cart {
    transition: var(--transition);
}

.add-to-cart:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Category Cards */
.category-card {
    transition: var(--transition);
    background: white;
    cursor: pointer;
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border-color: var(--primary-color) !important;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
}

.category-card img {
    transition: var(--transition);
}

.category-card:hover img {
    transform: scale(1.1);
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
    position: relative;
    overflow: hidden;
    min-height: 600px;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('/assets/images/hero-pattern.png') repeat;
    opacity: 0.05;
}

.hero-section .container {
    position: relative;
    z-index: 1;
}

.hero-section .badge {
    animation: fadeIn 0.8s ease-in 0.2s both;
}

.hero-section h1 {
    animation: slideInLeft 0.8s ease-out 0.4s both;
}

.hero-section .lead {
    animation: slideInLeft 0.8s ease-out 0.6s both;
}

.hero-section .btn {
    animation: fadeIn 0.8s ease-in 0.8s both;
}

/* Features Section */
.feature-card {
    text-align: center;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    height: 100%;
}

.feature-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.2);
}

.feature-card i {
    color: var(--primary-color);
    transition: var(--transition);
}

.feature-card:hover i {
    transform: scale(1.1);
}

/* Testimonials */
.testimonials .card {
    transition: var(--transition);
}

.testimonials .card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.15);
}

/* Newsletter */
.newsletter-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
}

.newsletter-form .input-group {
    max-width: 400px;
}

/* Stats Section */
.stat-item {
    text-align: center;
}

.stat-item h3 {
    font-size: 2.5rem;
    font-weight: 700;
}

/* Footer */
.footer {
    margin-top: auto;
}

.social-links a {
    transition: var(--transition);
}

.social-links a:hover {
    transform: translateY(-2px);
}

/* Buttons */
.btn {
    border-radius: var(--border-radius);
    font-weight: 500;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #0056b3;
    border-color: #0056b3;
    transform: translateY(-1px);
}

/* Forms */
.form-control {
    border-radius: var(--border-radius);
    border: 1px solid #ced4da;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Alerts */
.alert {
    border-radius: var(--border-radius);
    border: none;
}

/* Badges */
.badge {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Pagination */
.pagination .page-link {
    border-radius: var(--border-radius);
    margin: 0 2px;
    border: 1px solid #dee2e6;
    color: var(--primary-color);
}

.pagination .page-link:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Breadcrumb */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: ">";
    color: #6c757d;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

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

/* Responsive */
@media (max-width: 991px) {
    .hero-section {
        min-height: auto;
    }
    
    .hero-section h1 {
        font-size: 2.5rem;
    }
    
    .hero-section .lead {
        font-size: 1.1rem;
    }
}

@media (max-width: 768px) {
    .hero-section {
        padding: 3rem 0 !important;
    }
    
    .hero-section h1 {
        font-size: 2rem;
    }
    
    .hero-section .lead {
        font-size: 1rem;
    }
    
    .hero-section .badge {
        font-size: 0.75rem;
    }
    
    .search-form {
        margin-top: 1rem;
    }
    
    .product-card .card-img-top {
        height: 180px;
    }
    
    .stat-item h3 {
        font-size: 2rem;
    }
    
    .stat-item i {
        font-size: 2rem !important;
    }
}

@media (max-width: 576px) {
    .top-bar {
        display: none;
    }
    
    .hero-section {
        padding: 2rem 0 !important;
    }
    
    .hero-section h1 {
        font-size: 1.75rem;
    }
    
    .hero-section .lead {
        font-size: 0.95rem;
    }
    
    .hero-section .btn {
        font-size: 0.9rem;
        padding: 0.5rem 1rem !important;
    }
    
    .feature-card {
        margin-bottom: 1rem;
        padding: 1.5rem !important;
    }
    
    .product-card .card-img-top {
        height: 150px;
    }
    
    .category-card {
        padding: 1rem !important;
    }
    
    .category-card img {
        height: 50px !important;
    }
    
    .stat-item h3 {
        font-size: 1.5rem;
    }
    
    .stat-item i {
        font-size: 1.5rem !important;
    }
    
    .newsletter-section .card-body {
        padding: 2rem !important;
    }
    
    .newsletter-section h3 {
        font-size: 1.25rem;
    }
    
    .newsletter-section p {
        font-size: 0.9rem;
    }
}

/* Utilities */
.text-primary { color: var(--primary-color) !important; }
.bg-primary { background-color: var(--primary-color) !important; }
.border-primary { border-color: var(--primary-color) !important; }

.shadow-sm { box-shadow: var(--box-shadow) !important; }
.shadow { box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important; }
.shadow-lg { box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175) !important; }

.rounded { border-radius: var(--border-radius) !important; }
.rounded-lg { border-radius: 0.5rem !important; }

/* Hover Lift Effect */
.hover-lift {
    transition: all 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.15) !important;
}

/* Special Offers Section */
.special-offers .product-card:hover {
    border-color: var(--danger-color);
}

.special-offers .btn-danger {
    transition: var(--transition);
}

.special-offers .btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

/* Breadcrumb Enhancements */
.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    font-size: 1.2em;
}

.breadcrumb-item a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

.breadcrumb-item a:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* Filter Cards */
.filter-card {
    background: white;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.filter-card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
}

/* View Mode Buttons */
[data-view] {
    cursor: pointer;
}

[data-view].active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Grid de productos personalizado */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 0;
    padding: 0;
}

.product-item {
    display: flex;
    width: 100%;
}

.product-item .card {
    width: 100%;
}

/* Responsive grid */
@media (max-width: 575px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

@media (min-width: 576px) and (max-width: 767px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

@media (min-width: 992px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1.5rem;
    }
}

/* Vista de lista */
.products-grid.products-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.products-grid.products-list .product-item {
    width: 100%;
}

/* Página de ofertas - SOLO cuando hay problemas */
body[data-page="offers"] #offersGrid {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 1.5rem !important;
}

body[data-page="offers"] #offersGrid > .col-6,
body[data-page="offers"] #offersGrid > .col-sm-6,
body[data-page="offers"] #offersGrid > .col-md-4,
body[data-page="offers"] #offersGrid > .col-lg-3 {
    display: flex !important;
    flex: 0 0 calc(50% - 0.75rem) !important;
    max-width: calc(50% - 0.75rem) !important;
}

@media (min-width: 576px) {
    body[data-page="offers"] #offersGrid > .col-sm-6 {
        flex: 0 0 calc(50% - 0.75rem) !important;
        max-width: calc(50% - 0.75rem) !important;
    }
}

@media (min-width: 768px) {
    body[data-page="offers"] #offersGrid > .col-md-4 {
        flex: 0 0 calc(33.333333% - 1rem) !important;
        max-width: calc(33.333333% - 1rem) !important;
    }
}

@media (min-width: 992px) {
    body[data-page="offers"] #offersGrid > .col-lg-3 {
        flex: 0 0 calc(25% - 1.125rem) !important;
        max-width: calc(25% - 1.125rem) !important;
    }
}

/* Products Grid Alternative Views */
.products-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.products-list > div {
    width: 100% !important;
    max-width: 100% !important;
}

.products-list .product-card {
    flex-direction: row !important;
    max-width: 100%;
}

.products-list .product-card .position-relative {
    flex: 0 0 200px;
    max-width: 200px;
}

.products-list .product-card .card-img-top {
    width: 100%;
    height: 200px;
    object-fit: contain;
    padding: 1rem;
}

.products-list .product-card .card-body {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 2rem;
    padding: 1.5rem;
}

.products-list .product-card .card-title {
    flex: 1;
    margin-bottom: 0;
}

.products-list .product-card .mt-auto {
    margin-top: 0 !important;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.products-list .product-card .btn {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .products-list .product-card {
        flex-direction: column !important;
    }
    
    .products-list .product-card .position-relative {
        flex: 1;
        max-width: 100%;
    }
    
    .products-list .product-card .card-body {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Badge Enhancements */
.badge.bg-danger {
    background-color: var(--danger-color) !important;
}

.badge.bg-success {
    background-color: var(--success-color) !important;
}

.badge.bg-warning {
    background-color: var(--warning-color) !important;
    color: #212529;
}

/* Category Description */
.category-description {
    line-height: 1.8;
    font-size: 1rem;
}

.category-description h2,
.category-description h3,
.category-description h4 {
    color: var(--dark-color);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.category-description p {
    margin-bottom: 1rem;
}

.category-description ul,
.category-description ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.category-description a {
    color: var(--primary-color);
    text-decoration: underline;
}

.category-description a:hover {
    color: #0056b3;
}

.category-description img {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    margin: 1rem 0;
}

/* Subcategories Toggle */
.subcategory-hidden {
    animation: fadeOut 0.3s ease-out;
}

.subcategory-hidden.d-none {
    display: none !important;
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

#toggleSubcategories {
    transition: all 0.3s ease;
}

#toggleSubcategories:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#toggleSubcategories i {
    transition: transform 0.3s ease;
}

/* Load More Button */
#loadMoreBtn {
    transition: all 0.3s ease;
}

#loadMoreBtn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(2, 16, 31, 0.3);
}

#loadMoreBtn:disabled {
    opacity: 0.7;
}

/* Load Progress Bar */
#loadProgress {
    transition: width 0.5s ease;
}

.progress {
    background-color: #e9ecef;
    border-radius: 1rem;
    overflow: hidden;
}

.progress-bar {
    background: linear-gradient(90deg, var(--primary-color) 0%, #0056b3 100%);
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-in-left {
    animation: slideInLeft 0.5s ease-out;
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

.slide-in-right {
    animation: slideInRight 0.5s ease-out;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Floating Animation */
@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Hero Image Wrapper */
.hero-image-wrapper {
    position: relative;
    animation: float 6s ease-in-out infinite;
}

.hero-image-wrapper img {
    transition: transform 0.3s ease;
}

.hero-image-wrapper:hover img {
    transform: scale(1.02);
}

/* Print Styles */
@media print {
    .header,
    .footer,
    .btn,
    .pagination {
        display: none !important;
    }
    
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }
}
