/* Variables de tema base (colores, sombras y transiciones) */
:root {
    --primary-color: #4361ee;
    --primary-hover: #3a56d4;
    --secondary-color: #3f37c9;
    --text-color: #2b2d42;
    --light-text: #f8f9fa;
    --background: #ffffff;
    --card-bg: #ffffff;
    --border-color: #e9ecef;
    /* Sombra para los elementos */
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    /* Transición para los elementos */
    --transition: all 0.3s ease;
}

/* Overrides para modo oscuro */
.dark {
    /* Color del texto */
    --text-color: #ffffff;
    /* Color del fondo */
    --background: #1a1a1a;
    /* Color del fondo alternativo */
    --background-alt: #2d2d2d;
    /* Color del fondo de las tarjetas */
    --card-bg: #2d2d2d;
    /* Color del borde de los elementos */
    --border-color: #444;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    --primary-color: #007BFF;
    --secondary-color: #8A9AAB;
}

/* Botón flotante para publicar producto */
#btn-publicar {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 1000;
    transition: all 0.3s ease;
    text-decoration: none;
}

#btn-publicar:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* Contenedor principal de la tienda (espaciado por navbar fija) */
.store-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 120px 20px 20px 20px;
    min-height: calc(100vh - 80px);
}

/* Cabecera de la tienda: avatar + nombre + acciones */
.store-header {
    margin-top: 20px;
    background: var(--card-bg);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.store-profile {
    display: flex;
    gap: 20px;
    flex: 1;
}

.store-avatar {
    flex-shrink: 0;
}

.store-avatar img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.store-info {
    flex: 1;
}

.store-name {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0 0 8px 0;
    line-height: 1.2;
}

.store-role {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 1.1rem;
    margin: 0 0 5px 0;
}

.store-member-since {
    color: var(--secondary-color);
    font-size: 0.9rem;
    margin: 0 0 20px 0;
}

.store-description {
    margin-top: 20px;
}

.store-description h3 {
    font-size: 1.2rem;
    color: var(--text-color);
    margin: 0 0 10px 0;
    font-weight: 600;
}

.store-description p {
    color: var(--text-color);
    line-height: 1.6;
    margin: 0;
}

.no-description {
    color: var(--secondary-color);
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 8px;
}

.no-description a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.no-description a:hover {
    text-decoration: underline;
}

.store-actions {
    flex-shrink: 0;
}

.btn-edit-profile {
    background: var(--primary-color);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    border: none;
    cursor: pointer;
}

.btn-edit-profile:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

/* Sección contenedora de la grilla de productos */
.products-section {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

/* Encabezado de sección productos (título + contador) */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.section-header h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0;
}

.products-count {
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Grilla responsiva de productos dentro de la tienda */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 20px;
    margin-bottom: 20px;
}

/* Tarjeta de producto (vista tienda) */
.product-card {
    background: var(--background);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    position: relative;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Imagen principal del producto (rellena contenedor) */
.product-image img {
    width: 100%;
    height: 400px;
    object-fit: cover !important;
}

.no-image {
    width: 100%;
    height: 100%;
    background: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-color);
    font-size: 3rem;
}

/* Insignia de sin stock */
.out-of-stock-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #dc3545;
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 600;
}

.product-info {
    padding: 20px;
}

.product-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0 0 10px 0;
    line-height: 1.3;
}

.product-description {
    color: var(--secondary-color);
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0 0 15px 0;
}

.product-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0 0 10px 0;
}

.product-actions {
    padding: 0 20px 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.product-actions .btn-base {
    flex: 1;
    padding: 10px 15px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
    min-width: 120px;
}

.product-actions .btn-base:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

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

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-view-product {
    background: var(--primary-color);
    color: white;
}

.btn-add-cart {
    background: #28a745;
    color: white;
}

.btn-buy {
    background-color: var(--secondary-color);
    color: white;
}

.btn-out-of-stock {
    background: #6c757d;
    color: white;
    cursor: not-allowed;
    opacity: 0.6;
}

.no-products {
    text-align: center;
    padding: 60px 20px;
    color: var(--secondary-color);
}

.no-products i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.no-products h3 {
    font-size: 1.5rem;
    margin: 0 0 10px 0;
    color: var(--text-color);
}

.no-products p {
    margin: 0 0 20px 0;
    font-size: 1rem;
}

.no-products .btn-primary {
    background: var(--primary-color);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.no-products .btn-primary:hover {
    background: var(--primary-hover);
}

/* Modal nativo estilizado para acciones (editar, publicar, etc.) */
dialog {
    border: none;
    outline: none !important;
    border-radius: 12px;
    padding: 2rem;
    max-width: 90%;
    width: 500px;
    margin: 0;
    position: fixed;
    top: 50%;

    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: var(--card-bg, white);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

dialog[open] {
    opacity: 1;
    animation: dialogFadeIn 0.3s ease-out;
}

@keyframes dialogFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

dialog h3 {
    margin-top: 0;
    color: var(--primary-color);
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.dialog-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

.dialog-buttons button {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dialog-buttons button[type="button"] {
    background: red;
    color: var(--text-color);
}

.dialog-buttons button[type="submit"] {
    background: var(--primary-color);
    color: white;
}

.dialog-buttons button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 1rem;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.image-preview {
    margin-top: 1rem;
    text-align: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    margin-top: 0.5rem;
    border: 1px solid var(--border-color);
}

/* Estilos generales */
body {
    background-color: var(--background);
    color: var(--text-color);
    transition: var(--transition);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Liberation Sans', sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

main {
    padding-top: 120px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 120px 20px 40px 20px;
    min-height: calc(100vh - 80px); 
    background-color: var(--background);
    box-sizing: border-box;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
    padding: 1rem 0;
}

h2 {
    color: var(--primary-color);
    margin-bottom: 2rem;
    text-align: center;
    font-size: 2rem;
}

.store-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
    padding: 1rem 0;
}

.product-card {
    background: var(--surface-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

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

.product-title {
    font-size: 1rem;
    margin: 0 0 0.5rem;
    color: var(--text-color);
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.8em;
    max-height: 2.8em;
    line-clamp: 2;
}

.product-price-stock {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.product-price {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.25rem;
    margin: 0;
}

.product-stock {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.product-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
    padding: 0 1rem 1rem;
}

.product-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.btn-view-product,
.btn-add-cart {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 15px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.btn-view-product i,
.btn-add-cart i {
    margin-right: 6px;
    font-size: 0.9em;
}

.btn-view-product {
    background: linear-gradient(135deg, #6f42c1 0%, #5a32a3 100%);
    color: white;
    flex: 1;
    min-width: 120px;
}

.btn-view-product:hover {
    background: linear-gradient(135deg, #5a32a3 0%, #4a2a8a 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-add-cart {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    flex: 1;
    min-width: 120px;
}

.btn-add-cart:hover {
    background: linear-gradient(135deg, #218838 0%, #1aa179 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-add-cart.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn-add-cart.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

/* Formularios y controles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--card-bg);
    color: var(--text-color);
    font-size: 1rem;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.2);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

/* Modal de ediciÃ³n */
dialog {
    border: none;
    outline: none !important;
    border-radius: 12px;
    padding: 2rem;
    background: var(--card-bg);
    color: var(--text-color);
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

dialog h3 {
    margin: 0 0 1.5rem;
    color: var(--primary-color);
    text-align: center;
    font-size: 1.5rem;
}

/* Vista previa de imagen */
.image-preview {
    margin-top: 1rem;
    text-align: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin-top: 0.5rem;
    display: none;
}

.image-preview img[src] {
    display: inline-block;
}

/* Botones del formulario */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn i {
    font-size: 1rem;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
}

/* Mejoras para el input de archivo */
input[type="file"] {
    padding: 0.5rem;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    width: 100%;
    cursor: pointer;
}

input[type="file"]:hover {
    border-color: var(--primary-color);
}

/* Mensajes de estado */
.status-message {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.status-message.success {
    background-color: rgba(40, 167, 69, 0.1);
    color: #28a745;
    border: 1px solid #28a745;
}

.status-message.error {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border: 1px solid #dc3545;
}
/* Mensaje cuando no hay productos */
.store-grid + p {
    text-align: center;
    grid-column: 1 / -1;
    color: var(--text-color);
    font-size: 1.1rem;
    margin-top: 2rem;
}
/* ---- Tallas personalizadas (publicar producto) ---- */
.talla-manual {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.talla-manual .form-control {
    flex: 1;
}

/* BotÃ³n Agregar de talla personalizada */
.talla-manual .btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #565e64 100%);
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.talla-manual .btn-secondary:hover {
    background: linear-gradient(135deg, #5a6268 0%, #4e555b 100%);
    transform: translateY(-1px);
}
.talla-manual .btn-secondary:active {
    transform: translateY(0);
}

.tallas-seleccionadas {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    background: var(--primary-color);
    color: #fff;
}

.badge.badge-secondary {
    background: #6c757d;
}

.badge button {
    background: transparent;
    border: none;
    color: inherit;
    margin-left: 6px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

/* Vista previa de imÃ¡genes (grid) */
.images-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.images-preview img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

/* ---- Responsividad: header y grilla de productos ---- */
@media (max-width: 900px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 20px;
    }
    .product-image img {
        height: 300px;
    }
}

@media (max-width: 600px) {
    .store-header {
        flex-direction: column;
        align-items: stretch;
    }
    .btn-edit-profile {
        width: 100%;
        justify-content: center;
        margin-top: 10px;
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    .products-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .product-image img {
        height: 220px;
    }
}

/* Refuerzo especÃ­fico <= 550px */
@media (max-width: 550px) {
    .btn-edit-profile {
        width: 100%;
    }
    .product-image img {
        height: 200px;
    }
}

/* === Publicar/Editar: Estilos adicionales === */
/* CategorÃ­as en diÃ¡logos: caja con borde y 2 filas horizontales */
.categorias-container {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    background: var(--card-bg);
}
.categorias-checkboxes {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}
@media (max-width: 600px) {
    .categorias-checkboxes {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Limitar a 2 lÃ­neas el nombre y la descripciÃ³n en cards */
.product-name,
.product-description {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-clamp: 2;
}

/* Ocultar tallas predefinidas en el diÃ¡logo de publicar (solo mostrar talla personalizada) */
#publicar .tallas-checkboxes {
    display: none !important;
}
/* Ocultar opciones de talla predefinidas en el modal de edición (solo talla personalizada) */
#edit-product-modal .tallas-checkboxes {
    display: none !important;
}
/* Deshabilitar abrir dropdown por hover; usar click via JS */
.nav-user-dropdown:hover .dropdown-content {
    display: none !important;
}

/* Mantener visible el dropdown cuando esté toggled por clase .show, incluso al pasar el mouse */
.nav-user-dropdown:hover .dropdown-content.show {
    display: block !important;
}
/* Ajustes de navbar para pantallas pequeÃ±as <= 563px */
@media (max-width: 563px) {
    .navbar {
        height: 64px !important;
    }
    .navbar-container {
        padding: 0 12px !important;
        max-width: 100% !important;
    }
    .navbar-logo {
        font-size: 1.2rem !important;
        margin-right: 10px !important;
    }
    .navbar-logo-img {
        height: 30px !important;
    }
    .navbar-search {
        max-width: 300px !important;
        margin: 0 10px !important;
    }
    .navbar-search input[type="text"] {
        padding: 6px 10px !important;
        font-size: 0.9rem !important;
    }
    .navbar-search button {
        padding: 0 10px !important;
    }
    .nav-links {
        padding: 8px 10px !important;
        font-size: 0.9rem !important;
    }
    .nav-icon-link {
        width: 36px !important;
        height: 36px !important;
        font-size: 1.2rem !important;
    }
    .nav-user-avatar {
        width: 32px !important;
        height: 32px !important;
        border-width: 1px !important;
    }
    .dropdown-content {
        min-width: 180px !important;
    }
}
