/*
========================================================================
MAIN CSS - TIENDA ONLINE
========================================================================
Estilos generales para la tienda online
========================================================================
*/

/* ===== VARIABLES GLOBALES ===== */
:root {
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --border-radius: 8px;
    --box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --box-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s ease;
}

/* ===== ESTILOS GENERALES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* ===== TOP BAR ===== */
.top-bar {
    font-size: 0.875rem;
}

.top-bar a {
    transition: var(--transition);
}

.top-bar a:hover {
    opacity: 0.8;
}

/* ===== NAVBAR ===== */
.navbar {
    padding: 0.5rem 0;
}

.navbar-brand {
    padding: 0.5rem 0;
}

.navbar-brand img {
    max-height: 60px;
    width: auto;
    object-fit: contain;
}

.navbar-brand:hover {
    opacity: 0.9;
}

.nav-link {
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--color-primario) !important;
}

.dropdown-item.active {
    background-color: var(--color-primario);
}

/* Botones del navbar */
.navbar .btn {
    white-space: nowrap;
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
}

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

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

/* Gap entre botones en el navbar */
.navbar-nav.gap-2 > .nav-item {
    margin-left: 0.5rem;
}

/* Responsive para navbar */
@media (max-width: 991px) {
    .navbar-brand img {
        max-height: 50px;
    }
    
    .navbar-brand strong {
        font-size: 1rem !important;
    }
    
    .navbar .btn {
        width: 100%;
        margin-top: 0.5rem;
    }
    
    .navbar-nav.gap-2 > .nav-item {
        margin-left: 0;
        width: 100%;
    }
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
    background-color: transparent;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
}

/* ===== CARDS GENERALES ===== */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    height: 100%;
}

.card:hover {
    box-shadow: var(--box-shadow-hover);
    transform: translateY(-5px);
}

.card-img-top {
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    object-fit: cover;
    height: 250px;
}

/* ===== CATEGORIAS / FAMILIAS / LINEAS ===== */
.categoria-card,
.familia-card,
.linea-card {
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
}

.categoria-card:hover,
.familia-card:hover,
.linea-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15) !important;
}

.categoria-card .card-body,
.familia-card .card-body,
.linea-card .card-body {
    padding: 1.5rem;
}

.categoria-card h3,
.familia-card h4,
.familia-card h5,
.linea-card h5 {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.familia-card .card-title a,
.linea-card .card-title a {
    transition: color 0.3s ease;
}

.familia-card:hover .card-title a,
.linea-card:hover .card-title a {
    color: var(--color-primario) !important;
}

.categoria-card img,
.familia-card img,
.linea-card img {
    transition: var(--transition);
}

.categoria-card:hover img,
.familia-card:hover img,
.linea-card:hover img {
    transform: scale(1.1);
}

/* ===== PRODUCTOS ===== */
.producto-card {
    position: relative;
}

.producto-card .badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1;
}

.producto-precio {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primario);
}

.producto-precio-anterior {
    text-decoration: line-through;
    color: #999;
    font-size: 1rem;
}

.btn-agregar-carrito {
    width: 100%;
    font-weight: 600;
}

/* ===== CARRITO ===== */
.carrito-vacio {
    text-align: center;
    padding: 4rem 2rem;
}

.carrito-vacio i {
    font-size: 5rem;
    color: #dee2e6;
    margin-bottom: 1rem;
}

.carrito-item {
    border-bottom: 1px solid #dee2e6;
    padding: 1rem 0;
}

.carrito-item:last-child {
    border-bottom: none;
}

.carrito-item img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--border-radius);
}

.carrito-resumen {
    background-color: #f8f9fa;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    position: sticky;
    top: 100px;
}

.cantidad-selector {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.cantidad-selector button {
    width: 30px;
    height: 30px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cantidad-selector input {
    width: 60px;
    text-align: center;
}

/* ===== MODAL PRODUCTO ===== */
.modal-producto .modal-dialog {
    max-width: 900px;
}

.modal-producto .product-image {
    width: 100%;
    border-radius: var(--border-radius);
}

.modal-producto .opciones-grupo {
    margin-bottom: 1.5rem;
}

.modal-producto .opcion-item {
    padding: 0.75rem;
    border: 2px solid #dee2e6;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.modal-producto .opcion-item:hover {
    border-color: var(--color-primario);
}

.modal-producto .opcion-item.active {
    border-color: var(--color-primario);
    background-color: rgba(var(--color-primario), 0.1);
}

/* ===== BOTÓN WHATSAPP FLOTANTE ===== */
.whatsapp-float {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 99999 !important;
    width: auto;
    height: 60px;
    background: linear-gradient(135deg, #25D366 0%, #20BA5A 100%);
    color: white !important;
    border-radius: 30px;
    padding: 0 20px 0 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.6);
    transition: all 0.3s ease;
    text-decoration: none !important;
    font-family: var(--font-primary);
    cursor: pointer;
}

.whatsapp-float:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 30px rgba(37, 211, 102, 0.8);
    color: white !important;
    background: linear-gradient(135deg, #20BA5A 0%, #1a9647 100%);
}

.whatsapp-float i {
    font-size: 32px;
    color: white !important;
}

.whatsapp-text {
    font-size: 15px;
    font-weight: 600;
    color: white !important;
    white-space: nowrap;
}

/* Mobile */
@media (max-width: 767px) {
    .whatsapp-float {
        bottom: 20px;
        right: 20px;
        height: 55px;
        padding: 0 16px 0 12px;
    }
    
    .whatsapp-float i {
        font-size: 28px;
    }
    
    .whatsapp-text {
        font-size: 13px;
    }
}

/* ===== LOADING SPINNER ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--color-primario);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast {
    min-width: 250px;
}

/* ===== FILTROS ===== */
.filtros-sidebar {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--box-shadow);
}

.filtros-sidebar h5 {
    font-weight: 600;
    margin-bottom: 1rem;
}

.filtros-sidebar .form-check {
    margin-bottom: 0.5rem;
}

/* ===== PAGINACIÓN ===== */
.pagination {
    margin-top: 2rem;
}

.page-link {
    color: var(--color-primario);
    border-color: #dee2e6;
}

.page-link:hover {
    color: var(--color-secundario);
    background-color: var(--color-acento);
}

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

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

/* Mobile First - Ajustes para tablets y desktop */
@media (min-width: 768px) {
    .card-img-top {
        height: 280px;
    }
}

@media (min-width: 992px) {
    .card-img-top {
        height: 300px;
    }
}

/* Ajustes específicos para móvil */
@media (max-width: 767px) {
    .navbar-brand div strong {
        font-size: 0.9rem;
    }
    
    .card-img-top {
        height: 200px;
    }
    
    .producto-precio {
        font-size: 1.25rem;
    }
    
    .btn-whatsapp {
        width: 50px;
        height: 50px;
        font-size: 24px;
        bottom: 15px;
        right: 15px;
    }
    
    .carrito-item img {
        width: 60px;
        height: 60px;
    }
    
    /* Modal full screen en móvil */
    .modal-producto .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100vh;
    }
    
    .modal-producto .modal-content {
        height: 100%;
        border-radius: 0;
    }
}

/* ===== UTILIDADES ===== */
.text-primary-custom {
    color: var(--color-primario) !important;
}

.bg-primary-custom {
    background-color: var(--color-primario) !important;
}

.border-primary-custom {
    border-color: var(--color-primario) !important;
}

.btn-primary-custom {
    background-color: var(--color-primario);
    border-color: var(--color-primario);
    color: white;
    transition: all 0.3s ease;
}

.btn-primary-custom:hover {
    background-color: #d97706;
    border-color: #d97706;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.4);
}

/* ===== SISTEMA DE BÚSQUEDA ===== */

/* Contenedor principal de búsqueda */
.search-container {
    position: relative;
    width: 100%;
}

@media (min-width: 992px) {
    .search-container {
        min-width: 400px;
    }
}

/* Input de búsqueda */
.search-container input[type="search"] {
    border: 1px solid #dee2e6;
    border-left: none;
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
}

.search-container input[type="search"]:focus {
    border-color: var(--color-primario);
    box-shadow: 0 0 0 0.15rem rgba(var(--color-primario), 0.15);
}

.search-container .input-group-text {
    border: 1px solid #dee2e6;
    border-right: none;
}

.search-container input[type="search"]:focus + .input-group-text {
    border-color: var(--color-primario);
}

/* Dropdown de resultados */
.search-results-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    max-height: 600px;
    overflow-y: auto;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1050;
    animation: slideDown 0.2s ease-out;
}

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

/* Contenedor de resultados */
.search-results-container {
    padding: 0.5rem;
}

/* Sección de resultados */
.search-section {
    margin-bottom: 0.5rem;
}

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

.search-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #6c757d;
    padding: 0.75rem 1rem 0.5rem;
    letter-spacing: 0.5px;
}

/* Sugerencias (Familias y Líneas) */
.search-suggestions {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.search-suggestion-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: #333;
    transition: all 0.2s ease;
    border-radius: 6px;
    margin: 0 0.5rem;
}

.search-suggestion-item:hover {
    background-color: #f8f9fa;
    color: var(--color-primario);
}

.suggestion-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.suggestion-meta {
    font-size: 0.8rem;
    color: #6c757d;
}

/* Productos en búsqueda */
.search-products {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.search-product-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 6px;
    margin: 0 0.5rem;
}

.search-product-item:hover {
    background-color: #f8f9fa;
}

.search-product-image {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 5px;
}

.search-product-info {
    flex: 1;
    min-width: 0;
}

.search-product-code {
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 0.25rem;
}

.search-product-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: #333;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-product-desc {
    font-size: 0.8rem;
    color: #6c757d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-product-price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primario);
    white-space: nowrap;
}

/* Resaltado de texto coincidente */
.search-product-name mark,
.suggestion-name mark {
    background-color: #fff3cd;
    color: #000;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* Estados especiales */
.search-loading,
.search-no-results,
.search-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    text-align: center;
    color: #6c757d;
}

.search-loading {
    padding: 1.5rem;
}

.search-no-results i,
.search-error i {
    margin-bottom: 0.5rem;
}

/* Footer de búsqueda */
.search-footer {
    padding: 0.75rem;
    border-top: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

.search-footer .btn {
    font-size: 0.9rem;
    font-weight: 600;
}

/* Scrollbar personalizado para resultados */
.search-results-dropdown::-webkit-scrollbar {
    width: 8px;
}

.search-results-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: var(--border-radius);
}

.search-results-dropdown::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: var(--border-radius);
}

.search-results-dropdown::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Responsive para búsqueda */
@media (max-width: 991px) {
    .search-container {
        max-width: 100%;
    }
    
    .search-results-dropdown {
        max-height: 400px;
    }
    
    .search-product-image {
        width: 50px;
        height: 50px;
    }
    
    .search-product-price {
        font-size: 0.9rem;
    }
}

@media (max-width: 575px) {
    .search-product-item {
        flex-wrap: wrap;
    }
    
    .search-product-price {
        width: 100%;
        text-align: left;
        margin-top: 0.25rem;
    }
    
    .search-results-dropdown {
        max-height: 350px;
    }
}
