/* ============================================================
   MÓDULO DOCUMENTACIÓN
   ============================================================ */

.doc-module {
    position: relative;
}

/* ---- Header ---- */
.doc-module .module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    flex-wrap: wrap;
    gap: 8px;
}

.doc-module .module-header h2 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-color, #0a2463);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.doc-header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

/* ---- Botones principales ---- */
.btn-doc {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 13px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.18s;
    font-family: inherit;
    line-height: 1.4;
}

.btn-nueva-carpeta {
    background: var(--accent-color, #0a2463);
    color: white;
}
.btn-nueva-carpeta:hover { opacity: 0.88; }

.btn-subir-archivo {
    background: #3498db;
    color: white;
    cursor: pointer;
}
.btn-subir-archivo:hover { background: #2980b9; }

.btn-camara {
    background: #27ae60;
    color: white;
    cursor: pointer;
}
.btn-camara:hover { background: #219a52; }

.btn-pegar {
    background: #8e44ad;
    color: white;
}
.btn-pegar:hover { background: #7d3c98; }

.btn-doc-confirm {
    background: var(--accent-color, #0a2463);
    color: white;
}
.btn-doc-confirm:hover { opacity: 0.88; }

.btn-doc-cancel {
    background: #f1f5f9;
    color: #475569;
}
.btn-doc-cancel:hover { background: #e2e8f0; }

.btn-doc-danger {
    background: #e74c3c;
    color: white;
}
.btn-doc-danger:hover { background: #c0392b; }

/* Sube la foto y vuelve a abrir la cámara. Lleva el verde del botón Cámara
   porque es a donde devuelve, y así se distingue del Subir Foto que cierra. */
.btn-doc-otra {
    background: #27ae60;
    color: white;
}
.btn-doc-otra:hover { background: #219a52; }

/* ---- Breadcrumb ---- */
.doc-breadcrumb {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
    margin-bottom: 8px;
    font-size: 0.78rem;
}

.doc-bc-item {
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 4px;
    color: var(--accent-color, #3498db);
    font-weight: 600;
    transition: background 0.15s;
    white-space: nowrap;
}
.doc-bc-item:hover { background: rgba(52,152,219,0.1); }
.doc-bc-current {
    color: #64748b;
    cursor: default;
    font-weight: 400;
}
.doc-bc-current:hover { background: transparent; }
.doc-bc-sep { color: #cbd5e1; font-size: 0.6rem; padding: 0 1px; }

/* ---- Toolbar ---- */
.doc-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.doc-count {
    font-size: 0.72rem;
    color: #94a3b8;
}

.doc-view-toggle {
    display: flex;
    gap: 2px;
    background: #f1f5f9;
    border-radius: 6px;
    padding: 2px;
}

.btn-view-toggle {
    background: none;
    border: none;
    padding: 5px 9px;
    border-radius: 4px;
    cursor: pointer;
    color: #94a3b8;
    font-size: 0.82rem;
    transition: all 0.15s;
    line-height: 1;
}
.btn-view-toggle.active {
    background: white;
    color: var(--accent-color, #0a2463);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ---- Contenido ---- */
.doc-content { min-height: 180px; }

.doc-section { margin-bottom: 18px; }

.doc-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
    margin-bottom: 7px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ---- Grid (cards) ---- */
.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 10px;
}

/* ---- Lista ---- */
.doc-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* ---- Card: común ---- */
.doc-item-card {
    background: white;
    border-radius: 10px;
    padding: 14px 10px 8px;
    border: 1px solid #e5e7eb;
    transition: all 0.18s;
    position: relative;
    text-align: center;
    overflow: hidden;
}

.doc-folder-item.doc-item-card {
    cursor: pointer;
}
.doc-folder-item.doc-item-card:hover {
    border-color: var(--accent-color, #0a2463);
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}
.doc-file-item.doc-item-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}

.doc-card-icon {
    font-size: 2.4rem;
    margin-bottom: 8px;
    border-radius: 8px;
    padding: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.doc-card-thumb {
    width: 100%;
    height: 120px;
    overflow: hidden;
    border-radius: 7px;
    margin-bottom: 8px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* contain y no cover: la caja es apaisada y con cover un documento vertical se
   recorta a una franja del centro, que se lee como si no estuviera rotado.
   image-orientation deja explícito que se respete la orientación EXIF de las
   fotos de teléfono, para que la miniatura coincida con la vista previa. */
.doc-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-orientation: from-image;
}
.doc-card-thumb.doc-thumb-error {
    color: #cbd5e1;
    font-size: 2rem;
}

.doc-card-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}

.doc-card-desc {
    font-size: 0.68rem;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}

.doc-card-meta {
    font-size: 0.65rem;
    color: #94a3b8;
}

.doc-card-actions {
    display: none;
    justify-content: center;
    gap: 3px;
    margin-top: 7px;
}
.doc-item-card:hover .doc-card-actions { display: flex; }

/* ---- Lista: común ---- */
.doc-item-list {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    background: white;
    border-radius: 6px;
    border: 1px solid #f1f5f9;
    transition: all 0.14s;
}
.doc-folder-item.doc-item-list { cursor: pointer; }
.doc-folder-item.doc-item-list:hover {
    border-color: var(--accent-color, #0a2463);
    background: #fafbff;
}
.doc-file-item.doc-item-list:hover { background: #fafbff; }

.doc-item-icon-wrap {
    font-size: 1.35rem;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.doc-item-thumb {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 5px;
    overflow: hidden;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* En la vista de lista la miniatura es un cuadro de 38px: ahí cover llena mejor
   que contain, que la dejaría diminuta. Solo se asegura la orientación. */
.doc-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-orientation: from-image;
}

.doc-item-info { flex: 1; min-width: 0; }

.doc-item-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-item-meta {
    font-size: 0.68rem;
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-item-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.14s;
    flex-shrink: 0;
}
.doc-item-list:hover .doc-item-actions { opacity: 1; }

/* ---- Botones ícono ---- */
.btn-doc-icon {
    background: none;
    border: none;
    cursor: pointer;
    width: 27px;
    height: 27px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: #64748b;
    font-size: 0.72rem;
    transition: all 0.14s;
}
.btn-doc-icon:hover { background: #f1f5f9; color: #1e293b; }
.btn-delete-folder:hover,
.btn-delete-file:hover  { background: #fee2e2; color: #dc2626; }
.btn-download-file      { text-decoration: none; }
.btn-download-file:hover { background: #dbeafe; color: #2563eb; }

/* ---- Empty state ---- */
.doc-empty {
    text-align: center;
    padding: 50px 20px;
    color: #94a3b8;
}
.doc-empty i { font-size: 3.5rem; display: block; margin-bottom: 10px; opacity: 0.35; }
.doc-empty p  { margin: 4px 0; font-size: 0.88rem; color: #64748b; }
.doc-empty-hint { font-size: 0.78rem; color: #cbd5e1 !important; }

/* ---- Drop zone ---- */
.doc-drop-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(52,152,219,0.1);
    border: 2px dashed #3498db;
    border-radius: 10px;
    z-index: 50;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.doc-drop-overlay.active {
    display: flex;
    pointer-events: all;
}
.doc-drop-message {
    text-align: center;
    color: #3498db;
    font-weight: 700;
}
.doc-drop-message i { font-size: 2.8rem; display: block; margin-bottom: 6px; }

/* ---- Modal ---- */
.doc-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.42);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.doc-modal {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    overflow: hidden;
    animation: docModalIn 0.18s ease;
}

@keyframes docModalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-8px); }
    to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* Variante ancha: la vista previa necesita espacio para leer el documento, no el
   ancho de un diálogo de confirmación. El modal genérico se queda en 420px.
   En móvil no aplica: ahí manda la hoja a pantalla completa de mobile.css. */
.doc-modal--lg {
    max-width: 900px;
}
.doc-modal--lg .doc-modal-body {
    max-height: 78vh;
    overflow-y: auto;
}
.doc-modal--lg .doc-preview-img {
    height: 70vh;
}

/* ---- Modal a pantalla completa (cámara) ----
   La cámara necesita toda la pantalla: encuadrar un documento dentro de un
   recuadro pequeño obliga a adivinar qué se está enfocando. El cuerpo pierde
   el relleno para que la imagen llegue a los bordes, y la cabecera y el pie se
   quedan fijos arriba y abajo. */
.doc-modal--full {
    max-width: 100%;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
}
.doc-modal--full .doc-modal-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    background: #000;
}
/* El overlay deja de acolchar: los 16px de siempre le robarían a la cámara un
   marco por los cuatro lados y sacarían el pie fuera de la pantalla. */
.doc-modal-overlay--full { padding: 0; }

/* El escenario ocupa lo que quede libre y centra la imagen; las bandas negras
   que sobren a los lados son del propio fondo. */
.doc-cam-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #000;
}

/* Su tamaño lo pone resizeCanvases() en píxeles, no el CSS: marco, imagen y
   guía tienen que ocupar la misma caja exacta para que las esquinas que se
   arrastran caigan donde se ven. */
.doc-cam-frame {
    position: relative;
}

.doc-cam-preview {
    display: block;
    width: 100%;
    height: 100%;
}

.doc-cam-guide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
}

.doc-cam-hints {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 14px;
    background: #111827;
}
.doc-cam-hints span         { font-size: 0.75rem; color: #d1d5db; }
.doc-cam-hints span:last-child { font-size: 0.72rem; color: #9ca3af; }

.doc-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid #f1f5f9;
}
.doc-modal-header h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: #0a2463;
}
.doc-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    font-size: 0.95rem;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.14s;
}
.doc-modal-close:hover { background: #f1f5f9; color: #475569; }

.doc-modal-body { padding: 18px; }

.doc-modal-footer {
    display: flex;
    justify-content: flex-end;
    /* Con tres botones —Cancelar, Otra foto, Subir— la fila no cabe en un
       teléfono estrecho: sin esto el primero se sale del modal. */
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 18px;
    border-top: 1px solid #f1f5f9;
    background: #fafbff;
}

/* ---- Formulario dentro del modal ---- */
.doc-form-group { margin-bottom: 13px; }
.doc-form-group:last-child { margin-bottom: 0; }
.doc-form-group label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
}

.doc-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.82rem;
    color: #1e293b;
    background: white;
    box-sizing: border-box;
    transition: border-color 0.14s;
    font-family: inherit;
}
.doc-input:focus {
    outline: none;
    border-color: var(--accent-color, #0a2463);
    box-shadow: 0 0 0 2px rgba(10,36,99,0.07);
}
.doc-textarea { resize: vertical; min-height: 68px; }

/* ---- Opciones de color ---- */
.doc-color-options {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}
.doc-color-opt {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.14s;
    border: 2px solid transparent;
    box-sizing: border-box;
}
.doc-color-opt:hover { transform: scale(1.15); }
.doc-color-opt.selected {
    border-color: #1e293b;
    transform: scale(1.12);
    box-shadow: 0 0 0 2px white inset;
}

/* ---- Texto de advertencia en modal ---- */
.doc-warning {
    color: #dc2626;
    font-size: 0.78rem;
    margin-top: 8px;
    display: flex;
    align-items: flex-start;
    gap: 5px;
}
.doc-warning i { margin-top: 1px; flex-shrink: 0; }

/* ---- Preview de foto ---- */
.doc-photo-preview {
    text-align: center;
    margin-bottom: 6px;
}
.doc-photo-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    object-fit: contain;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.doc-photo-hint {
    text-align: center;
    font-size: 0.72rem;
    color: #94a3b8;
    margin: 4px 0 10px;
}

/* ---- Preview de imagen en modal ---- */
/* Visor de imagen: el alto lo fija el contenedor, no la imagen, para que al
   ampliar la imagen pueda crecer más allá del marco y el visor haga scroll.
   Los archivos responsive ajustan este max-height por breakpoint. */
/* Altura DEFINIDA, no max-height: así el max-height:100% de la imagen resuelve
   contra ella. Con max-height el alto queda indefinido, el porcentaje se ignora
   y la imagen sale a tamaño natural.
   El centrado va con margin:auto en la imagen y no con align-items/justify-content:
   en un contenedor con scroll, esos recortan el contenido que se desborda en vez
   de dejarlo alcanzable. */
.doc-preview-img {
    position: relative;
    display: flex;
    height: 65vh;
    overflow: auto;
    background: #f8fafc;
    border-radius: 8px;
}
/* El tope del modo ajustado es el propio visor. Ninguna hoja responsive toca
   la imagen: solo la altura del contenedor, así el zoom nunca queda capado. */
/* align-self y height auto son imprescindibles: en un contenedor flex los hijos
   se estiran por defecto, la imagen tomaba la altura del visor y object-fit
   metía la foto dentro de esa caja dejando bandas a los lados. Ampliar solo
   ensanchaba la caja y la foto seguía atada al alto, que se veía como que el
   zoom no hacía nada. Sin estirar, la caja se ajusta sola a la proporción. */
.doc-preview-img img {
    align-self: center;
    height: auto;
    margin: auto;
    image-orientation: from-image;
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    cursor: zoom-in;
    user-select: none;
    -webkit-user-drag: none;
}
/* Ampliada: se libera del marco y manda el ancho en px que fija el JS. */
/* Sin margin auto: al desbordar el visor, los márgenes automáticos empujan la
   imagen y recortan el borde superior izquierdo, que queda inalcanzable. */
.doc-preview-img img.is-zoomed {
    align-self: flex-start;
    margin: 0;
    height: auto;
    max-width: none;
    max-height: none;
    cursor: grab;
    border-radius: 0;
}
.doc-preview-img.is-grabbing,
.doc-preview-img.is-grabbing img {
    cursor: grabbing;
}

.doc-preview-loading {
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #94a3b8;
    font-size: 0.8rem;
    width: 200px;
}
.doc-preview-bar {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
}
.doc-preview-bar span {
    display: block;
    height: 100%;
    width: 0;
    background: #0a2463;
    border-radius: 99px;
    transition: width 0.15s linear;
}
/* Sin Content-Length no hay porcentaje que mostrar: la barra se mueve sola
   para indicar actividad en vez de quedarse congelada en 0. */
.doc-preview-bar.is-indeterminate span {
    width: 40%;
    animation: docBarSlide 1.1s ease-in-out infinite;
}
@keyframes docBarSlide {
    from { transform: translateX(-100%); }
    to   { transform: translateX(250%); }
}

.doc-preview-zoom {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
}
.doc-zoom-btn {
    background: #f1f5f9;
    border: none;
    border-radius: 6px;
    color: #475569;
    cursor: pointer;
    padding: 6px 10px;
    font-size: 0.8rem;
}
.doc-zoom-btn:hover { background: #e2e8f0; color: #0a2463; }
.doc-zoom-level {
    font-size: 0.75rem;
    color: #64748b;
    min-width: 68px;
    text-align: center;
}

/* ---- Botón papelera ---- */
.btn-papelera {
    background: #f1f5f9;
    color: #64748b;
}
.btn-papelera:hover { background: #fee2e2; color: #dc2626; }

/* ---- Vista papelera ---- */
.doc-trash-hint {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.doc-trash-item { background: #fffbf5; border-color: #fde68a; }
.doc-trash-item:hover { background: #fff8e1; }

.doc-trash-meta { margin-top: 3px; }

.doc-trash-dias {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    background: #fef9c3;
    color: #b45309;
}
.doc-trash-dias.urgent { background: #fee2e2; color: #dc2626; }

.doc-item-meta strong { color: #475569; }

/* ---- Auditoría en vista previa ---- */
.doc-preview-audit {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 8px 10px;
    background: #f8fafc;
    border-radius: 6px;
    font-size: 0.75rem;
    color: #64748b;
    border: 1px solid #e2e8f0;
}
.doc-preview-audit i { color: #94a3b8; flex-shrink: 0; }
.doc-preview-audit strong { color: #1e293b; }

/* ---- Vista previa de documento (no imagen) ---- */
.doc-preview-doc {
    text-align: center;
    padding: 28px 0 12px;
}
.doc-preview-doc i { font-size: 3.5rem; }
.doc-preview-doc-name {
    margin-top: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #1e293b;
    word-break: break-all;
}

/* Responsive en css/responsive/documentacion/{mobile,tablet,desktop}.css */
