body {
    font-family: Arial, sans-serif;
    margin: 0;
    background-color: #f4f4f4;
    color: #333;
}
header, main {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}
form {
    margin-top: 20px;
    padding: 8px;
    border-radius: 5px;
}
input[type="email"], input[type="password"], input[type="text"], input[type="number"], textarea {
    width: calc(100% - 22px);
    padding: 10px;
    margin-bottom: 1px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
button {
    background-color: #007bff;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
button:hover {
    background-color: #0056b3;
}
.product-card {
    border: 1px solid #eee;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 5px;
    background-color: #fdfdfd;
}
img {
    max-width: 100%;
    height: auto;
}

#search-form button[type="submit"] {
    width: auto !important;
    align-self: center !important;
}




/* ======================================= */
/* ESTILOS PARA EL HEADER (Modernización)  */
/* ======================================= */

header {
    background-color: #2563eb;
    color: white;
    padding: 3px 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
}
.search-bar-container {
    margin: 4px 0 !important;
}

header nav {
    display: flex;
    align-items: center;
    gap: 25px;
    margin-left: auto; 
}

header nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding: 8px 10px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

header nav a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

header nav #user-greeting {
    margin-left: 20px;
    font-size: 0.9rem;
    color: #bfdbfe;
}

header nav button#logout-btn {
    background-color: #f87171;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    font-weight: 600;
}

header nav button#logout-btn:hover {
    background-color: #ef4444; 
}

header nav #cart-icon-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    margin-left: 15px;
    transition: color 0.2s;
}

header nav #cart-icon-btn:hover {
    color: #bfdbfe;
}
#feed-list {
    max-width: 1500px !important;
    margin: 0 auto !important;
}

#user-store-search-input {
    max-width: 400px !important;
}


#search-form button[type="submit"] {
    background-color: #2563eb !important;
    color: white !important;
    border: none !important;
    border-radius: 999px !important;
    padding: 6px 14px !important;
    font-weight: 600 !important;
    font-size: 0.88rem !important;
    cursor: pointer !important;
    transition: background 0.2s !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

#search-form button[type="submit"]:hover {
    background-color: #1d4ed8 !important;
}

@media (max-width: 768px) {
    #inventoryContainer {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }
}

@media (max-width: 768px) {
    header {
        flex-wrap: wrap !important;
        gap: 4px !important;
        padding: 6px 12px 8px 12px !important;
    }

    header h1 {
        font-size: 1.3rem !important;
        order: 1 !important;
    }

    .search-bar-container {
            width: 100% !important;
            order: 3 !important;
            margin: 0 0 6px 0 !important;
        }

    header nav {
        order: 2 !important;
        margin-left: auto !important;
    }

    #search-form {
        width: 100% !important;
    }

    #search-form > div {
        width: 100% !important;
    }

    #search-input {
        width: 100% !important;
        min-width: 0 !important;
    }
}

@media (max-width: 768px) {
    #user-store-products-container .bg-white.rounded-2xl {
        border-radius: 10px !important;
    }

    #user-store-products-container .w-full.h-48 {
        height: 130px !important;
    }

    #user-store-products-container .p-4 {
        padding: 8px !important;
    }

    #user-store-products-container .text-lg {
        font-size: 0.85rem !important;
    }

    #user-store-products-container .text-xl {
        font-size: 1rem !important;
    }

    #user-store-products-container .add-to-cart-btn {
        padding: 6px 10px !important;
        font-size: 0.8rem !important;
    }
}
@media (max-width: 768px) {
    #user-store-products-container {
        padding: 0 !important;
        margin: 0 !important;
    }

    #user-store-section {
        padding: 8px !important;
    }
}
#user-store-section {
    padding-top: 4px !important;
}
#feed-list {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 12px !important;
    padding: 16px !important;
}

main {
    margin-bottom: 0 !important;
    padding: 0 !important;
}
#logout-btn {
    padding: 6px 10px !important;
    font-size: 0.85rem !important;
}
#auth-section > div {
    max-width: 420px !important;
    margin-top: 20px !important;
}

#auth-section {
    align-items: flex-start !important;
    padding-top: 20px !important;
    overflow: hidden !important;
}
#auth-section {
    height: calc(100vh - 60px) !important;
    overflow: hidden !important;
}


  .auth-card {
    border-radius: 2rem;
    box-shadow: 0 20px 50px rgba(0,0,0,0.08);
  }

.auth-tab-active {
    background-color: #eff6ff;
    color: #2563eb !important;
    box-shadow: inset 0 -3px 0 #2563eb;
}


  .auth-input {
    border-radius: 9999px;
    background: #f5f5f5;
    padding: 0.9rem 1.2rem;
  }

  .auth-button {
    border-radius: 9999px;
    font-weight: 600;
    font-size: 1.1rem;
    padding: 0.9rem;
  }

/* ===================== */
/* CARD DEL FEED          */
/* (única definición — antes había dos bloques ".feed-product-card" */
/*  duplicados con valores distintos de borde/sombra; se dejó uno) */
/* ===================== */
.feed-product-card {
    border-radius: 12px !important;
    border: 0.5px solid #e5e7eb !important;
    overflow: hidden !important;
    background: white !important;
    padding: 0 !important;
    transition: transform 0.18s, box-shadow 0.18s !important;
    cursor: pointer !important;
}
.feed-product-card:hover {
    transform: translateY(-3px) !important;
    box-shadow: 0 8px 20px rgba(0,0,0,0.09) !important;
    border-color: #d1d5db !important;
}

/* Nombre del producto (1er <p> dentro de la card) */
.feed-product-card > div:last-child > p:nth-of-type(1) {
    padding: 8px 10px 0 10px !important;
    font-weight: 500 !important;
    line-height: 1.3 !important;
    margin: 0 0 4px !important;
    font-size: 0.85rem !important;
    color: #12141a !important;
    white-space: normal !important;
    overflow: hidden !important;
    text-overflow: unset !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    min-height: 2.2em !important;
}

/* Precio (2do <p>) */
.feed-product-card > div:last-child > p:nth-of-type(2) {
    padding: 0 10px 2px 10px !important;
    font-weight: 800 !important;
    line-height: 1.1 !important;
    margin: 0 0 2px !important;
    font-size: 1.05rem !important;
    color: #16a34a !important;
}
.feed-product-card > div:last-child > p:nth-of-type(2) span {
    color: #16a34a !important;
    font-weight: 600 !important;
}

/* Bloque del vendedor */
.feed-product-card .seller-block {
    padding: 7px 10px 9px 10px !important;
    margin: 0 !important;
}
.feed-product-card .seller-name {
    font-weight: 600 !important;
}
@media (max-width: 768px) {
    .feed-product-card > div:last-child > p:nth-of-type(1) {
        font-size: 0.78rem !important;
        padding: 6px 8px 0 8px !important;
        line-height: 1.3 !important;
        min-height: 2em !important;
    }

    .feed-product-card > div:last-child > p:nth-of-type(2) {
        font-size: 0.92rem !important;
        padding: 0 8px 2px 8px !important;
        line-height: 1.2 !important;
    }

    .feed-product-card .seller-block {
        padding: 6px 8px 8px 8px !important;
    }

    #feed-list {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        padding: 8px !important;
    }
}

/* Tablet: 3 columnas en vez de saltar directo de 5 a 2 */
@media (max-width: 1100px) and (min-width: 769px) {
    #feed-list {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

#isPublished {
    width: 18px !important;
    height: 18px !important;
    cursor: pointer !important;
    accent-color: #2563eb !important;
}
@media (max-width: 768px) {
    #user-store-description {
        display: none !important;
    }
}

/* ===================== */
/* SKELETON LOADING      */
/* ===================== */
@keyframes skeleton-pulse {
    0%   { background-color: #e8eaed; }
    50%  { background-color: #f5f5f5; }
    100% { background-color: #e8eaed; }
}

.feed-product-card .img-skeleton {
    width: 100%;
    padding-top: 100%;
    background-color: #e8eaed;
    animation: skeleton-pulse 1.4s ease-in-out infinite;
}

.feed-product-card .name-skeleton {
    height: 13px;
    background-color: #e8eaed;
    border-radius: 4px;
    margin-bottom: 6px;
    width: 85%;
    animation: skeleton-pulse 1.4s ease-in-out infinite;
}

.feed-product-card .price-skeleton {
    height: 16px;
    background-color: #e8eaed;
    border-radius: 4px;
    width: 40%;
    animation: skeleton-pulse 1.4s ease-in-out infinite 0.2s;
}

.feed-product-card .seller-skeleton {
    height: 22px;
    background-color: #e8eaed;
    border-radius: 11px;
    width: 60%;
    animation: skeleton-pulse 1.4s ease-in-out infinite 0.4s;
}
/* Footer siempre abajo */
body {
    display: flex !important;
    flex-direction: column !important;
    min-height: 100vh !important;
}

main {
    flex: 1 !important;
}
/* ===================== */
/* MAPA RESPONSIVE       */
/* ===================== */
@media (max-width: 768px) {
    #mapa-body {
        flex-direction: column !important;
    }

    #mapa-sidebar {
        width: 100% !important;
        border-left: none !important;
        border-top: 0.5px solid #e5e7eb !important;
        max-height: 220px !important;
        flex-shrink: 0 !important;
    }

    #mapa-sidebar-list {
        max-height: 170px !important;
    }

    #mapa-leaflet {
        min-height: 320px !important;
    }

    #mapa-section > div {
        height: calc(100vh - 56px) !important;
    }
}
/* Carrito siempre delante del mapa */
#cart-sidebar {
    z-index: 9999 !important;
}

/* Popup de Leaflet delante del sidebar del mapa */
#mapa-leaflet .leaflet-popup {
    z-index: 2000 !important;
}

#mapa-leaflet .leaflet-pane {
    z-index: 400 !important;
}

/* Sidebar del mapa detrás del popup */
#mapa-sidebar {
    z-index: 1 !important;
}
/* ===================== */
/* MAPA ALTURA ADAPTABLE */
/* ===================== */
#mapa-section {
    height: calc(100vh - 56px) !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

#mapa-section > div {
    height: 100% !important;
    overflow: hidden !important;
}

#mapa-body {
    flex: 1 !important;
    overflow: hidden !important;
    min-height: 0 !important;
}

#mapa-leaflet {
    height: 100% !important;
    width: 100% !important;
}

#mapa-sidebar {
    height: 100% !important;
    overflow: hidden !important;
}

#mapa-sidebar-list {
    flex: 1 !important;
    overflow-y: auto !important;
    min-height: 0 !important;
}
#mapa-section {
    display: none !important;
}
#mapa-section[style*="display: block"],
#mapa-section[style*="display:block"] {
    display: flex !important;
    flex-direction: column;
}
body.loading * {
    visibility: hidden !important;
    animation: revealBody 0s 1.5s forwards;
}

@keyframes revealBody {
    to { visibility: visible !important; }
}

/* ===================== */
/* BOTÓN REGÍSTRATE      */
/* ===================== */
#register-public-btn {
    background: linear-gradient(135deg, #f97316, #ef4444) !important;
    color: white !important;
    font-weight: 700 !important;
    border: none !important;
    border-radius: 999px !important;
    padding: 8px 16px !important;
    cursor: pointer !important;
    position: relative !important;
    animation: latido 1.4s ease-in-out infinite !important;
    box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.7) !important;
}

@keyframes latido {
    0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.7); }
    50%  { transform: scale(1.06); box-shadow: 0 0 0 10px rgba(249, 115, 22, 0); }
    100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(249, 115, 22, 0); }
}

#register-public-btn:hover {
    animation: none !important;
    transform: scale(1.08) !important;
    background: linear-gradient(135deg, #ea580c, #dc2626) !important;
}

/* ============================================================ */
/* FICHA DE PRODUCTO (#user-product-modal) — estética del mockup */
/* ============================================================ */

#user-product-modal > div {
    border-radius: 20px !important;
    box-shadow: 0 24px 60px rgba(17,20,26,.22) !important;
}

#user-product-image {
    border-radius: 16px !important;
    border: 1px solid #e6e9ee !important;
    background-color: #f3f5f8 !important;
}

#user-product-thumbnails img {
    width: 64px !important;
    height: 64px !important;
    object-fit: cover !important;
    border-radius: 10px !important;
    border: 1.5px solid #e6e9ee !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
}

#user-product-title {
    font-weight: 800 !important;
    line-height: 1.3 !important;
    letter-spacing: -0.01em !important;
}

#user-product-price {
    letter-spacing: -0.01em !important;
}

#user-product-description {
    background: #fff !important;
    border: 1px solid #e6e9ee !important;
    border-radius: 16px !important;
    padding: 18px 20px !important;
    margin-top: 4px !important;
}

#user-product-modal h3 {
    font-size: 0.95rem !important;
    color: #64748b !important;
    text-transform: uppercase !important;
    letter-spacing: .04em !important;
    font-weight: 700 !important;
    margin-bottom: 10px !important;
}

#buy-product-btn {
    border-radius: 12px !important;
    background-color: #2563eb !important;
}
#buy-product-btn:hover {
    background-color: #1d4ed8 !important;
}

@media (max-width: 768px) {
    #user-product-modal > div {
        border-radius: 16px !important;
    }
    #user-product-image {
        border-radius: 12px !important;
    }
    #user-product-title {
        font-size: 1.25rem !important;
    }
    #user-product-description {
        border-radius: 12px !important;
        padding: 14px 16px !important;
    }
}

/* ============================================================ */
/* FICHA DE PRODUCTO (link directo /usuario/idProducto)          */
/* — "Enviar mensaje" arriba a la derecha en vez de al fondo     */
/* ============================================================ */

/* El botón se inyecta por JS como último hijo de #product-detail-section,
   así que por orden de DOM cae al final (abajo). Lo sacamos del flujo
   normal y lo anclamos arriba a la derecha de toda la sección. */
#product-detail-section {
    position: relative !important;
}
#product-message-btn {
    position: absolute !important;
    top: 20px !important;
    right: 16px !important;
    width: auto !important;
    margin: 0 !important;
    padding: 10px 18px !important;
    font-size: 0.85rem !important;
    align-self: unset !important;
    z-index: 5 !important;
    box-shadow: 0 4px 14px rgba(37,99,235,.35) !important;
}

@media (max-width: 768px) {
    #product-message-btn {
        top: 12px !important;
        right: 12px !important;
        padding: 8px 14px !important;
        font-size: 0.78rem !important;
    }
}

/* ============================================================ */
/* "MÁS PRODUCTOS DE ESTA TIENDA" — una sola fila con scroll     */
/* horizontal (nunca más de una fila), tanto en desktop como en  */
/* mobile. Clases con prefijo "rp-" para no chocar con nada      */
/* existente en el sitio.                                        */
/* ============================================================ */

/* ============================================================ */
/* "MÁS PRODUCTOS DE ESTA TIENDA" — una sola fila, sin scroll.   */
/* Se muestran los que alcancen: 4 en desktop, 3 en tablet,      */
/* 2 en mobile. El resto (si el JS trae más) queda recortado —   */
/* el truco es: alto de fila fijo + cualquier fila extra a 0 +   */
/* overflow:hidden. Clases con prefijo "rp-" para no chocar con  */
/* nada existente en el sitio.                                   */
/* ============================================================ */

.rp-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: 212px;  /* alto de la única fila visible */
    grid-auto-rows: 0;          /* cualquier fila de más queda en 0 */
    gap: 14px;
    overflow: hidden;           /* … y se recorta, no se ve ni hace scroll */
}

.rp-card {
    background: #fff;
    border: 1px solid #e6e9ee;
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: transform .18s, box-shadow .18s, border-color .18s;
}
.rp-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(17,20,26,.09);
    border-color: #d1d5db;
}

.rp-img-wrap {
    position: relative;
    width: 100%;
    height: 130px; /* fijo, no depende del ancho de la columna */
    background: #f3f5f8;
    overflow: hidden;
}
.rp-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.rp-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #2563eb;
    color: #fff;
    font-size: .62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .02em;
    padding: 3px 9px;
    border-radius: 999px;
}

.rp-body {
    height: 82px;
    padding: 9px 11px 11px;
    box-sizing: border-box;
}
.rp-title {
    font-size: .82rem;
    font-weight: 500;
    color: #12141a;
    line-height: 1.3;
    margin: 0 0 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.rp-price {
    font-size: .95rem;
    font-weight: 800;
    color: #16a34a;
    margin: 0;
}

/* Tablet: 3 por fila */
@media (max-width: 900px) {
    .rp-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Mobile: 2 por fila, fila más baja porque la imagen es más chica */
@media (max-width: 640px) {
    .rp-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: 178px;
        gap: 10px;
    }
    .rp-img-wrap { height: 100px; }
    .rp-body { height: 78px; padding: 7px 8px 9px; }
    .rp-title { font-size: .76rem; }
    .rp-price { font-size: .85rem; }
    .rp-badge { font-size: .58rem; padding: 2px 7px; }
    #related-products-section h3,
    #related-products-section-pd h3 { font-size: 1rem; }
}