* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.contenedor-galeria {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 1200px;
    width: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    height: auto;
    max-height: 90vh;
}

/* Encabezado */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 28px;
    font-weight: 600;
}

.btn-salir {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-salir:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Contenedor de imágenes */
.galeria-contenedor {
    height: auto;
    overflow: visible;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #f8f9fa;
    min-height: auto;
    padding: 30px;
    gap: 0;
}

.imagenes-wrapper {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    width: 100%;
    max-width: 600px;
    height: auto;
    auto-rows: auto;
    flex: 0 0 auto;
}

.imagen-item {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    background: white;
    width: 100%;
    height: 400px;
}

.imagen-item:hover {
    transform: scale(1.05);
}

.imagen-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.imagen-item.seleccionada {
    border: 4px solid #28a745;
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
}

.imagen-item.seleccionada::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    background: #28a745;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.nombre-imagen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mensaje-titulo {
    color: white;
    font-size: 8px;
}

.vacio {
    background: #e9ecef;
    border: 2px dashed #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 16px;
    border-radius: 10px;
}

/* Controles */
.controles {
    background: white;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    border-top: 1px solid #e0e0e0;
}

.btn-control {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    min-width: 100px;
}

.btn-control:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-control:active {
    transform: translateY(0);
}

.btn-control:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.contador {
    font-weight: 600;
    color: #667eea;
    font-size: 16px;
    min-width: 80px;
    text-align: center;
}

/* Indicador de página */
.indicador-pagina {
    display: flex;
    justify-content: center;
    align-content: center;
    gap: 8px;
    padding: 15px 10%;
    margin: 10px 0;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    flex-wrap: wrap;
}

.punto {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ccc;
    cursor: pointer;
    transition: all 0.3s ease;
}

.punto.activo {
    background: #667eea;
    transform: scale(1.3);
}

.punto:hover {
    background: #667eea;
}

/* Responsive - Tableta */
@media (max-width: 1024px) {
    .imagenes-wrapper {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .header h1 {
        font-size: 24px;
    }

    .galeria-contenedor {
        min-height: 350px;
        padding: 20px;
    }
}

/* Responsive - Celular */
@media (max-width: 768px) {
    .contenedor-galeria {
        max-height: 100vh;
        border-radius: 0;
    }

    .imagenes-wrapper {
        grid-template-columns: 1fr;
        gap: 15px;
        max-width: 100%;
    }

    .header {
        padding: 15px;
    }

    .header h1 {
        font-size: 20px;
    }

    .btn-salir {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .galeria-contenedor {
        min-height: 400px;
        padding: 15px;
    }

    .imagen-item {
        height: 300px;
    }

    .controles {
        padding: 15px 10px;
        gap: 8px;
    }

    .btn-control {
        padding: 10px 15px;
        font-size: 12px;
        min-width: 80px;
    }

    .contador {
        font-size: 14px;
        min-width: 70px;
    }

    .nombre-imagen {
        font-size: 11px;
        padding: 8px;
    }
}

/* Responsive - Celular pequeño */
@media (max-width: 480px) {
    .header h1 {
        font-size: 18px;
    }

    .btn-control {
        padding: 8px 12px;
        font-size: 11px;
        min-width: 70px;
    }

    .contador {
        font-size: 12px;
        min-width: 60px;
    }

    .controles {
        gap: 5px;
        padding: 10px 5px;
    }

    .indicador-pagina {
        padding: 10px;
        gap: 6px;
    }

    .punto {
        width: 8px;
        height: 8px;
    }
}

/* Panel de selección: scroll fijo para no encoger la imagen */
#seleccionPanel {
    width: 100%;
    max-width: 600px;
    max-height: 220px;
    overflow-y: auto;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    #seleccionPanel { max-height: 140px; }
}

.seleccion-panel {
    background: white;
    padding: 15px;
    border-top: 1px solid #e0e0e0;
    width: 100%;
    max-width: 600px;
}

.seleccion-titulo {
    margin-bottom: 10px;
}

.seleccion-lista {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.seleccion-item {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.btn-eliminar-item {
    margin-left: 10px;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
}

.modal-overlay-seleccion { z-index: 1000; }
.modal-overlay-email { z-index: 1100; }
.modal-overlay-codigo { z-index: 1200; }
.modal-overlay-exito { z-index: 1300; }

.modal-card {
    background: white;
    border-radius: 8px;
    padding: 16px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-card-420 { max-width: 420px; }
.modal-card-480 { max-width: 480px; }

.modal-card-center {
    text-align: center;
    padding: 20px;
}

.modal-main-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.modal-img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    border-radius: 6px;
    background: #f5f5f5;
}

.modal-flex-1 {
    flex: 1;
}

.modal-nombre {
    font-weight: 700;
    margin-bottom: 8px;
}

.modal-label {
    display: block;
    margin-bottom: 6px;
}

.modal-select {
    margin-left: 8px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 12px;
}

.modal-actions-tight {
    gap: 8px;
}

.modal-input {
    width: 100%;
    padding: 8px;
    margin-bottom: 8px;
}

.btn-continuar {
    min-width: 120px;
    background: #4CAF50;
}

.btn-finalizar {
    min-width: 160px;
    background: #FF5722;
}

.btn-cancelar {
    background: #ccc;
    color: #000;
}

.btn-cerrar-x {
    min-width: 40px;
}

.btn-enviar-codigo {
    background: #667eea;
}

.btn-verificar {
    background: #28a745;
}

.modal-exito-titulo {
    color: #28a745;
    margin-bottom: 10px;
}

.modal-exito-mensaje {
    font-weight: bold;
    margin: 15px 0;
}

.modal-exito-nota {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
}

.btn-finalizar-exito {
    background: #667eea;
    width: 100%;
    padding: 12px;
}

.vacio-full {
    grid-column: 1 / -1;
    height: 400px;
}

.vacio-texto {
    text-align: center;
}

.vacio-titulo {
    margin-bottom: 10px;
}
