/* ==========================================================================
   Galería de imágenes reutilizable (admin: relevamientos y registros informe)
   ========================================================================== */

.images-gallery {
    width: 100%;
}

.images-gallery .gallery-toolbar {
    padding: 6px 4px;
    border-bottom: 1px solid #eaeaea;
}

.images-gallery .gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    padding: 8px 4px;
    min-height: 120px;
    border-radius: 6px;
    transition: background-color 0.15s ease;
}

.images-gallery.is-dragover .gallery-grid {
    background-color: #eaf4ff;
    outline: 2px dashed #3d8bfd;
    outline-offset: -4px;
}

.images-gallery .gallery-empty {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    font-style: italic;
    border: 1px dashed #d0d0d0;
    border-radius: 6px;
}

.images-gallery .gallery-item {
    position: relative;
    aspect-ratio: 4 / 3;
    border-radius: 6px;
    overflow: hidden;
    background-color: #f4f4f4;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.images-gallery .gallery-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.images-gallery .gallery-item.is-selected {
    outline: 3px solid #28a745;
    outline-offset: -3px;
}

.images-gallery .gallery-item.is-busy {
    pointer-events: none;
}
.images-gallery .gallery-item.is-busy::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.55);
    z-index: 3;
}
.images-gallery .gallery-item.is-busy::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    border: 2px solid rgba(0, 0, 0, 0.15);
    border-top-color: #0056b3;
    border-radius: 50%;
    z-index: 4;
    animation: gallery-spin 0.6s linear infinite;
}
@keyframes gallery-spin {
    to { transform: rotate(360deg); }
}
.images-gallery .gallery-item.is-just-rotated {
    animation: gallery-flash 0.4s ease;
}
@keyframes gallery-flash {
    0% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); }
    100% { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
}

.images-gallery .gallery-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
}

.images-gallery .gallery-actions {
    position: absolute;
    inset: auto 0 0 0;
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 4px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.images-gallery .gallery-item:hover .gallery-actions,
.images-gallery .gallery-item:focus-within .gallery-actions {
    opacity: 1;
}

/* Touch / sin hover: acciones siempre visibles */
@media (hover: none), (pointer: coarse) {
    .images-gallery .gallery-actions {
        opacity: 1;
    }
}

.images-gallery .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.92);
    color: #333;
    font-size: 12px;
    cursor: pointer;
    text-decoration: none;
    line-height: 1;
    transition: background-color 0.1s ease, color 0.1s ease;
}

.images-gallery .btn-icon:hover {
    background: #fff;
    color: #0056b3;
}

.images-gallery .btn-icon-danger:hover {
    background: #dc3545;
    color: #fff;
}

.images-gallery .btn-undo-replace,
.images-gallery .btn-undo-delete {
    display: none;
    background: #fff3cd;
    color: #856404;
}
.images-gallery .btn-undo-replace:hover,
.images-gallery .btn-undo-delete:hover {
    background: #ffc107;
    color: #333;
}

/* Reemplazo pendiente */
.images-gallery .gallery-item.is-pending-replace .gallery-actions [data-action="replace"],
.images-gallery .gallery-item.is-pending-replace .gallery-actions [data-action="delete"] {
    display: none;
}
.images-gallery .gallery-item.is-pending-replace .btn-undo-replace {
    display: inline-flex;
}

/* Borrado pendiente (fantasma) */
.images-gallery .gallery-item.is-pending-delete {
    opacity: 0.55;
    outline: 3px solid #dc3545;
    outline-offset: -3px;
}
.images-gallery .gallery-item.is-pending-delete .gallery-thumb {
    filter: grayscale(0.6);
}
.images-gallery .gallery-item.is-pending-delete::after {
    content: 'Se borrará';
    position: absolute;
    top: 6px;
    right: 6px;
    background: #dc3545;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    z-index: 2;
}
.images-gallery .gallery-item.is-pending-delete .gallery-actions [data-action="rotate"],
.images-gallery .gallery-item.is-pending-delete .gallery-actions [data-action="replace"],
.images-gallery .gallery-item.is-pending-delete .gallery-actions [data-action="delete"],
.images-gallery .gallery-item.is-pending-delete .gallery-actions [data-action="download"] {
    display: none;
}
.images-gallery .gallery-item.is-pending-delete .btn-undo-delete {
    display: inline-flex;
}
.images-gallery .gallery-item.is-pending-delete .gallery-actions {
    opacity: 1;
}

/* Checkbox de selección (arriba a la izquierda) */
.images-gallery .gallery-checkbox {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 2;
    margin: 0;
    cursor: pointer;
}

.images-gallery .gallery-checkbox input {
    position: absolute;
    opacity: 0;
    width: 22px;
    height: 22px;
    margin: 0;
    cursor: pointer;
}

.images-gallery .gallery-checkbox-mark {
    display: inline-block;
    width: 22px;
    height: 22px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #6c757d;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    position: relative;
    transition: background-color 0.1s ease, border-color 0.1s ease;
}

.images-gallery .gallery-checkbox input:checked + .gallery-checkbox-mark {
    background: #28a745;
    border-color: #28a745;
}

.images-gallery .gallery-checkbox input:checked + .gallery-checkbox-mark::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Lightbox */
.gallery-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    cursor: zoom-out;
}

.gallery-lightbox.is-open {
    display: flex;
}

.gallery-lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    cursor: default;
}

.gallery-lightbox .lightbox-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 30px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.85;
}

.gallery-lightbox .lightbox-close:hover {
    opacity: 1;
}

.gallery-lightbox .lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.85;
}

.gallery-lightbox .lightbox-nav:hover { opacity: 1; background: rgba(255, 255, 255, 0.3); }
.gallery-lightbox .lightbox-prev { left: 16px; }
.gallery-lightbox .lightbox-next { right: 16px; }

.gallery-lightbox .lightbox-counter {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.04em;
    opacity: 0.9;
    pointer-events: none;
}

/* Utilidades */
.images-gallery .gap-2 { gap: 0.5rem; }

/* ==========================================================================
   Estilos específicos del listado /actividadesOperarios (admin)
   ========================================================================== */
#tableActividadesAdmin {
    font-size: 0.9rem;
    table-layout: fixed;
}
#tableActividadesAdmin tbody tr { cursor: pointer; }
#tableActividadesAdmin tbody tr:hover td { background-color: #f0f7ff; }
#tableActividadesAdmin td,
#tableActividadesAdmin th { vertical-align: middle; }
#tableActividadesAdmin td { word-wrap: break-word; overflow-wrap: anywhere; }
#tableActividadesAdmin th.col-acciones,
#tableActividadesAdmin td.col-acciones {
    position: sticky;
    right: 0;
    background-color: #fff;
    box-shadow: -3px 0 4px -3px rgba(0,0,0,0.15);
    z-index: 1;
}
#tableActividadesAdmin img.thumb-mini,
.thumb-mini {
    width: 48px !important;
    height: 48px !important;
    max-width: 48px !important;
    max-height: 48px !important;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    display: inline-block;
}
#tableActividadesAdmin img.thumb-mini[data-fotos] {
    cursor: zoom-in;
}
#tableActividadesAdmin img.thumb-mini[data-fotos]:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    outline: 2px solid #3d8bfd;
    outline-offset: 1px;
}
.thumb-mini-empty {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    background: #f0f0f0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #bbb;
}
.badge-estado { font-size: 11px; padding: 4px 8px; }
/* Dato que se muestra pero no se edita y puede ocupar más de una línea (ej. planta en los modales del informe) */
.campo-solo-lectura {
    height: auto;
    min-height: calc(1.5em + .5rem + 2px);
    background-color: #e9ecef;
}
.filtros-bar {
    background: #f9fafb;
    border: 1px solid #eaeaea;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 14px;
}
.actividad-badge {
    font-size: 11px;
    padding: 3px 6px;
    background: #e7f1ff;
    color: #0056b3;
    border-radius: 3px;
}

/* Modal detalle: estado bloqueado/desbloqueado */
#form-detalleActividad.is-locked {
    background: #f7f7f7;
    border: 1px dashed #ccc;
    border-radius: 6px;
    padding: 12px;
    position: relative;
}
#form-detalleActividad.is-locked::before {
    content: '\f023  BLOQUEADO — Apretá "Habilitar edición" arriba para modificar';
    font-family: 'Font Awesome 5 Free', 'FontAwesome', sans-serif;
    font-weight: 900;
    display: block;
    background: #fff3cd;
    color: #856404;
    border-left: 3px solid #ffc107;
    padding: 6px 12px;
    margin: -12px -12px 12px -12px;
    border-radius: 6px 6px 0 0;
    font-size: 12px;
}
#form-detalleActividad.is-locked input:disabled,
#form-detalleActividad.is-locked select:disabled,
#form-detalleActividad.is-locked textarea:disabled {
    background-color: #eef0f2 !important;
    color: #6c757d !important;
    cursor: not-allowed;
    opacity: 1;
}
#form-detalleActividad.is-unlocked {
    background: #eaf7ea;
    border: 1px solid #28a745;
    border-radius: 6px;
    padding: 12px;
}
#form-detalleActividad.is-unlocked::before {
    content: '\f09c  EDICIÓN HABILITADA — recordá "Guardar cambios" al final';
    font-family: 'Font Awesome 5 Free', 'FontAwesome', sans-serif;
    font-weight: 900;
    display: block;
    background: #d4edda;
    color: #155724;
    border-left: 3px solid #28a745;
    padding: 6px 12px;
    margin: -12px -12px 12px -12px;
    border-radius: 6px 6px 0 0;
    font-size: 12px;
}

/* Tabs del modal detalle de actividad */
#modalActividadDetalle .nav-tabs {
    border-bottom: 1px solid #dee2e6;
}
#modalActividadDetalle .nav-tabs .nav-link {
    color: #555;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 0.6rem 1rem;
}
#modalActividadDetalle .nav-tabs .nav-link.active {
    color: #155724;
    background: transparent;
    border-bottom-color: #28a745;
    font-weight: 600;
}
#modalActividadDetalle .nav-tabs .nav-link:hover {
    border-bottom-color: #adb5bd;
}
#modalActividadDetalle .modal-body {
    min-height: 320px;
}

/* Tabs de modales del informe */
#modalEditarActividad .nav-tabs,
#modalEditarRegistro .nav-tabs {
    border-bottom: 1px solid #dee2e6;
}
#modalEditarActividad .nav-tabs .nav-link,
#modalEditarRegistro .nav-tabs .nav-link {
    color: #555;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 0.6rem 1rem;
}
#modalEditarActividad .nav-tabs .nav-link.active,
#modalEditarRegistro .nav-tabs .nav-link.active {
    color: #155724;
    background: transparent;
    border-bottom-color: #28a745;
    font-weight: 600;
}
#modalEditarActividad .modal-body,
#modalEditarRegistro .modal-body {
    min-height: 300px;
}

/* Acciones de la tabla de registros del informe */
#tableRegistrosInforme td .d-inline-flex {
    white-space: nowrap;
}
#tableRegistrosInforme td .badge {
    line-height: 1.4;
    padding: 0.35em 0.5em;
}

/* Reemplazo pendiente (aún no guardado) */
.images-gallery .gallery-item.is-pending-replace {
    outline: 3px solid #ffc107;
    outline-offset: -3px;
}
.images-gallery .gallery-item.is-pending-replace::after {
    content: 'Pendiente';
    position: absolute;
    top: 6px;
    right: 6px;
    background: #ffc107;
    color: #333;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    z-index: 2;
}
.images-gallery .gallery-item.is-pending-replace .gallery-actions {
    opacity: 1;
}
