/* ============ VARIABLES Y RESET ============ */
:root {
    --primary-color: #d32f2f;
    --secondary-color: #232f3e;
    --error-color: #ff9900;
    --success-color: #4CAF50;
    --text-color: #333;
    --light-bg: #f0f2f5;
    --white: #fff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    color: var(--text-color);
    background-color: var(--light-bg);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* ============ LAYOUT HELPERS ============ */
.v-align {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.h-align {
    display: flex;
    flex-direction: row;
    width: 100%;
    justify-content: space-evenly;
    align-content: center;
}

/* ============ HEADER & NAVIGATION ============ */
header {
    background: var(--primary-color);
    color: var(--white);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.index-title {
    width: 100%;
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    span{
        color: var(--secondary-color);
    }
}

/* Sidebar */
.sidebar {
    width: 250px;
    height: 100vh;
    background: var(--secondary-color);
    color: var(--white);
    position: fixed;
    top: 0;
    left: -290px;
    transition: left 0.3s;
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    position: absolute;
    z-index: 20;
    overflow-y: scroll;
}

.sidebar.active {
    left: 0;
}

.sidebar h3 {
    color: var(--error-color);
    margin-top: 0;
}

.categories {
    list-style: none;
    padding: 0;
}

.categories li {
    margin: 10px 0;
}

.categories a {
    color: var(--white);
    text-decoration: none;
    display: block;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.3s;
}

.categories a:hover {
    background: var(--error-color);
}

.categories a:active {
    background: var(--error-color);
}

.close-btn {
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    position: absolute;
    right: 15px;
    top: 10px;
    cursor: pointer;
}

.menu-btn {
    margin-left: 20px;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.2rem;
    cursor: pointer;
    margin-right: 10px;
}

/* ============ MAIN CONTENT ============ */
.main-content {
    transition: margin-left 0.3s;
    min-height: 100vh;
}

/* Search */
.search-container {
    width: 100%;
    display: flex;
    flex-grow: 1;
    margin: 0 20px;
    justify-content: center;
    align-content: center;
}

.search-container input {
    width: 100%;
    max-width: 500px;
    padding: 8px;
    border: none;
    border-radius: 4px 0 0 4px;
}

.search-container button {
    background: var(--secondary-color);
    border: none;
    padding: 8px 15px;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    color: var(--white);
}

.search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid #ddd;
    border-radius: 0 0 4px 4px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 15;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.search-item {
    display: flex;
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
}

.search-item:hover {
    background: #f5f5f5;
}

.search-item img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    margin-right: 10px;
}

.search-item h4 {
    margin: 0;
    color: var(--primary-color);
    font-size: 0.9rem;
}

.search-item p {
    margin: 5px 0 0;
    color: var(--secondary-color);
    font-weight: bold;
}

.no-results, .error-results {
    padding: 10px;
    text-align: center;
    color: #666;
}

/* ============ PRODUCTS ============ */
.products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    padding: 15px;
}

.product {
    width: 180px;
    height: 280px;
    border: 1px solid #ddd;
    padding: 10px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s;
}

.product:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.product img {
    width: 100%;
    height: 120px;
    object-fit: contain;
    margin-bottom: 10px;
    background-color: #f5f5f5;
    padding: 10px;
    border-radius: 4px;
}

.product img[src="/images/default_product_image.png"] {
    object-fit: none;
    background-color: #e0e0e0;
    padding: 20px;
}

.product h3, .product p {
    margin: 5px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* ============ BUTTONS ============ */
.btn {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 0 auto 0;
    padding: 14px 20px;
    font-size: 1.1rem;
    background-color: var(--secondary-color);
    color: #111;
    border: 1px solid #a88734;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.3s ease;
    text-align: center;
}

.btn:hover {
    background-color: #e2b33b;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.btn:disabled {
    background-color: rgba(0, 0, 0, 0);
    border-color: rgba(0, 0, 0, 0);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    font-size: 20px;
    position: relative;
    color: #9a2617;
    top: 40px;
    padding: 0;
}

.view-product-btn {
    background: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 8px;
    cursor: pointer;
    width: calc(100% - 20px);
    position: absolute;
    bottom: 10px;
    left: 10px;
    font-weight: bold;
    transition: background 0.3s;
}

.view-product-btn:hover {
    background: var(--secondary-color);
}

.cart-button {
    display: none;
    color: var(--white);
    text-decoration: none;
    font-size: 0.9rem;
}

/* ============ AUTHENTICATION ============ */
.auth-buttons {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #444;
}

.auth-btn {
    display: block;
    color: var(--white);
    text-decoration: none;
    padding: 10px 15px;
    margin: 5px 0;
    border-radius: 4px;
    transition: background 0.3s;
}

.auth-btn:hover {
    background: var(--secondary-color);
}

.auth-btn i {
    margin-right: 8px;
}

/* ============ BOTONES ESPECIALES ============ */
.header-buttons {
    display: flex;
    gap: 15px;
    margin: 10px 0;
    justify-content: center;
    flex-wrap: wrap;
}

.cart-button, .publish-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.3s;
}

.cart-button {
    background-color: var(--secondary-color);
    color: white;
    border: 1px solid #a88734;
}

.cart-button:hover {
    background-color: #37475a;
}

.publish-button {
    background-color: var(--primary-color);
    color: white;
    border: 1px solid #9a2617;
}

.publish-button:hover {
    background-color: #b12704;
}

/* ============ MENSAJE SIN PRODUCTOS ============ */
.no-products {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    font-size: 1.2rem;
    color: #666;
    background: #f9f9f9;
    border-radius: 8px;
    margin: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Estilo para la categoría activa */
.categories li a.active {
    background-color: var(--error-color);
    color: white;
}

/* ============ MENSAJES DE ESTADO ============ */
.loading-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    font-size: 1.2rem;
    color: #666;
}

.error-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    font-size: 1.2rem;
    color: #d32f2f;
    background: #ffebee;
    border-radius: 8px;
    margin: 20px;
}

/* ============ POPUP DE PROVINCIA ============ */
.provincia-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.provincia-popup .popup-content {
    background-color: var(--white);
    padding: 30px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.provincia-popup h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.provincia-popup p {
    margin-bottom: 20px;
    color: var(--text-color);
}

.provincia-select {
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.confirm-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.confirm-btn:hover {
    background-color: #b71c1c;
}

.confirm-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Estilos para la alerta de provincia */
.provincia-alert {
    background-color: var(--error-color);
    color: var(--white);
    padding: 10px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 2;
    display: none;
    justify-content: center;
    align-items: center;
    gap: 15px;
    width: 100%;
    font-size: 14px;
}

.provincia-alert #change-provincia {
    color: white;
    text-decoration: underline;
    cursor: pointer;
    font-weight: bold;
}

.provincia-alert #change-provincia:hover {
    color: #ffcccc;
}

.cerrar-alerta {
    background: none;
    border: none;
    color: var(--white);
    font-size: 20px;
    cursor: pointer;
    padding: 0 10px;
}

.cerrar-alerta:hover {
    color: #ffcccc;
}

/* ============ MEDIA QUERIES ============ */
@media (max-width: 768px) {
    .sidebar {
        width: 200px;
        height: 100vh;
        z-index: 20;
    }
    
    .products {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .search-container {
        margin: 0 10px;
    }
    
    .header-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .cart-button, .publish-button {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    header {
        flex-wrap: wrap;
        padding: 10px;
    }
    
    .search-container {
        order: 3;
        width: 100%;
        margin: 10px 0 0;
    }
    
    .products {
        display: flex;
        flex-wrap: wrap;
    }
    
    .product {
        margin: auto;
        width: 45%;
        padding: 2.5%;
    }
}

/* ============ PRODUCT METRICS ============ */
.product-metrics {
    display: flex;
    flex-direction: column;
    margin-top: -4px;
    font-size: 0.8rem;
    color: #666;
    height: 0;
    height: 10px;

}

.metric {
    display: flex;
    align-items: center;
    gap: 3px;
}

.metric i {
    color: var(--secondary-color);
    font-size: 0.9rem;
}

.rating-stars {
    color: #ffc107;
    margin-right: 3px;
}

.sales-count {
    color: #666;
}

.rating-stars .half-star {
    position: relative;
    display: inline-block;
    color: #ffc107;
}

.rating-stars .half-star:before {
    content: '★';
    position: absolute;
    left: 0;
    width: 50%;
    overflow: hidden;
    color: #ffc107;
}

.rating-stars .half-star:after {
    content: '☆';
    color: #ffc107;
}

/* Agregar esto al final de index.css */
.product-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: bold;
    color: white;
    z-index: 1;
}

.badge-local {
    background-color: var(--success-color);
    border: 1px solid #2e7d32;
}

.badge-import {
    background-color: var(--secondary-color);
    border: 1px solid #1a237e;
}

/* ============ LOGO STYLES ============ */
.header-container {
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: space-between;
}

.logo-container {
    display: flex;
    align-items: center;
    margin-right: 15px;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo-img {
    height: 40px; /* Altura inicial del logo */
    width: auto;
    object-fit: contain;
    transition: all 0.3s ease;
}

/* Ajustes para pantallas más grandes */
@media (min-width: 768px) {
    .logo-img {
        height: 50px; /* Logo más grande en pantallas mayores */
    }
    
    .header-container {
        justify-content: flex-start;
    }
}

/* Ajustes para pantallas pequeñas */
@media (max-width: 480px) {
    .logo-img {
        height: 35px; /* Logo un poco más pequeño en móviles */
    }
    
    .menu-btn {
        margin-left: 10px;
    }
}

/* Asegurar que el título no se muestre cuando el logo está presente */
.index-title {
    display: none;
}

/* Mostrar el título solo si el logo no carga */
.logo-link:not([href*="logo.jpg"]) + .index-title {
    display: block;
}


/* ============ LOGO BANNER ============ */
.logo-banner {
    background: var(--primary-color);
    padding-bottom: 5px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
    z-index: 5;
    width: 100%;
    display: flex;
    flex-direction: row;
    margin: 0;
    margin-bottom: 20px;
    
}

.logo-container {
    max-width: 1200px;
    margin: 0;
    padding: 0 15px;
    display: flex;
    margin-right: 15px;
    justify-content: space-evenly;
}

.logo-img {
    height: 70px;
    width: auto;
    object-fit: contain;
    transition: all 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

/* Efecto hover sutil */
.logo-img:hover {
    transform: scale(1.03);
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.25));
}

/* Ajustes responsivos */
@media (max-width: 768px) {
    .logo-img {
        height: 100px;
        width: 300;
    }
    .logo-banner {
        padding: 20px 0;
        margin-bottom: 0px;
    }

}

@media (max-width: 480px) {
    .logo-img {
        height: 40px;
    }
}

/* Ajustar el header para que no quede pegado al logo */
header {
    margin-top: 0;
    padding: 0;
}