/* ============================================================
   Sistema de Gestión de Consultas SIAF – Estilos
   ============================================================ */
:root {
    --primary: #1a4d8f;
    --primary-dark: #0d3266;
    --primary-light: #e8f0fe;
    --accent: #c62828;
    --success: #2e7d32;
    --warning: #f57f17;
    --info: #0277bd;
    --bg: #f4f6f9;
    --card: #ffffff;
    --text: #212529;
    --text-muted: #6c757d;
    --border: #dee2e6;
    --sidebar-w: 260px;
    --header-h: 56px;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* ----- LAYOUT ----- */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--primary-dark);
    color: #fff;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform .3s;
}
.sidebar .brand {
    padding: 16px 20px;
    font-size: 15px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,.15);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar .brand span { font-size: 20px; }
.sidebar nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-size: 13.5px;
    transition: all .2s;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover,
.sidebar nav a.active {
    color: #fff;
    background: rgba(255,255,255,.1);
    border-left-color: #fff;
}
.sidebar nav a .icon { font-size: 18px; width: 22px; text-align: center; }
.sidebar .user-box {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,.15);
    font-size: 12px;
}
.sidebar .user-box .name { font-weight: 600; font-size: 13px; }
.sidebar .user-box .role { opacity: .7; margin-top: 2px; }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

.top-bar {
    height: var(--header-h);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.top-bar h1 { font-size: 17px; font-weight: 600; color: var(--primary-dark); }
.top-bar .actions { display: flex; gap: 10px; align-items: center; }

.content { padding: 24px; flex: 1; }

/* ----- CARDS ----- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 20px;
}
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-body { padding: 20px; }

/* ----- STATS ----- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-card .stat-icon { font-size: 32px; }
.stat-card .stat-info { flex: 1; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }

/* ----- TABLE ----- */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: #f8f9fa; font-weight: 600; color: var(--text-muted); text-transform: uppercase; font-size: 11px; letter-spacing: .5px; position: sticky; top: 0; }
tr:hover { background: #f8f9fa; }
td.truncate { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ----- BADGES ----- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-registrado  { background: #e9ecef; color: #495057; }
.badge-asignado    { background: #cfe2ff; color: #084298; }
.badge-en-revision { background: #fff3cd; color: #664d03; }
.badge-pendiente   { background: #fff3cd; color: #856404; }
.badge-respondido  { background: #d1e7dd; color: #0f5132; }
.badge-en-validacion { background: #e2d9f3; color: #432874; }
.badge-atendido    { background: #d1f2eb; color: #0b5345; }
.badge-reabierto   { background: #f8d7da; color: #842029; }
.badge-cancelado   { background: #e9ecef; color: #6c757d; }
.badge-alta   { background: #f8d7da; color: #842029; }
.badge-media  { background: #fff3cd; color: #664d03; }
.badge-baja   { background: #d1e7dd; color: #0f5132; }

/* ----- FORMS ----- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; color: #495057; }
.form-group .hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="url"],
select, textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    transition: border-color .2s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,77,143,.1); }
textarea { resize: vertical; min-height: 100px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-inline .form-group { margin-bottom: 0; }

/* ----- BUTTONS ----- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s;
    font-family: inherit;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #1b5e20; }
.btn-danger  { background: var(--accent); color: #fff; }
.btn-danger:hover { background: #b71c1c; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: #f8f9fa; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-icon { padding: 6px; font-size: 16px; }

/* ----- ALERTS ----- */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.alert-success { background: #d1e7dd; color: #0f5132; border: 1px solid #badbcc; }
.alert-error   { background: #f8d7da; color: #842029; border: 1px solid #f5c2c7; }
.alert-info    { background: #cff4fc; color: #055160; border: 1px solid #b6effb; }

/* ----- DETAIL VIEW ----- */
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; }
.detail-main { min-width: 0; }
.detail-sidebar { }

.info-row { display: flex; padding: 8px 0; border-bottom: 1px solid #f0f0f0; }
.info-row:last-child { border-bottom: none; }
.info-label { width: 140px; flex-shrink: 0; font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; }
.info-value { flex: 1; }

/* ----- RESPUESTAS ----- */
.respuesta-item {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    position: relative;
}
.respuesta-item.is-emisor { border-left: 3px solid var(--primary); background: var(--primary-light); }
.respuesta-item.is-responsable { border-left: 3px solid var(--success); }
.respuesta-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12px;
}
.respuesta-author { font-weight: 700; }
.respuesta-date { color: var(--text-muted); }
.respuesta-body { font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; }

/* ----- TIMELINE ----- */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 16px; }
.timeline-item::before { content: ''; position: absolute; left: -20px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid var(--card); }
.timeline-item .time { font-size: 11px; color: var(--text-muted); }
.timeline-item .event { font-size: 13px; }

/* ----- SIMILARES ----- */
.similares-box {
    border: 1px solid #e8d44d;
    background: #fffde7;
    border-radius: 6px;
    padding: 12px;
    margin-top: 8px;
    display: none;
}
.similares-box.visible { display: block; }
.similares-box h4 { font-size: 13px; margin-bottom: 8px; color: #f57f17; }
.similar-item { padding: 8px; border-bottom: 1px solid #f0e68c; font-size: 12px; cursor: pointer; }
.similar-item:last-child { border-bottom: none; }
.similar-item:hover { background: #fff9c4; }
.similar-item .sim-code { font-weight: 700; color: var(--primary); }
.similar-item .sim-text { color: #555; margin-top: 2px; }

/* ----- PAGINATION ----- */
.pagination { display: flex; gap: 4px; margin-top: 16px; justify-content: center; }
.pagination a, .pagination span {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    text-decoration: none;
    color: var(--text);
}
.pagination a:hover { background: #e9ecef; }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ----- LOGIN ----- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}
.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-card h1 { font-size: 20px; color: var(--primary-dark); margin-bottom: 6px; }
.login-card p { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }
.login-card .logo { text-align: center; margin-bottom: 20px; font-size: 48px; }

/* ----- EVIDENCE ----- */
.evidence-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.evidence-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #f8f9fa;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
}
.evidence-item a { color: var(--primary); text-decoration: none; }
.evidence-item a:hover { text-decoration: underline; }

/* ----- RESPONSIVE ----- */
@media (max-width: 1024px) {
    .detail-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .form-row-3 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .content { padding: 16px; }
    .mobile-toggle { display: block !important; }
}
.mobile-toggle { display: none; background: none; border: none; font-size: 24px; cursor: pointer; }

/* ----- CHARTS ----- */
.chart-container { height: 250px; position: relative; }
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 200px; padding-top: 20px; }
.bar-chart .bar {
    flex: 1;
    min-width: 30px;
    border-radius: 4px 4px 0 0;
    position: relative;
    transition: height .5s ease;
    cursor: pointer;
}
.bar-chart .bar:hover { opacity: .85; }
.bar-chart .bar .bar-label {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    white-space: nowrap;
    color: var(--text-muted);
}
.bar-chart .bar .bar-value {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 700;
}

/* MFD tree */
.mfd-tree { list-style: none; }
.mfd-tree li { padding: 6px 0; }
.mfd-tree .parent { font-weight: 700; font-size: 14px; margin-top: 10px; }
.mfd-tree .child { padding-left: 28px; font-size: 13px; }
.mfd-actions { display: inline-flex; gap: 4px; margin-left: 8px; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal { background: #fff; border-radius: 10px; padding: 24px; width: 480px; max-width: 90vw; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* Filters bar */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border);
    align-items: flex-end;
}
.filters-bar .form-group { margin-bottom: 0; min-width: 140px; }
.filters-bar select, .filters-bar input { padding: 6px 10px; font-size: 12px; }

/* ----- REUNIONES ----- */
.badge-borrador   { background: #e9ecef; color: #495057; }
.badge-finalizada { background: #d1e7dd; color: #0f5132; }
.badge-cumplido   { background: #d1e7dd; color: #0f5132; }

.integrante-resultados {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    background: var(--card);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 6px 16px rgba(0,0,0,.08);
}
.integrante-resultado-item {
    padding: 8px 10px;
    font-size: 12.5px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}
.integrante-resultado-item:last-child { border-bottom: none; }
.integrante-resultado-item:hover { background: #f8f9fa; }
.integrante-resultado-vacio { padding: 8px 10px; font-size: 12px; color: var(--text-muted); }

.integrante-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 6px 5px 10px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 14px;
    font-size: 12px;
}
.chip-remove {
    background: none;
    border: none;
    color: var(--primary-dark);
    cursor: pointer;
    font-size: 11px;
    padding: 2px 5px;
    border-radius: 50%;
}
.chip-remove:hover { background: rgba(0,0,0,.08); }

.acuerdo-row {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    padding-right: 40px;
    margin-bottom: 14px;
    background: #fbfbfc;
}
.acuerdo-row .acuerdo-remove {
    position: absolute;
    top: 10px;
    right: 10px;
}
.acuerdo-row .form-group:last-child { margin-bottom: 0; }

.agenda-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}
.agenda-row .agenda-descripcion { flex: 1; }

.autosave-status {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    padding: 6px;
    border-radius: 6px;
}
.autosave-status.saving { color: var(--info); }
.autosave-status.saved  { color: var(--success); }
.autosave-status.error  { color: var(--accent); font-weight: 600; }

/* ============================================================
   MÓDULO REUNIONES — lenguaje visual piloto (scope: .reuniones-view)
   Aplicado solo aquí; el resto de la app no se toca.
   ============================================================ */
.reuniones-view {
    --r-radius: 10px;
    --r-shadow-card: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
    --r-shadow-panel: 0 8px 24px rgba(16,24,40,.14), 0 2px 6px rgba(16,24,40,.06);
}
.reuniones-view .card {
    border-radius: var(--r-radius);
    box-shadow: var(--r-shadow-card);
}
.reuniones-view .card-header {
    padding: 14px 22px;
    letter-spacing: .2px;
}
.reuniones-view .card-body { padding: 22px; }
.reuniones-view .btn {
    border-radius: var(--r-radius);
    transition: transform 120ms ease-out, background-color 120ms ease-out, border-color 120ms ease-out;
}
.reuniones-view .btn:active { transform: scale(.97); }
.reuniones-view input[type="text"],
.reuniones-view input[type="url"],
.reuniones-view select,
.reuniones-view textarea {
    border-radius: var(--r-radius);
}

/* ----- Trigger de campo (fecha/hora) ----- */
.reuniones-view .date-field,
.reuniones-view .time-field {
    position: relative;
}
.reuniones-view .field-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-radius);
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    transition: border-color 120ms ease-out, box-shadow 120ms ease-out;
}
.reuniones-view .field-trigger:hover { border-color: #c3cad3; }
.reuniones-view .field-trigger:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,77,143,.1);
}
.reuniones-view .field-trigger:active { transform: scale(.99); }
.reuniones-view .field-trigger-text { color: var(--text); }
.reuniones-view .field-trigger-icon { font-size: 14px; opacity: .8; }

/* ----- Panel flotante base (compartido) ----- */
.reuniones-view .floating-panel {
    position: fixed;
    z-index: 300;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-radius);
    box-shadow: var(--r-shadow-panel);
    opacity: 0;
    transform: scale(.95) translateY(-4px);
    transition: opacity 120ms ease-in, transform 120ms ease-in;
    pointer-events: none;
}
.reuniones-view .floating-panel.open {
    opacity: 1;
    transform: scale(1) translateY(0);
    transition: opacity 160ms cubic-bezier(.2,.8,.2,1), transform 160ms cubic-bezier(.2,.8,.2,1);
    pointer-events: auto;
}
@media (prefers-reduced-motion: reduce) {
    .reuniones-view .floating-panel,
    .reuniones-view .floating-panel.open {
        transition: none;
    }
}

/* ----- Date picker ----- */
.reuniones-view .date-panel { width: 336px; padding: 12px; }
.reuniones-view .date-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.reuniones-view .date-panel-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: capitalize;
}
.reuniones-view .date-panel-nav {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-muted);
    transition: background-color 120ms ease-out;
}
.reuniones-view .date-panel-nav:hover { background: #f0f2f5; color: var(--text); }
.reuniones-view .date-panel-nav:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.reuniones-view .date-panel-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 10.5px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 4px;
}
.reuniones-view .date-panel-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.reuniones-view .date-panel-day {
    width: 100%;
    aspect-ratio: 1;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 12.5px;
    color: var(--text);
    cursor: pointer;
    transition: background-color 120ms ease-out, color 120ms ease-out;
}
.reuniones-view .date-panel-day:hover { background: #f0f2f5; }
.reuniones-view .date-panel-day:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.reuniones-view .date-panel-day.otro-mes { color: #c3cad3; }
.reuniones-view .date-panel-day.hoy { font-weight: 700; color: var(--primary); }
.reuniones-view .date-panel-day.seleccionado { background: var(--primary); color: #fff; }
.reuniones-view .date-panel-day.seleccionado:hover { background: var(--primary-dark); }
.reuniones-view .date-panel-footer {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
}

/* ----- Time picker ----- */
.reuniones-view .time-panel { width: 200px; padding: 8px; }
.reuniones-view .time-panel-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.reuniones-view .time-panel-col {
    height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    scroll-behavior: smooth;
}
.reuniones-view .time-panel-option {
    border: none;
    background: transparent;
    border-radius: 8px;
    padding: 8px 0;
    font-size: 13px;
    text-align: center;
    color: var(--text);
    cursor: pointer;
    transition: background-color 120ms ease-out, color 120ms ease-out;
}
.reuniones-view .time-panel-option:hover { background: #f0f2f5; }
.reuniones-view .time-panel-option:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.reuniones-view .time-panel-option.seleccionado { background: var(--primary); color: #fff; font-weight: 600; }
.reuniones-view .time-panel-footer {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
}
