/* ════════════════════════════════════════════════════════════════════════
   MÓDULOS COMUNES · SIE
   ────────────────────────────────────────────────────────────────────────
   Componentes reutilizables por cualquier módulo del sistema:
     · Barra de filtros        (.filtros)
     · Tabs de página          (.tab-nav, .tab-panel)
     · Modal genérico          (.modal-overlay, .modal-box ...)
     · Modal con tabs internos (.modal-tabs, .modal-tab, .modal-panel)
     · Form-group              (.form-group, .form-row)
     · Drop-zone de archivos   (.drop-zone, .upload-progress)
     · Timeline / comentarios  (.timeline, .comentario-form)
     · Tabla institucional     (.table-card + estilos de DataTables)

   Depende de layout-admin.css (variables y botones).
   ════════════════════════════════════════════════════════════════════════ */

/* ─── FILTROS ───────────────────────────────────────────────────────── */
.filtros {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

.filtros .search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}
.filtros .search-wrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-faint);
    font-size: 13px;
}

.filtros input,
.filtros select {
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    background: #fff;
    outline: none;
    transition: border .15s;
}
.filtros input:focus,
.filtros select:focus { border-color: var(--vino); }

.filtros .search-wrap input { width: 100%; padding-left: 34px; }
.filtros select { min-width: 150px; cursor: pointer; }

/* ─── TABS DE PÁGINA ────────────────────────────────────────────────── */
.tab-nav {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 22px;
}

.tab-btn {
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    padding: 11px 18px;
    color: var(--text-soft);
    border-bottom: 2.5px solid transparent;
    margin-bottom: -1px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: all .15s;
}
.tab-btn:hover { color: var(--vino); }
.tab-btn.active {
    color: var(--vino);
    border-bottom-color: var(--vino);
}

.tab-panel { display: none; animation: fade .25s ease; }
.tab-panel.active { display: block; }

@keyframes fade {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}

/* ─── TABLA INSTITUCIONAL (compatible con DataTables) ───────────────── */
.table-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}

table.dataTable thead th {
    background: var(--vino);
    color: #fff;
    font-weight: 500;
    font-size: 12.5px;
    border: none !important;
    padding: 11px 12px;
}
table.dataTable tbody td {
    font-size: 13px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
table.dataTable tbody tr:hover { background: #faf8f6; }

.td-acciones { white-space: nowrap; }

/* ─── MODAL GENÉRICO ────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44, 42, 43, .5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }

.modal-box {
    background: var(--surface);
    border-radius: var(--radius);
    width: 100%;
    max-width: 780px;
    box-shadow: var(--shadow-lg);
    max-height: 92vh;
    overflow-y: auto;
    animation: pop .2s ease;
}
@keyframes pop {
    from { transform: scale(.96); opacity: 0; }
    to   { transform: none;       opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 {
    font-size: 17px;
    font-weight: 600;
    color: var(--vino);
}

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-faint);
    cursor: pointer;
}
.modal-close:hover { color: var(--vino); }

.modal-body { padding: 22px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 22px;
    border-top: 1px solid var(--border);
}

/* ─── MODAL CON TABS INTERNOS ───────────────────────────────────────── */
.modal-tabs {
    display: flex;
    gap: 2px;
    padding: 0 22px;
    border-bottom: 1px solid var(--border);
    background: #faf8f6;
}

.modal-tab {
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    padding: 12px 16px;
    color: var(--text-soft);
    border-bottom: 2.5px solid transparent;
    margin-bottom: -1px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: all .15s;
}
.modal-tab:hover { color: var(--vino); }
.modal-tab.active {
    color: var(--vino);
    border-bottom-color: var(--vino);
    background: #fff;
}

.modal-tab .tab-badge {
    background: var(--vino-light);
    color: var(--vino);
    font-size: 10.5px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}
.modal-tab.active .tab-badge { background: var(--vino); color: #fff; }

.modal-panel { display: none; padding: 22px; }
.modal-panel.active { display: block; animation: fade .2s ease; }

/* ─── FORM-GROUP ────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }

.form-group label {
    display: block;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}
.form-group label .req { color: var(--vino); }

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    outline: none;
    transition: border .15s;
    background: #fff;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { border-color: var(--vino); }

.form-group textarea { resize: vertical; min-height: 72px; }
.form-group select { cursor: pointer; }

@media (max-width: 620px) {
    .form-row { flex-direction: column; gap: 0; }
}

/* ─── DROP-ZONE DE ARCHIVOS ─────────────────────────────────────────── */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px 16px;
    text-align: center;
    background: #faf8f6;
    cursor: pointer;
    transition: all .15s;
    margin-bottom: 14px;
    display: block;
}
.drop-zone:hover { border-color: var(--vino); background: #fdf3f7; }
.drop-zone.dragover { border-color: var(--vino); background: #f5eaef; }

.drop-zone i {
    font-size: 24px;
    color: var(--vino);
    margin-bottom: 8px;
    display: block;
}
.drop-zone-text { font-size: 13px; color: var(--text-soft); }
.drop-zone-text strong { color: var(--vino); }
.drop-zone input[type="file"] { display: none; }

.archivo-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    transition: border-color .15s;
}
.archivo-item:hover { border-color: var(--vino); }

.archivo-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--vino-light);
    color: var(--vino);
    display: grid;
    place-items: center;
    font-size: 15px;
    flex-shrink: 0;
}
.archivo-info { flex: 1; min-width: 0; }
.archivo-nombre {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.archivo-meta { font-size: 11px; color: var(--text-faint); margin-top: 1px; }
.archivo-actions { display: flex; gap: 4px; }

.upload-progress {
    display: none;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 12px;
}
.upload-progress.show { display: block; }
.upload-progress-bar {
    height: 100%;
    background: var(--vino);
    width: 0;
    transition: width .2s;
}

/* ─── TIMELINE / COMENTARIOS ────────────────────────────────────────── */
.timeline {
    position: relative;
    padding-left: 22px;
    margin-top: 8px;
}
.timeline::before {
    content: '';
    position: absolute;
    left: 9px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding: 0 0 16px 18px;
    font-size: 13px;
}
.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
    position: absolute;
    left: -22px;
    top: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--vino);
    display: grid;
    place-items: center;
    font-size: 9px;
    color: var(--vino);
}

.timeline-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
}
.timeline-who { font-weight: 500; color: var(--text); }
.timeline-who .who-rol {
    font-size: 11px;
    color: var(--text-soft);
    font-weight: 400;
    margin-left: 5px;
}
.timeline-when {
    font-size: 11.5px;
    color: var(--text-faint);
    white-space: nowrap;
}
.timeline-detail { color: var(--text-soft); line-height: 1.5; }

.comentario-form { margin-bottom: 16px; }
.comentario-form textarea {
    width: 100%;
    font-family: inherit;
    font-size: 13.5px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    resize: vertical;
    min-height: 70px;
    outline: none;
    transition: border-color .15s;
}
.comentario-form textarea:focus { border-color: var(--vino); }
.comentario-form .form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

/* ─── BADGES GENÉRICOS DE ESTATUS / PRIORIDAD ───────────────────────── */
.badge-estatus,
.badge-prio {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 20px;
    display: inline-block;
}
.badge-prio { color: #fff; font-weight: 600; }

.est-por-hacer   { background: #efeae5; color: var(--gris); }
.est-en-proceso  { background: #e3e7e6; color: var(--verde); }
.est-en-revision { background: #f3e4ce; color: #8a5a1c; }
.est-completada  { background: #e4f0e9; color: #2f6b46; }

/* Responsive: tabs apilados en móvil */
@media (max-width: 600px) {
    .modal-tabs { padding: 0 10px; overflow-x: auto; }
    .modal-tab { padding: 10px 12px; font-size: 12px; }
}
