/* =====================================================
   trabajadores-documentos.css
   Entrega de EPI y documentos a trabajadores.
   Complementa administracion.css — no lo sobreescribe.
   Mismo lenguaje visual que vacaciones.css.
   ===================================================== */

:root {
    --epi-purple: #8b5cf6;
    --epi-purple-light: #ede9fe;
    --green: #10b981;
    --red: #ef4444;
    --border: rgba(0,0,0,0.08);
    --radius: 10px;
    --shadow: 0 2px 10px rgba(0,0,0,0.07);
}

/* ─── LAYOUT ─── */
.epi-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 0;
    min-height: calc(100vh - 60px - 50px);
    background: linear-gradient(135deg, #f5f7fa 0%, #e5e9f2 100%);
}

/* ─── SIDEBAR ─── */
.epi-sidebar {
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 2px 0 8px rgba(0,0,0,0.05);
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}

.sidebar-header h3 {
    font-size: 0.85rem;
    font-weight: 700;
    color: #4b5563;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-header h3 i { color: var(--primary-blue); }

.sidebar-search {
    position: relative;
    display: flex;
    align-items: center;
}

.sidebar-search i {
    position: absolute;
    left: 0.65rem;
    color: #9ca3af;
    font-size: 0.8rem;
}

.sidebar-search input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 20px;
    font-size: 0.85rem;
    background: #fff;
    color: #1f2937;
    outline: none;
    transition: border-color 0.2s;
}

.sidebar-search input:focus { border-color: var(--primary-blue); }

.worker-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

.worker-list::-webkit-scrollbar { width: 4px; }
.worker-list::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 4px; }

.worker-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

.worker-item:hover { background: #f8fafc; }

.worker-item.active {
    background: rgba(59,130,246,0.07);
    border-left-color: var(--primary-blue);
}

.worker-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid #e2e8f0;
}

.worker-avatar-all {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(59,130,246,0.12);
    color: var(--primary-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* Icono de respaldo cuando no hay foto o falla la carga */
.worker-avatar-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #94a3b8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
    border: 2px solid #e2e8f0;
}

.worker-info { min-width: 0; }

.worker-name {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.worker-sub {
    display: block;
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 1px;
}

/* ─── ÁREA CENTRAL ─── */
.epi-main {
    padding: 1.25rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    overflow-y: auto;
    padding-bottom: 70px;
}

/* ─── TOPBAR ─── */
.epi-topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #fff;
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    flex-wrap: wrap;
}

.epi-tabs {
    display: flex;
    gap: 0.25rem;
    flex: 1;
    flex-wrap: wrap;
}

.etab {
    padding: 0.45rem 0.9rem;
    border-radius: 6px;
    border: 1.5px solid #e2e8f0;
    background: #fff;
    color: #4b5563;
    font-size: 0.83rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.etab:hover { border-color: var(--primary-blue); color: var(--primary-blue); }

.etab.active {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: #fff;
    box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}

.epi-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-add-epi {
    padding: 0.45rem 1rem;
    border-radius: 6px;
    border: none;
    font-size: 0.83rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
    background: var(--epi-purple);
    color: #fff;
    box-shadow: 0 2px 8px rgba(139,92,246,0.3);
}

.btn-add-epi:hover { background: #7c3aed; transform: translateY(-1px); }

/* ─── KPI ROW ─── */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.kpi-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    border-top: 3px solid var(--kpi-color, var(--primary-blue));
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.1); }

.kpi-icon {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--kpi-color, var(--primary-blue)) 12%, transparent);
    color: var(--kpi-color, var(--primary-blue));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.kpi-num {
    display: block;
    font-size: 1.7rem;
    font-weight: 800;
    color: #1f2937;
    line-height: 1;
}

.kpi-lbl {
    display: block;
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ─── TAB PANELS ─── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── TABLAS ─── */
.table-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.table-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.table-title i { color: var(--primary-blue); }

.table-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.filter-select {
    padding: 0.4rem 0.75rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.82rem;
    color: #374151;
    background: #fff;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.filter-select:focus { border-color: var(--primary-blue); }

.table-wrap { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table thead th {
    background: #f1f5f9;
    color: #6b7280;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.65rem 1rem;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    text-align: left;
}

.data-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
}

.data-table tbody tr:hover { background: #f8fafc; }

.data-table tbody td {
    padding: 0.65rem 1rem;
    color: #374151;
    vertical-align: middle;
}

.table-empty {
    text-align: center;
    padding: 3rem !important;
    color: #9ca3af;
    font-size: 0.9rem;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.6rem;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge-articulo { background: #ede9fe; color: #5b21b6; }
.badge-firmado  { background: #d1fae5; color: #065f46; }

/* Pill trabajador */
.worker-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.worker-pill img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid #e2e8f0;
}

.worker-pill .worker-avatar-icon {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
}

.worker-pill-name {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.85rem;
}

/* Lista de artículos en la tabla */
.articulos-resumen {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    max-width: 320px;
}

/* Firma mini-preview en tabla */
.firma-thumb {
    width: 70px;
    height: 32px;
    object-fit: contain;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
}

/* Botón acción en tabla */
.btn-row-action {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1.5px solid #e2e8f0;
    background: #fff;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.btn-row-action:hover { background: #fee2e2; border-color: #fecaca; color: #ef4444; }

/* ─── MODALES ─── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.55);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-box {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    animation: fadeInUp 0.25s ease;
    max-height: 90vh;
    overflow: hidden;
}

.modal-box-lg { max-width: 640px; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1f2937;
}

.modal-head i { color: var(--epi-purple); margin-right: 0.4rem; }

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.modal-close:hover { background: #fee2e2; color: #ef4444; }

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-foot {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

/* Formulario dentro del modal */
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.3rem; }

.form-group label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #4b5563;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.req { color: #ef4444; }

.form-ctrl {
    padding: 0.6rem 0.85rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 7px;
    font-size: 0.88rem;
    color: #1f2937;
    background: #fff;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    width: 100%;
}

.form-ctrl:focus { border-color: var(--primary-blue); }

textarea.form-ctrl { resize: vertical; min-height: 60px; }

/* ─── TARJETAS DE EPI ─── */
.epi-checklist {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem;
}

.epi-card {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.85rem 0.9rem;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.15s;
}

.epi-card:hover {
    border-color: #c4b5fd;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139,92,246,0.12);
}

.epi-card.checked {
    border-color: var(--epi-purple);
    background: var(--epi-purple-light);
    box-shadow: 0 2px 10px rgba(139,92,246,0.18);
}

.epi-card-head {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.epi-card input[type="checkbox"] {
    width: 19px;
    height: 19px;
    accent-color: var(--epi-purple);
    cursor: pointer;
    flex-shrink: 0;
}

.epi-card label {
    font-size: 0.92rem;
    font-weight: 700;
    color: #374151;
    cursor: pointer;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: none;
    letter-spacing: 0;
}

.epi-card label i {
    font-size: 1.15rem;
    color: #9ca3af;
    width: 22px;
    text-align: center;
    transition: color 0.2s;
}

.epi-card.checked label i { color: var(--epi-purple); }

.epi-card .epi-extra-fields {
    display: none;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.7rem;
    padding-left: calc(19px + 0.65rem);
}

.epi-card.checked .epi-extra-fields { display: flex; }

.epi-extra-fields input[type="text"] {
    width: 70px;
    padding: 0.35rem 0.45rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.8rem;
    text-align: center;
    background: #fff;
}

.epi-extra-fields input[type="number"] {
    width: 48px;
    padding: 0.35rem 0.45rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.8rem;
    text-align: center;
    background: #fff;
}

/* Tarjeta "Ropa": grupo que se despliega con subtipos */
.epi-card-group { grid-column: 1 / -1; }

.epi-card-chevron {
    color: #9ca3af;
    font-size: 0.8rem;
    transition: transform 0.25s ease, color 0.2s;
    margin-left: auto;
}

.epi-card-group.expanded .epi-card-chevron {
    transform: rotate(180deg);
    color: var(--epi-purple);
}

.epi-subgrupo {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.25s ease, margin-top 0.3s ease;
}

.epi-card-group.expanded .epi-subgrupo {
    max-height: 400px;
    opacity: 1;
    margin-top: 0.85rem;
}

.epi-sub-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
    transition: border-color 0.2s, background 0.2s;
}

.epi-sub-item.checked {
    border-color: var(--epi-purple);
    background: #fff;
    box-shadow: inset 0 0 0 1px var(--epi-purple);
}

.epi-sub-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--epi-purple);
    cursor: pointer;
    flex-shrink: 0;
}

.epi-sub-item label {
    font-size: 0.83rem;
    font-weight: 600;
    color: #4b5563;
    cursor: pointer;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.epi-sub-item label i { font-size: 0.95rem; color: #9ca3af; width: 18px; text-align: center; }
.epi-sub-item.checked label i { color: var(--epi-purple); }

.epi-sub-item .epi-extra-fields {
    display: none;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0;
    padding-left: 0;
    flex-shrink: 0;
}

.epi-sub-item.checked .epi-extra-fields { display: flex; }

/* ─── ARTÍCULOS LIBRES ─── */
.extra-items-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.extra-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: var(--epi-purple-light);
    color: #5b21b6;
    padding: 0.45rem 0.7rem;
    border-radius: 7px;
    font-size: 0.83rem;
    font-weight: 600;
}

.extra-item-row button {
    border: none;
    background: none;
    color: #5b21b6;
    cursor: pointer;
    font-size: 0.85rem;
    opacity: 0.7;
}

.extra-item-row button:hover { opacity: 1; }

.extra-item-add {
    display: grid;
    grid-template-columns: 2fr 1.4fr 0.7fr auto;
    gap: 0.4rem;
}

.qty-ctrl { text-align: center; }

.btn-add-extra {
    width: 38px;
    border-radius: 7px;
    border: 1.5px solid var(--epi-purple);
    background: #fff;
    color: var(--epi-purple);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-add-extra:hover { background: var(--epi-purple); color: #fff; }

/* ─── FIRMA DIGITAL ─── */
.signature-wrap {
    border: 1.5px dashed #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.signature-canvas {
    width: 100%;
    height: 160px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: crosshair;
    touch-action: none;
}

.btn-clear-signature {
    align-self: flex-end;
    padding: 0.35rem 0.8rem;
    border-radius: 6px;
    border: 1.5px solid #fecaca;
    background: #fff;
    color: #ef4444;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s;
}

.btn-clear-signature:hover { background: #fee2e2; }

/* ─── BOTONES MODAL ─── */
.btn-cancel {
    flex: 1;
    padding: 0.65rem;
    border-radius: 7px;
    border: 1.5px solid #e2e8f0;
    background: #fff;
    color: #4b5563;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel:hover { background: #f1f5f9; }

.btn-save {
    flex: 2;
    padding: 0.65rem;
    border-radius: 7px;
    border: none;
    background: var(--epi-purple);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(139,92,246,0.35);
}

.btn-save:hover { background: #7c3aed; transform: translateY(-1px); }
.btn-save:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-del {
    padding: 0.65rem 1.25rem;
    border-radius: 7px;
    border: 1.5px solid #fecaca;
    background: #fff;
    color: #ef4444;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.btn-del:hover { background: #fee2e2; }

/* Detalle modal */
.detalle-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.detalle-item {
    background: #f8fafc;
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
}

.detalle-item.full { grid-column: 1 / -1; }

.detalle-key {
    font-size: 0.72rem;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    display: block;
    margin-bottom: 0.2rem;
}

.detalle-val {
    font-size: 0.9rem;
    color: #1f2937;
    font-weight: 600;
}

.detalle-firma-img {
    max-width: 100%;
    height: 110px;
    object-fit: contain;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    margin-top: 0.4rem;
}

/* ─── RESUMEN ─── */
.resumen-table .num-fuerte { font-weight: 700; color: var(--epi-purple); }

/* ─── RESPONSIVE ─── */
@media (max-width: 1200px) {
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .epi-checklist { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .epi-layout { grid-template-columns: 1fr; }

    .epi-sidebar {
        max-height: 220px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .worker-list {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        max-height: none;
    }

    .worker-item {
        flex-shrink: 0;
        flex-direction: column;
        align-items: center;
        padding: 0.75rem;
        border-left: none;
        border-bottom: 3px solid transparent;
        text-align: center;
        gap: 0.3rem;
        min-width: 80px;
    }

    .worker-item.active {
        border-bottom-color: var(--primary-blue);
        background: rgba(59,130,246,0.05);
    }

    .worker-sub { display: none; }

    .epi-topbar { flex-wrap: wrap; }

    .epi-actions { width: 100%; justify-content: flex-end; }

    .epi-checklist { grid-template-columns: 1fr; }
    .epi-subgrupo { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .epi-main { padding: 0.75rem; }
    .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 0.65rem; }
    .form-row-2 { grid-template-columns: 1fr; }
    .etab { font-size: 0.75rem; padding: 0.4rem 0.65rem; }
    .extra-item-add { grid-template-columns: 1fr 1fr; }
    .detalle-grid { grid-template-columns: 1fr; }
}
