/* =====================================================================
   Alena LMS — datos: DataTable, gráficos, report builder
   ===================================================================== */
[hidden] { display: none !important; }

/* ---------- DataTable ---------- */
.dt-wrap { position: relative; }
.card > .dt-wrap, .card-table > .dt-wrap { margin: 0; }
.dt-toolbar {
    display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap;
    padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); background: var(--surface);
}
.dt-search { position: relative; display: flex; align-items: center; flex: 1; min-width: 190px; max-width: 340px; margin: 0; }
.dt-search svg { position: absolute; left: 0.65rem; width: 15px; height: 15px; color: var(--text-tertiary); pointer-events: none; }
.dt-search input {
    width: 100%; min-height: var(--control-h-sm); padding: 0.25rem 0.7rem 0.25rem 2rem; font-size: 0.85rem; font-family: inherit;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
.dt-search input:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--ring); background: var(--surface); }
.dt-tools { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.dt-tools .btn svg { width: 15px; height: 15px; }
.dt-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--brand-600); color: #fff; font-size: 0.68rem; font-weight: 700; display: inline-grid; place-items: center; }
.dt-btn-filters[aria-pressed="true"] { background: var(--brand-50); border-color: var(--brand-400); color: var(--brand-800); }
.dt-cols { position: relative; }
.dt-menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 210px; max-height: 320px; overflow: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 0.4rem;
    animation: menuIn 0.15s ease;
}
.dt-menu-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.42rem 0.55rem; border-radius: var(--radius-xs); font-size: 0.86rem; color: var(--text-secondary); cursor: pointer; margin: 0; font-weight: 500; }
.dt-menu-item:hover { background: var(--brand-50); color: var(--brand-800); }
.dt-menu-item input { width: 16px; height: 16px; accent-color: var(--brand-600); margin: 0; }
.dt-menu-reset { width: 100%; margin-top: 0.3rem; padding: 0.4rem; border: none; border-top: 1px solid var(--border); background: none; color: var(--brand-700); font-size: 0.8rem; font-weight: 600; cursor: pointer; font-family: inherit; }
.dt-menu-reset:hover { text-decoration: underline; }

.dt-sortable { cursor: pointer; user-select: none; transition: color 0.15s ease, background-color 0.15s ease; }
.dt-sortable:hover { color: var(--brand-700); background: var(--brand-50); }
.dt-sortable:focus-visible { outline: 2px solid var(--brand-500); outline-offset: -2px; }
.dt-sort { margin-left: 0.35rem; font-size: 0.65rem; opacity: 0.35; }
.dt-sorted { color: var(--brand-800); }
.dt-sorted .dt-sort { opacity: 1; color: var(--brand-600); }

tr.dt-filters th { padding: 0.35rem 0.5rem; background: var(--surface-2); text-transform: none; letter-spacing: 0; border-bottom: 1px solid var(--border-strong); }
tr.dt-filters input, tr.dt-filters select {
    width: 100%; min-width: 90px; min-height: var(--control-h-sm); padding: 0.2rem 0.5rem; font-size: 0.8rem; font-family: inherit; font-weight: 400;
    border: 1px solid var(--border-strong); border-radius: var(--radius-xs); background: var(--surface); color: var(--text);
}
tr.dt-filters input:focus, tr.dt-filters select:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--ring); }
.dt-col-hidden { display: none !important; }
tr.dt-empty td { text-align: center; color: var(--text-tertiary); padding: 1.6rem 1rem; }

.dt-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; padding: 0.6rem 0.9rem; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 0.8rem; color: var(--text-tertiary); }
.dt-pager { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }
.dt-page {
    min-width: 30px; height: 30px; padding: 0 0.5rem; border-radius: var(--radius-xs); border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text-secondary); font-family: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: var(--ease);
}
.dt-page:hover:not(:disabled) { background: var(--brand-50); border-color: var(--brand-400); color: var(--brand-800); }
.dt-page.current { background: var(--brand-gradient); border-color: transparent; color: #fff; }
.dt-page:disabled { opacity: 0.4; cursor: default; }
.dt-dots { padding: 0 0.2rem; }
.dt-size { min-height: 30px; padding: 0 0.4rem; margin-right: 0.4rem; font-size: 0.8rem; font-family: inherit; border: 1px solid var(--border-strong); border-radius: var(--radius-xs); background: var(--surface); color: var(--text-secondary); }
.dt-server-pager { display: flex; justify-content: flex-end; gap: 0.25rem; padding: 0.6rem 0.9rem; background: var(--surface-2); border-top: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.dt-server-pager a, .dt-server-pager span.dt-page { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 0.5rem; border-radius: var(--radius-xs); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-secondary); font-size: 0.82rem; font-weight: 600; transition: var(--ease); }
.dt-server-pager a:hover { background: var(--brand-50); border-color: var(--brand-400); color: var(--brand-800); }
.dt-server-pager .current { background: var(--brand-gradient); border-color: transparent; color: #fff; }
.dt-server-pager .disabled { opacity: 0.4; }
.dt-server-pager .dt-info { margin-right: auto; font-size: 0.8rem; color: var(--text-tertiary); border: none; background: none; height: auto; min-width: 0; padding: 0; }

/* Celdas de tabla frecuentes */
.cell-user { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.cell-user strong { display: block; font-weight: 600; color: var(--text); line-height: 1.25; }
.cell-user small { display: block; color: var(--text-tertiary); font-size: 0.78rem; line-height: 1.25; }
.cell-strong { font-weight: 600; color: var(--text); }
.cell-muted { color: var(--text-tertiary); }
.progress-inline { display: flex; align-items: center; gap: 0.5rem; min-width: 110px; }
.progress-inline .progress-bar { flex: 1; height: 6px; }
.progress-inline span { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* Resumen rápido sobre listados (chips de stats) */
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.7rem; margin-bottom: 1rem; }
.stat-chip {
    display: flex; align-items: center; gap: 0.65rem; padding: 0.65rem 0.85rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-xs); transition: var(--ease);
}
.stat-chip:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.stat-chip .ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-100); color: var(--brand-700); flex-shrink: 0; }
.stat-chip .ico svg { width: 17px; height: 17px; }
.stat-chip .n { font-size: 1.15rem; font-weight: 700; line-height: 1.1; color: var(--text); font-variant-numeric: tabular-nums; }
.stat-chip .l { font-size: 0.74rem; color: var(--text-tertiary); }
.stat-chip.tone-accent .ico { background: var(--accent-soft); color: var(--accent); }
.stat-chip.tone-warm .ico { background: var(--accent-warm-soft); color: var(--warning-ink); }
.stat-chip.tone-sky .ico { background: var(--accent-sky-soft); color: #0369a1; }
.stat-chip.tone-danger .ico { background: var(--danger-soft); color: var(--danger-ink); }

/* ---------- Gráficos ---------- */
.chart-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 0.9rem; margin-bottom: 1rem; }
.chart-card { grid-column: span 6; margin-bottom: 0; min-width: 0; }
.chart-card.span-8 { grid-column: span 8; }
.chart-card.span-4 { grid-column: span 4; }
.chart-card.span-12 { grid-column: span 12; }
.chart-card .card-header { margin-bottom: 0.5rem; }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.chart-box.short { height: 220px; }
.chart-empty { display: grid; place-items: center; height: 100%; color: var(--text-tertiary); font-size: 0.88rem; text-align: center; }
.chart-legend-note { font-size: 0.75rem; color: var(--text-tertiary); margin: 0.3rem 0 0; }
.range-tabs { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-secondary); border-radius: var(--radius-sm); }
.range-tabs a { padding: 0.25rem 0.7rem; border-radius: 6px; font-size: 0.78rem; font-weight: 600; color: var(--text-tertiary); transition: var(--ease); }
.range-tabs a:hover { color: var(--text); }
.range-tabs a.active { background: var(--surface); color: var(--brand-800); box-shadow: var(--shadow-xs); }
@media (max-width: 960px) { .chart-card, .chart-card.span-8, .chart-card.span-4 { grid-column: span 12; } }

/* ---------- Report builder ---------- */
.rb-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 1000px) { .rb-layout { grid-template-columns: 1fr; } }
.rb-panel h3 { display: flex; align-items: center; gap: 0.45rem; font-size: 0.95rem; }
.rb-panel h3 svg { width: 17px; height: 17px; color: var(--brand-600); }
.rb-section { padding-bottom: 0.9rem; margin-bottom: 0.9rem; border-bottom: 1px dashed var(--border); }
.rb-section:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.rb-section > label:first-child { margin-top: 0; }
.chip-group { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.3rem; }
.chip-radio, .chip-check { position: relative; margin: 0 !important; }
.chip-radio input, .chip-check input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; margin: 0; }
.chip-radio span, .chip-check span {
    display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.3rem 0.75rem; border-radius: 999px; font-size: 0.82rem; font-weight: 600;
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-secondary); transition: var(--ease); user-select: none;
}
.chip-radio:hover span, .chip-check:hover span { border-color: var(--brand-400); background: var(--brand-50); }
.chip-radio input:checked + span, .chip-check input:checked + span { background: var(--brand-gradient); border-color: transparent; color: #fff; box-shadow: 0 3px 8px -3px rgba(8, 127, 91, 0.6); }
.chip-radio input:focus-visible + span, .chip-check input:focus-visible + span { box-shadow: var(--ring); }
.rb-result-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.export-group { display: inline-flex; gap: 0.4rem; flex-wrap: wrap; }
.export-group .btn svg { width: 15px; height: 15px; }
.report-table td.total-label, .report-table tfoot td.total-label { text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.05em; color: var(--text-secondary); }
.delta { font-weight: 700; font-size: 0.8rem; }
.delta.up { color: var(--success-ink); }
.delta.down { color: var(--danger-ink); }
.report-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.7rem; margin-bottom: 1rem; }
.report-meta { font-size: 0.8rem; color: var(--text-tertiary); margin: 0 0 0.75rem; }

/* Actividad reciente */
.activity-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.1rem; }
.activity-list li { display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.55rem 0.2rem; border-bottom: 1px dashed var(--border); font-size: 0.88rem; color: var(--text-secondary); line-height: 1.4; }
.activity-list li:last-child { border-bottom: none; }
.activity-list strong { color: var(--text); }
.activity-list em { font-style: normal; font-weight: 600; color: var(--brand-700); }
.activity-list small { display: block; color: var(--text-tertiary); font-size: 0.74rem; margin-top: 0.1rem; }
.activity-dot { width: 9px; height: 9px; margin-top: 0.4rem; border-radius: 50%; background: var(--accent-sky); flex-shrink: 0; box-shadow: 0 0 0 3px var(--accent-sky-soft); }
.activity-dot.done { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.row-you td { background: var(--brand-50); }
