.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
}

.modal-content {
    background: #ffffff;
    /* Reduje el margen superior para aprovechar el espacio y aumenté el ancho */
    margin: 5% auto; 
    width: 90%;
    max-width: 900px; /* Antes era 500px */
    max-height: 90vh; /* Limita la altura al 90% de la pantalla */
    border-radius: 12px;
    color: #222;
    position: relative;
    animation: fadeIn 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Evita que el contenedor principal se rompa */
}

.close {
    position: absolute;
    top: 12px;
    right: 15px;
    font-size: 26px;
    cursor: pointer;
    z-index: 10; /* Asegura que la "X" siempre sea clickeable por encima del texto */
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

.modal-product-details {
    display: flex;
    gap: 20px;
    padding: 30px 25px 15px; /* El padding se movió aquí para el scroll */
    overflow-y: auto; /* ESTA ES LA CLAVE: Crea un scroll si el texto es muy largo */
}

.modal-image-placeholder {
    width: 40%;
    height: 350px;
    background-color: #eee;
    background-size: contain;
    background-position: center;
    border-radius: var(--border-radius);
    background-repeat: no-repeat;
}

.modal-info-text {
    width: 60%;
    display: flex;
    flex-direction: column;
}

.modal-info-text h3 {
    font-size: 1.8em;
    color: var(--color-primary);
    margin-bottom: 5px;
    margin-top: 0;
}

.modal-price-display {
    font-size: 1.4em;
    font-weight: 700;
    margin-bottom: 15px;
}

.modal-price-display #modal-price {
    color: var(--color-accent);
}

.modal-stock-label {
    font-weight: 700;
    margin-bottom: 10px;
}

.stock-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.size-option {
    padding: 10px 5px;
    border: 1px solid #ddd;
    text-align: center;
    border-radius: 5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.size-option.available {
    background-color: white;
    color: var(--color-text);
}

.size-option.unavailable {
    background-color: #f4f4f4;
    color: #999;
    cursor: not-allowed;
    text-decoration: line-through;
}

.size-option:not(.unavailable):hover {
    border-color: var(--color-primary);
    background-color: #e6e6e6;
}

.size-option.selected {
    background-color: #ffe0e0;
    border-color: var(--color-accent) !important;
    box-shadow: 0 0 5px rgba(255, 0, 0, 0.5);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 25px;
    border-top: 1px solid #eee;
    background-color: #fff; /* Fondo blanco para que no se mezcle con el scroll */
}

.modal-admin {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
}

.modal-content-admin {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 900px;
    border-radius: 8px;
    position: relative;
}

.close-admin-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-admin-btn:hover,
.close-admin-btn:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

.admin-float-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* --- NUEVO: RESPONSIVE PARA MÓVILES --- */
@media (max-width: 768px) {
    .modal-product-details {
        flex-direction: column; /* Apila la imagen arriba y el texto abajo */
        overflow-y: auto;       /* El scroll general del modal por si la pantalla es muy pequeña */
        padding: 20px 15px;
        max-height: 70vh;       /* Evita que se estire más allá de los botones inferiores */
    }
    
    .modal-image-placeholder {
        width: 100%;
        height: 220px;          /* Altura fija para que no se oculte */
        min-height: 220px;      /* CRUCIAL: Evita que el texto largo la encoja a 0px */
        background-size: contain;
        background-repeat: no-repeat;
        margin-bottom: 15px;    /* Separa la imagen del título */
    }
    
    .modal-info-text {
        width: 100%;
        flex-shrink: 0;         /* Evita que el contenedor de texto colapse */
    }

    /* Opcional: Reducir un poco el tamaño de la letra en celular para ganar espacio */
    .modal-info-text h3 {
        font-size: 1.5em;
    }
}

#modal-description {
    white-space: pre-line; /* Esta es la magia que respeta tus saltos de línea */
    line-height: 1.6;      /* Da un poco de espacio entre los renglones para que se lea mejor */
    color: #444;           /* Un gris oscuro cansa menos la vista que el negro puro */
}