/************************/        
/*       PRODUCTOS      */
/************************/

/* Contenedor principal */
.productos-container {
    max-width: 120rem;
    margin: 0 auto;
    padding: 0; /* Sin padding horizontal, usa el del main container */
    min-height: 500px; /* Altura mínima para evitar cambios de layout */
    width: 100%; /* Usa todo el ancho disponible */
    box-sizing: border-box; /* Incluye cualquier padding/border en el cálculo del ancho */
}

/* Responsive para productos-container */
@media (max-width: 1024px) {
    .productos-container {
        max-width: 100%;
        width: 100%;
        margin: 0;
        overflow-x: hidden; /* Evita scroll horizontal */
    }
}

@media (max-width: 480px) {
    .productos-container {
        max-width: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
        overflow-x: hidden; /* Evita scroll horizontal */
    }
}

/* Responsive para contenedor principal - Solo márgenes específicos si es necesario */

/* Header horizontal con título y filtros */
.header-productos {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 3rem;
    padding-top: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #e0e0e0;
    position: relative;
    min-height: 60px; /* Altura mínima para mantener consistencia */
    width: 100%;
    box-sizing: border-box;
}

.titulo-seccion {
    font-size: 3.2rem;
    font-weight: 300;
    color: var(--dark-text);
    margin: 0;
    flex-shrink: 0; /* No se comprime */
    white-space: nowrap; /* No se rompe en múltiples líneas */
    text-transform: uppercase;
}

/* Filtros en línea horizontal */
.filtros-linea {
    display: flex;
    align-items: center;
    gap: 3rem;
    flex-shrink: 0; /* Evita que se comprima */
    width: auto;
    min-width: 300px; /* Ancho mínimo para mantener estructura */
}

/* Custom Dropdown Styles */
.custom-dropdown {
    position: relative;
    display: inline-block;
}

.custom-dropdown .dropdown-label {
    color: #111;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.4rem;
    font-weight: 400;
    text-transform: uppercase;
    white-space: nowrap;
    padding: 0.8rem 1.2rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    min-width: 160px;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.custom-dropdown .dropdown-label:hover {
    border-color: var(--primary-color);
    background-color: #f8f9fa;
}

.custom-dropdown .dropdown-arrow {
    font-size: 0.8em;
    transition: transform 0.3s ease;
    color: #666;
}

.custom-dropdown.active .dropdown-arrow {
    transform: rotate(180deg);
}

.custom-dropdown .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.custom-dropdown.active .dropdown-menu {
    display: block;
}

.custom-dropdown .dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 1.3rem;
    color: #333;
    background: white;
    border: none;
    width: 100%;
    text-align: left;
    transition: background-color 0.2s ease;
    text-transform: uppercase;
}

.custom-dropdown .dropdown-item:hover {
    background-color: #f8f9fa;
    color: var(--primary-color);
}

.custom-dropdown .dropdown-item.active {
    background-color: var(--primary-color);
    color: white;
}

.custom-dropdown .dropdown-group-label {
    padding: 8px 16px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #666;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
    text-transform: uppercase;
}

/* Información de resultados */
.info-resultados {
    margin-bottom: 2rem;
}

.productos-count {
    font-size: 1.4rem;
    color: #666;
    font-weight: 400;
}

/* Responsive para móviles */
@media (max-width: 768px) {
    .header-productos {
        flex-direction: column;
        align-items: flex-start;
        gap: 2rem;
    }
    
    .filtros-linea {
        flex-direction: column;
        align-items: stretch;
        gap: 1.5rem;
        width: 100%;
    }
    
    .custom-dropdown {
        width: 100%;
    }
    
    .custom-dropdown .dropdown-label {
        width: 100%;
        min-width: auto;
    }
    
    .titulo-seccion {
        font-size: 2.8rem;
    }
}

/* Grid de productos */
.grid-productos {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2.5rem;
    margin-top: 2rem;
    margin-bottom: 5rem;
    justify-items: center;
    align-items: stretch;
    padding: 2rem 0;
    min-height: 600px; /* Altura fija para mantener el layout */
    position: relative; /* Para posicionar el mensaje absoluto */
}

/* Mensaje centrado en toda la pantalla cuando no hay productos */
.mensaje-no-productos {
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    width: 100%;
    text-align: center;
}

.mensaje-no-productos p {
    font-size: 1.8rem;
    color: #6c757d;
    font-weight: 400;
    text-align: center;
    margin: 0;
    line-height: 1.4;
}

/* Tarjetas transparentes para mantener el grid cuando no hay productos */
.producto-card-transparente {
    display: flex;
    flex-direction: column;
    height: 100%;
    align-items: center;
    text-align: center;
    min-height: 450px; /* Misma altura que tarjetas normales */
    width: 100%; /* Responsivo */
    max-width: 379.98px; /* Mismo ancho máximo que tarjetas normales */
}

.producto-card-transparente.invisible {
    visibility: hidden; /* Invisible pero ocupa espacio en el grid */
}

@media (max-width: 900px) {
    .grid-productos {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .mensaje-no-productos p {
        font-size: 1.5rem;
    }
}

@media (max-width: 600px) {
    .grid-productos {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        padding: 1rem 0;
        margin-top: 1rem;
        margin-bottom: 3rem;
        width: 100%;
        box-sizing: border-box;
    }
    
    .producto-imagen-container {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
        max-width: none; /* Sin límite máximo en móvil */
    }
    
    .producto-card {
        width: 100%;
        max-width: none; /* Sin límite máximo en móvil */
        box-sizing: border-box;
    }
    
    .producto-card-transparente {
        min-height: 300px;
        width: 100%;
        max-width: none; /* Sin límite máximo en móvil */
    }
    
    .mensaje-no-productos p {
        font-size: 1.3rem;
        padding: 0 1rem;
    }
    
    .producto-nombre {
        font-size: 1.1rem;
        padding-top: 0.6rem;
    }
    
    .producto-precio {
        font-size: 1.1rem;
        padding-top: 0.4rem;
    }
    
    .btn-ver-producto {
        font-size: 0.9rem;
        padding: 0.5em 0;
        margin-top: 0.6rem;
    }
    
    .btn-destacado {
        width: 32px;
        height: 32px;
        font-size: 1.2rem;
        top: 6px;
        right: 6px;
    }
}

@media (max-width: 480px) {
    .grid-productos {
        gap: 0.8rem;
        padding: 0.5rem 0;
        grid-template-columns: repeat(2, 1fr); /* Mantener 2 columnas */
        width: 100%;
    }
    
    .producto-imagen-container {
        width: 100%;
        max-width: none;
    }
    
    .producto-card {
        width: 100%;
        max-width: none;
    }
    
    .producto-nombre {
        font-size: 1rem;
        padding-top: 0.5rem;
    }
    
    .producto-precio {
        font-size: 1rem;
        padding-top: 0.3rem;
    }
    
    .btn-ver-producto {
        font-size: 0.85rem;
        padding: 0.4em 0;
        margin-top: 0.5rem;
    }
}

/* Tarjetas de productos */
.producto-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    align-items: center;
    text-align: center;
    width: 100%; /* Responsivo */
    max-width: 379.98px; /* Máximo en desktop */
    box-sizing: border-box;
}

/* Contenedor de imagen con posición relativa para la estrella */
.producto-imagen-container {
    position: relative;
    display: inline-block;
    width: 100%;
    aspect-ratio: 1; /* Mantiene proporción cuadrada */
    overflow: hidden; /* Para que el zoom de la imagen no se salga del contenedor */
    background: #f3f3f3;
    max-width: 379.98px; /* Máximo en desktop */
}

/* Botón de estrella destacado */
.btn-destacado {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.6rem;
    color: #ddd;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.btn-destacado:hover {
    background: rgba(255, 255, 255, 1);
    color: #ffd700;
    transform: scale(1.1);
}

.btn-destacado.destacado {
    color: #ffd700;
    background: rgba(255, 255, 255, 1);
}

.btn-destacado.destacado:hover {
    color: #ffed4e;
}

/* Contenedor para el contenido variable de la tarjeta */
.producto-info {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    text-align: center;
}

/* Imagen cuadrada y recortada */
.producto-card img,
.producto-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: transparent;
    margin: 0 0 0.5rem 0;
    display: block;
    border-radius: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    transition: transform 0.25s cubic-bezier(.4,1.5,.5,1), box-shadow 0.25s cubic-bezier(.4,1.5,.5,1);
}

/* Zoom suave solo dentro del contenedor, sin cambiar el tamaño del contenedor */
.producto-img-link:hover .producto-img,
.producto-imagen-container:hover .producto-img {
    transform: scale(1.08);
    z-index: 2;
    box-shadow: 0 4px 24px rgba(0,0,0,0.10);
}

.producto-nombre{
    font-size: 1.5rem;
    font-weight: 400;
    flex: 1 1 auto;
    word-break: break-word;
    white-space: normal;
    padding-top: 1.2rem;
    color: var(--dark-text);
}

.producto-precio{
    font-size: 1.5rem;
    font-weight: 400;
    flex: 0 0 auto;
    color: var(--dark-text);
    padding-top: 1rem;
}

.btn-ver-producto {
    display: block;
    width: 100%;
    background: var(--primary-color);
    color: #fff;
    text-align: center;
    padding: 0.7em 0;
    border-radius: 4px;
    text-decoration: none;
    font-size: 1.2rem;
    margin-top: 1rem;
    transition: background 0.2s;
}

.btn-ver-producto:hover {
    background: var(--primary-color-hover);
}

/* Modales y botones */
.modal-overlay {
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
}

.modal-content {
    background: #fafafa;
    padding: 2rem;
    border-radius: 12px;
    max-width: 800px;
    width: 90%;
    max-height: 85vh;
    margin: auto;
    position: relative;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: modalAppear 0.3s ease-out;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    cursor: pointer;
    font-size: 1.8rem;
    color: #666;
    transition: color 0.3s ease;
    z-index: 10;
}

.modal-close:hover {
    color: #333;
}

/* Animación para el modal */
@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-50px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Título del modal */
.modal-content h2 {
    margin: 0 0 1.5rem 0;
    padding-bottom: 1rem;
    border-bottom: 2px solid #eee;
    color: var(--primary-color);
    font-size: 1.8rem;
    font-weight: 600;
    text-align: center;
}

.modal-actions {
    width: 100%;
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #eee;
}

.modal-actions button {
    flex: 1;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-actions .btn-agregar,
.modal-actions .btn-guardar {
    background-color: var(--primary-color);
    color: white;
}

.modal-actions .btn-agregar:hover,
.modal-actions .btn-guardar:hover {
    background-color: var(--primary-color-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-cancelar {
    background-color: #6c757d;
    color: white;
    transition: all 0.3s ease;
}

.btn-cancelar:hover {
    background-color: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.mensaje-exito {
    display: none;
    color: green;
    margin-top: 1rem;
}

/* Desactivar resize en textarea de descripción */
textarea[name='descripcion'] {
  resize: none;
  height: 160px;
}

/* Estilos para textareas de descripción corta y medidas */
textarea[name='descripcion_corta'] {
  resize: vertical;
  height: 80px;
  min-height: 60px;
}

textarea[name='medidas'] {
  resize: vertical;
  height: 100px;
  min-height: 80px;
}

/* Estilos para campos de precio */
.help-text {
  display: block;
  font-size: 0.85rem;
  color: #666;
  margin-top: 0.25rem;
  font-style: italic;
}

.precio-calculado {
  background-color: #f8f9fa;
  border: 2px solid #28a745;
  border-radius: 6px;
  padding: 1rem;
  margin: 1rem 0;
  text-align: center;
  font-size: 1.1rem;
}

.precio-calculado strong {
  color: #28a745;
}

/* Checkbox de IVA */
input[type="checkbox"] {
  margin-right: 0.5rem;
  transform: scale(1.2);
}

label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: 500;
}

/* Estilos para botones consistentes */
.btn-agregar, .btn-eliminar, .btn-editar {
    border: none;
    border-radius: 4px;
    padding: 0.8rem 1.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
    display: inline-block;
    font-weight: 500;
}

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

.btn-agregar:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.btn-eliminar {
    background-color: #d86461;
    color: white;
}

.btn-eliminar:hover {
    background-color: #c55653;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.btn-editar {
    background-color: #868e96;
    color: white;
}

.btn-editar:hover {
    background-color: #6c757d;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Contenedor de botones principales */
.botones-admin {
    text-align: center;
    margin-bottom: 2rem;
    margin-top: 5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Botones en las tarjetas de productos */
.botones-producto {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.botones-producto .btn-editar,
.botones-producto .btn-eliminar {
    flex: 1;
    padding: 0.6rem;
    font-size: 0.9rem;
}

/* Estilos específicos para formularios en modales */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.7rem;
    font-weight: 600;
    color: #333;
    font-size: 1rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.8rem;
    border-radius: 6px;
    border: 2px solid #ddd;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(75, 89, 69, 0.1);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-group input.no-spin::-webkit-outer-spin-button,
.form-group input.no-spin::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.form-group input.no-spin {
    appearance: textfield;
    -moz-appearance: textfield;
}

/* Estilos para upload de imágenes */
.image-upload-container {
    width: 100%;
}

.image-upload-box {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    background-color: #f9f9f9;
    transition: all 0.3s ease;
}

.image-upload-box:hover {
    border-color: #007bff;
    background-color: #f0f8ff;
}

.upload-icon {
    font-size: 2em;
    color: #666;
    margin-bottom: 10px;
}

.upload-text {
    color: #666;
    font-size: 0.9em;
}

.upload-text small {
    color: #999;
    font-size: 0.8em;
}

/* Mensajes de error */
.mensaje-error {
    color: red;
    margin-bottom: 1em;
    text-align: center;
    display: none;
}

/* Estilos para texto de confirmación */
#textoConfirmarEliminarProducto {
    margin-bottom: 1.5em;
}

.btn-restaurar-imagen i {
    font-size: 0.8em;
}

/* Estilos para badges de tipo de producto */
.producto-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.badge-planta {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
}

.badge-material {
    background: linear-gradient(135deg, #6f42c1, #007bff);
    margin: 0 0 1rem 0;
}

/* Media queries para responsividad del modal */
@media (max-width: 1200px) {
    .modal-content {
        max-width: 700px;
        width: 92%;
    }
}

@media (max-width: 768px) {
    .modal-content {
        max-width: 95%;
        width: 95%;
        max-height: 90vh;
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .modal-overlay {
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .modal-content {
        width: 98%;
        max-height: 95vh;
        padding: 1rem;
        border-radius: 8px;
    }
    
    .modal-overlay {
        padding: 0.25rem;
    }
    
    .modal-close {
        top: 10px;
        right: 15px;
        font-size: 1.5rem;
    }
}

@media (max-height: 600px) {
    .modal-content {
        max-height: 95vh;
        padding: 1rem;
    }
}

/* Asegurar que las cards tengan posición relativa para los badges */
.producto-card {
    position: relative;
}

/* Estilos adicionales para la categoría en Ver Todo */
.producto-categoria {
    font-size: 0.9rem;
    color: #666;
    margin: 5px 0;
    font-weight: 500;
}

/* Ajustes responsivos para badges */
@media (max-width: 768px) {
    .producto-badge {
        top: 8px;
        right: 8px;
    }
    
    .badge {
        padding: 5px 10px;
        font-size: 0.7rem;
    }
}