:root {
    --primary-color: #3A3A3A; /* Dark Gray */
    --secondary-color: #B08D57; /* Muted Gold/Bronze */
    --accent-color: #8C6B4A; /* Darker Bronze/Brown */
    --text-color: #4F4F4F; /* Softer Dark Gray for text */
    --light-bg: #FDFBF5; /* Very Light Cream */
    --card-bg: #FFFFFF; /* White for cards */
    --border-color: #F0EAE0; /* Light beige for borders */
    --premium-font: 'Montserrat', sans-serif;
    --display-font: 'Playfair Display', serif;

    --btc-price-color: #2E7D32; /* Greenish for BTCPY1 */
    --usd-price-color: #1565C0; /* Bluish for USD */
    --category-nav-gap: 6px; /* Variable para el gap de categorías en móvil */
}

body {
    font-family: var(--premium-font);
    margin: 0;
    background-color: var(--light-bg);
    color: var(--text-color);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Estilo general del header (para desktop y pantallas grandes) */
header {
    background-color: var(--primary-color);
    color: var(--light-bg);
    padding: 20px 40px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    border-bottom: 2px solid var(--secondary-color);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo-container {
    display: flex;
    align-items: center;
}

#logo {
    height: 55px;
    margin-right: 18px;
    border-radius: 6px;
}

header h1 {
    font-family: var(--display-font);
    margin: 0;
    font-size: 2em;
    font-weight: 700;
    letter-spacing: 0.5px;
}

#category-nav {
    margin: 10px 0;
    text-align: center;
}

#category-nav button {
    background-color: transparent;
    color: var(--light-bg);
    border: 1px solid rgba(253, 251, 245, 0.7);
    padding: 9px 18px;
    margin: 7px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    border-radius: 20px;
    transition: background-color 0.25s, color 0.25s, transform 0.2s, box-shadow 0.2s;
    letter-spacing: 0.3px;
}

#category-nav button:hover,
#category-nav button.active {
    background-color: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
}
#category-nav button.active {
    font-weight: 600;
}

main {
    padding: 35px 20px;
    max-width: 1400px;
    margin: 35px auto;
}

#current-category-title {
    font-family: var(--display-font);
    text-align: center;
    margin-bottom: 45px;
    font-size: 2.6em;
    color: var(--primary-color);
}

#loading-indicator {
    text-align: center;
    padding: 35px;
    font-size: 1.4em;
    color: var(--accent-color);
    font-family: var(--display-font);
}

#error-message {
    color: #c0392b;
    text-align: center;
    padding: 20px;
    background-color: #fdecea;
    border: 1px solid #f5c6cb;
    border-radius: 5px;
    margin: 20px auto;
    max-width: 80%;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 30px;
}

.product-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(176, 141, 87, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.product-card:hover {
    transform: translateY(-6px) scale(1.01);
    box-shadow: 0 10px 25px rgba(176, 141, 87, 0.15), 0 6px 10px rgba(176, 141, 87, 0.12);
}

.product-card-image-wrapper {
    width: 100%;
    height: 250px;
    overflow: hidden;
    border-bottom: 1px solid var(--border-color);
}

.product-card-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease-out;
}

.product-card:hover .product-card-image-wrapper img {
    transform: scale(1.05);
}

.product-info {
    padding: 18px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-info h3 {
    font-size: 1em;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 8px;
    color: var(--primary-color);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.8em;
    line-height: 1.4;
}

.star-rating { margin-bottom: 8px; color: #FFB300; font-size: 0.9em; }
.star-rating .fas, .star-rating .far { margin-right: 1px; }

.product-price {
    font-size: 1.15em;
    font-weight: 700;
    color: var(--usd-price-color);
    margin-bottom: 2px;
}
.product-price .currency { font-size: 0.7em; font-weight: 500; margin-left: 2px; }

.product-price-btc {
    font-size: 1.05em;
    color: var(--btc-price-color);
    margin-bottom: 12px;
    font-weight: 700;
}
.product-price-btc .currency { font-size: 0.8em; font-weight: 500; margin-left: 2px; }

.consult-button {
    background: linear-gradient(145deg, var(--primary-color), #505050);
    color: white;
    padding: 10px 16px;
    text-align: center;
    text-decoration: none;
    border-radius: 7px;
    margin-top: auto;
    border: none;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    letter-spacing: 0.2px;
    transition: background-color 0.25s, transform 0.2s, box-shadow 0.25s;
    z-index: 10;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.consult-button:hover {
    background: linear-gradient(145deg, var(--secondary-color), var(--accent-color));
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.modal {
    display: none; position: fixed; z-index: 1001; left: 0; top: 0; width: 100%; height: 100%;
    overflow: auto; background-color: rgba(40, 40, 40, 0.8); align-items: center;
    justify-content: center; padding: 20px; backdrop-filter: blur(6px);
}
.modal.active { display: flex; }
.modal-content {
    background-color: var(--card-bg); margin: auto; padding: 25px 35px;
    border: 1px solid var(--border-color); width: 90%; border-radius: 12px;
    box-shadow: 0 10px 35px rgba(0,0,0,0.25); position: relative;
    animation: fadeInModal 0.35s ease-out; max-height: 90vh; overflow-y: auto;
}
.consultation-modal-style .modal-content { max-width: 580px; }
.product-details-modal-style .modal-content { max-width: 750px; }

@keyframes fadeInModal {
    from { opacity: 0; transform: translateY(-25px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.close-modal-button {
    color: #aaa; position: absolute; top: 15px; right: 20px; font-size: 30px;
    font-weight: bold; cursor: pointer; transition: color 0.2s, transform 0.2s; line-height: 1;
}
.close-modal-button:hover, .close-modal-button:focus { color: var(--primary-color); transform: rotate(90deg); }
.modal-content h2 {
    font-family: var(--display-font); color: var(--primary-color); margin-top: 0;
    margin-bottom: 20px; font-size: 1.8em; text-align: center;
}
#consultation-modal .modal-content p { margin-bottom: 20px; font-size: 1em; line-height: 1.7; color: var(--text-color); text-align: center; }
#consultation-modal #consultation-product-intro { margin-bottom: 10px; }
#consultation-modal #consultation-product-name-modal { color: var(--accent-color); }
.modal-contact-buttons { display: flex; flex-direction: column; gap: 15px; margin-top: 10px; }
.modal-contact-buttons .contact-button {
    display: flex; align-items: center; justify-content: center; padding: 12px 20px;
    text-decoration: none; border-radius: 8px; font-size: 1em; font-weight: 500;
    transition: opacity 0.3s, transform 0.2s, box-shadow 0.2s; color: white; box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.modal-contact-buttons .contact-button:hover { opacity: 0.9; transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.15); }
.contact-button.signal { background-color: #3A76F0; }
.contact-button.simplex { background-color: #050f14; }
.contact-icon { height: 22px; width: auto; margin-right: 12px; }
#product-details-modal #modal-product-image-container { width: 100%; max-height: 350px; margin-bottom: 25px; text-align: center; border-radius: 8px; overflow: hidden; background-color: #f9f9f9; }
#product-details-modal #modal-product-image { max-width: 100%; max-height: 350px; object-fit: contain; border-radius: 8px; }
#product-details-modal #modal-product-rating { text-align: center; margin-bottom: 15px; }
#product-details-modal .modal-product-price-usd, #product-details-modal .modal-product-price-btc { text-align: center; font-size: 1.4em; font-weight: 700; margin-bottom: 8px; }
#product-details-modal .modal-product-price-usd { color: var(--usd-price-color); }
#product-details-modal .modal-product-price-btc { color: var(--btc-price-color); }
#modal-product-specs-container h3, #modal-product-description-container h3 { font-family: var(--display-font); color: var(--accent-color); font-size: 1.2em; margin-top: 25px; margin-bottom: 10px; border-bottom: 1px solid var(--border-color); padding-bottom: 5px; }
#modal-product-specs-list { list-style: none; padding-left: 0; font-size: 0.95em; }
#modal-product-specs-list li { padding: 5px 0; border-bottom: 1px dashed var(--border-color); }
#modal-product-specs-list li:last-child { border-bottom: none; }
#modal-product-specs-list strong { color: var(--primary-color); margin-right: 5px; }
#modal-product-description { font-size: 0.95em; line-height: 1.8; text-align: justify; }
#product-details-modal .ebay-link-button, #product-details-modal .consult-button-from-details { display: block; width: calc(100% - 40px); margin: 25px auto 10px auto; padding: 12px 20px; border-radius: 8px; text-align: center; font-weight: 600; font-size: 1em; transition: background-color 0.3s, transform 0.2s; }
#product-details-modal .ebay-link-button { background-color: #e53238; color: white; text-decoration: none; }
#product-details-modal .ebay-link-button:hover { background-color: #c41a20; transform: translateY(-1px); }
#product-details-modal .consult-button-from-details { background-color: var(--primary-color); color: white; border: none; cursor: pointer; }
#product-details-modal .consult-button-from-details:hover { background-color: var(--secondary-color); transform: translateY(-1px); }

footer {
    text-align: center; padding: 30px; background-color: var(--primary-color);
    color: var(--light-bg); font-size: 0.9em; margin-top: 60px;
    border-top: 3px solid var(--secondary-color);
}

/* --- Responsive Adjustments --- */

@media (max-width: 992px) { /* Tablets y similar */
    header { padding: 15px 25px; }
    header h1 { font-size: 1.8em; }
    #category-nav button { padding: 8px 15px; font-size: 0.8em; margin: 5px; }
    main { padding: 25px 15px; max-width: 100%; }
    #current-category-title { font-size: 2.2em; margin-bottom: 35px; }
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 25px; }
    .product-details-modal-style .modal-content { max-width: 90%; }
}

/* Ajustes para móviles (pantallas de 768px de ancho o menos) */
@media (max-width: 768px) {
    header {
        position: static; /* Header deja de ser fijo */
        flex-direction: column;
        padding: 15px 10px; /* Padding ajustado */
        align-items: center; /* Centra el logo-container y category-nav */
    }
    .logo-container {
        flex-direction: column;
        align-items: center;
        margin-bottom: 15px; /* Espacio entre logo/título y categorías */
        width: 100%;
    }
    #logo {
        height: 45px; /* Logo más pequeño */
        margin-right: 0;
        margin-bottom: 8px; /* Espacio entre logo y título */
    }
    header h1 {
        font-size: 1.4em; /* Título más pequeño */
        line-height: 1.2;
        text-align: center;
        margin: 0;
    }

    #category-nav {
        display: flex;
        flex-wrap: wrap;
        justify-content: center; /* Centra los botones */
        gap: var(--category-nav-gap); /* Espacio entre botones */
        width: 100%;
        padding: 5px 0; /* Padding vertical */
        margin: 0; /* Resetear margen */
    }

    #category-nav button {
        width: calc(50% - (var(--category-nav-gap) / 2) - 1px); /* Ajustado para 2 por fila con gap. El -1px es un pequeño ajuste para asegurar que quepan por si hay problemas de redondeo en el cálculo del navegador */
        box-sizing: border-box;
        margin: 0; /* El gap se encarga del espaciado */
        padding: 8px 6px; /* Padding del botón más compacto */
        font-size: 0.75em; /* Fuente del botón más pequeña */
        line-height: 1.2;
        min-height: auto;
        border-radius: 15px; /* Bordes más redondeados */
        text-align: center;
    }

    main { padding: 20px 10px; }
    #current-category-title { font-size: 1.8em; margin-bottom: 25px; }
    .product-card-image-wrapper { height: 220px; }
    .modal-content { padding: 20px; }
    .product-details-modal-style .modal-content,
    .consultation-modal-style .modal-content { max-width: calc(100% - 20px); } /* Más ajustado */
    .modal-content h2 { font-size: 1.5em; }
}


@media (max-width: 480px) { /* Móviles muy pequeños */
    header {
        padding: 10px;
    }
    #logo {
        height: 40px;
        margin-bottom: 5px;
    }
    header h1 {
        font-size: 1.2em; /* Título aún más pequeño */
    }

    #category-nav {
        gap: 4px; /* Gap más pequeño */
        --category-nav-gap: 4px; /* Actualizar variable si es usada por botones */
    }
    #category-nav button {
        width: calc(50% - (var(--category-nav-gap) / 2) - 1px);
        padding: 7px 5px;
        font-size: 0.68em; /* Fuente aún más pequeña */
        border-radius: 12px;
    }

    #current-category-title { font-size: 1.6em; margin-bottom: 20px; }
    .product-grid { grid-template-columns: 1fr; gap: 15px; } /* Productos en una columna */
    .product-card-image-wrapper { height: 230px; }
    .product-info h3 { font-size: 0.9em; }
    #product-details-modal .ebay-link-button,
    #product-details-modal .consult-button-from-details,
    .modal-contact-buttons .contact-button { font-size: 0.85em; padding: 10px 12px; }
}
