/* ============================================================
   styles.css — Estilos compartidos PMO
   ============================================================ */

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

:root {
  --bg:#fff; --bg2:#f7f7f5; --bg3:#f1efe8;
  --txt:#1a1a18; --txt2:#5f5e5a; --txt3:#888780;
  --border:rgba(0,0,0,0.12); --border2:rgba(0,0,0,0.22);
  --radius:8px; --radius-lg:12px;
  --p1:#4e33e9; --p2:#280071;
  --card-bg:#f7f7f5; --input-bg:#fff;
  --sidebar-bg:#3d28d4; --sidebar-w:240px;
}
[data-theme="dark"] {
  --bg:#1a1a1f; --bg2:#25252c; --bg3:#2e2e38;
  --txt:#e8e8e6; --txt2:#a0a09a; --txt3:#666660;
  --border:rgba(255,255,255,0.10); --border2:rgba(255,255,255,0.18);
  --p1:#7b66f0; --p2:#a48fff;
  --card-bg:#25252c; --input-bg:#2e2e38;
  --sidebar-bg:#2a1fa8;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--txt);
  font-size: 14px; line-height: 1.6;
  transition: background .2s, color .2s;
}

/* ── Layout ─────────────────────────────────────────────── */
.app   { display: flex; height: 100vh; overflow: hidden; }
.main  { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.content { flex: 1; overflow-y: auto; padding: 24px 32px 48px; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg);
  display: flex; flex-direction: column; flex-shrink: 0;
  transition: width .25s cubic-bezier(.4,0,.2,1); overflow: hidden;
}
.sidebar.collapsed { width: 64px; }
.sidebar-header {
  padding: 12px 10px; border-bottom: 1px solid rgba(255,255,255,0.12);
  display: flex; align-items: center; justify-content: space-between;
  min-height: 56px; flex-shrink: 0;
}
.sidebar-logo-full  { height: 26px; object-fit: contain; filter: brightness(0) invert(1); }
.sidebar-logo-icon  { height: 28px; width: 28px; object-fit: contain; filter: brightness(0) invert(1); display: none; }
.sidebar.collapsed .sidebar-logo-full { display: none; }
.sidebar.collapsed .sidebar-logo-icon { display: block; }

.sidebar-toggle {
  background: none; border: none; cursor: pointer; padding: 4px;
  border-radius: 6px; display: flex; align-items: center;
  color: rgba(255,255,255,0.7); flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.12); color: #fff; }
.sidebar-toggle svg { transition: transform .25s; }
.sidebar.collapsed .sidebar-toggle svg { transform: rotate(180deg); }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; overflow-x: hidden; }
.sidebar-section-label {
  font-size: 10px; font-weight: 600; color: rgba(255,255,255,0.4);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 0 8px; margin: 16px 0 6px; white-space: nowrap;
  transition: opacity .2s, height .2s, margin .2s;
}
.sidebar.collapsed .sidebar-section-label { opacity: 0; height: 0; margin: 0; padding: 0; }

.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: 8px; cursor: pointer; color: rgba(255,255,255,0.75);
  font-size: 13px; font-weight: 500; border: none; background: none;
  width: 100%; text-align: left; white-space: nowrap; overflow: hidden;
}
.nav-item:hover  { background: rgba(255,255,255,0.10); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.18); color: #fff; }
.nav-item-label  { overflow: hidden; transition: opacity .2s, max-width .25s; max-width: 160px; }
.sidebar.collapsed .nav-item-label { opacity: 0; max-width: 0; }

.nav-icon { width: 24px; height: 24px; border-radius: 5px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-icon img { width: 16px; height: 16px; filter: brightness(0) invert(1); }
.nav-icon svg  { width: 16px; height: 16px; }

.sidebar-footer { padding: 10px 8px; border-top: 1px solid rgba(255,255,255,0.12); flex-shrink: 0; }
.sidebar-user   { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; overflow: hidden; }
.sidebar-user-info { overflow: hidden; transition: opacity .2s, max-width .25s; max-width: 160px; white-space: nowrap; }
.sidebar.collapsed .sidebar-user-info { opacity: 0; max-width: 0; }
.sidebar-avatar    { width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,0.25); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: #fff; flex-shrink: 0; }
.sidebar-user-name { font-size: 12px; font-weight: 500; color: #fff; line-height: 1.2; }
.sidebar-user-role { font-size: 11px; color: rgba(255,255,255,0.5); }

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; border-bottom: 0.5px solid var(--border);
  flex-shrink: 0; gap: 10px; flex-wrap: wrap;
}
.topbar-left  { font-size: 13px; color: var(--txt2); }
.topbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Botones ─────────────────────────────────────────────── */
.btn { border: 0.5px solid var(--border2); border-radius: var(--radius); padding: 7px 15px; font-size: 13px; cursor: pointer; background: var(--bg); color: var(--txt); font-weight: 500; }
.btn:hover { background: var(--bg2); }
.btn-primary { background: var(--p1); color: #fff; border-color: var(--p1); }
.btn-primary:hover { background: var(--p2); }
.btn-danger  { color: #c0392b; border-color: #c0392b; }
.btn-danger:hover { background: #fff0ee; }
.btn-icon {
  border: 0.5px solid var(--border2); border-radius: var(--radius);
  padding: 7px; cursor: pointer; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--bg2); }
.btn-icon img { width: 18px; height: 18px; filter: brightness(0); }
[data-theme="dark"] .btn-icon img { filter: brightness(0) invert(1); }
.btn-icon-primary { background: var(--p1); border-color: var(--p1); }
.btn-icon-primary img { filter: brightness(0) invert(1) !important; }
.btn-icon-dark { background: var(--p2); border-color: var(--p2); }
.btn-icon-dark img { filter: brightness(0) invert(1) !important; }

/* ── Tarjetas KPI ────────────────────────────────────────── */
.kpi-row  { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 32px; }
.kpi-card { background: var(--card-bg); border-radius: var(--radius-lg); padding: 18px 20px; position: relative; overflow: hidden; }
.kpi-card-accent { position: absolute; top: 0; left: 0; width: 4px; height: 100%; border-radius: 4px 0 0 4px; }
.kpi-card-label  { font-size: 11px; color: var(--txt2); margin-bottom: 8px; font-weight: 500; }
.kpi-card-value  { font-size: 32px; font-weight: 600; line-height: 1; color: var(--txt); }
.kpi-card-sub    { font-size: 11px; color: var(--txt3); margin-top: 6px; }

/* ── Tabla ───────────────────────────────────────────────── */
.table-wrap { background: var(--bg); border: 0.5px solid var(--border); border-radius: var(--radius-lg); overflow: auto; margin-bottom: 24px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; font-weight: 500; font-size: 11px; color: var(--txt2); padding: 9px 12px; border-bottom: 0.5px solid var(--border); background: var(--bg2); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 0.5px solid var(--border); color: var(--txt); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg2); }

/* ── Badges ──────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.badge-green  { background: #e6faf2; color: #1a7a52; }
.badge-amber  { background: #fff3e0; color: #c05e00; }
.badge-red    { background: #fdecea; color: #c0392b; }
.badge-blue   { background: #eae8fd; color: #280071; }
.badge-gray   { background: #f1efe8; color: #5f5e5a; }
.badge-purple { background: #f0e6ff; color: #5a0aad; }
.badge-status-espera     { background: #f1efe8; color: #5f5e5a; }
.badge-status-progreso   { background: #e8f4fd; color: #1565c0; }
.badge-status-pausado    { background: #fff8e1; color: #f57f17; }
.badge-status-completado { background: #e6faf2; color: #1a7a52; }
.badge-status-cancelado  { background: #fdecea; color: #c0392b; }
.badge-health-tiempo  { background: #e6faf2; color: #1a7a52; }
.badge-health-riesgo  { background: #fff3e0; color: #c05e00; }
.badge-health-retraso { background: #fdecea; color: #c0392b; }

.sit-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.sit-ok   { background: #e6faf2; color: #1a7a52; }
.sit-warn { background: #fff3e0; color: #c05e00; }
.sit-bad  { background: #fdecea; color: #c0392b; }
.sit-info { background: #eae8fd; color: #280071; }

.health-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.hd-green  { background: #1a7a52; }
.hd-yellow { background: #c05e00; }
.hd-red    { background: #c0392b; }
.hd-gray   { background: #aaa; }

/* ── Colores de texto ────────────────────────────────────── */
.good    { color: #1a7a52; }
.warn    { color: #c05e00; }
.bad     { color: #c0392b; }
.neutral { color: var(--txt); }

/* ── Sección ─────────────────────────────────────────────── */
.section { margin-bottom: 26px; padding-bottom: 26px; border-bottom: 0.5px solid var(--border); }
.section:last-of-type { border-bottom: none; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.section-title  { font-size: 11px; font-weight: 500; color: var(--txt3); text-transform: uppercase; letter-spacing: 0.06em; }
.gen-section-title { font-size: 12px; font-weight: 600; color: var(--txt3); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.gen-section-title::after { content: ''; flex: 1; height: 0.5px; background: var(--border2); }

/* ── Edit link ───────────────────────────────────────────── */
.edit-link { font-size: 12px; color: var(--p1); cursor: pointer; border: none; background: none; padding: 0; }
.edit-link:hover { text-decoration: underline; }
.action-btn { border: none; background: none; cursor: pointer; font-size: 13px; padding: 2px 5px; border-radius: 4px; color: var(--txt2); }
.action-btn:hover { background: var(--bg3); }
.action-btn.del { color: #c0392b; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.38); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--bg); border-radius: var(--radius-lg); border: 0.5px solid var(--border2); padding: 24px; width: 92%; max-width: 540px; max-height: 88vh; overflow-y: auto; }
.modal h3 { font-size: 16px; font-weight: 500; margin-bottom: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.btn-cancel { background: none; border: none; padding: 7px 12px; font-size: 13px; cursor: pointer; color: var(--txt2); }
.btn-save   { background: var(--p1); color: #fff; border: none; border-radius: var(--radius); padding: 7px 18px; font-size: 13px; cursor: pointer; font-weight: 500; }
.btn-save:hover { background: var(--p2); }

/* ── Formularios ─────────────────────────────────────────── */
.form-row   { margin-bottom: 12px; }
.form-label { font-size: 12px; color: var(--txt2); margin-bottom: 4px; display: block; }
.form-hint  { font-size: 11px; color: var(--txt3); margin-top: 3px; display: block; }
.form-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 10px; }
input[type=text], input[type=number], input[type=date], input[type=password],
select, textarea {
  border: 0.5px solid var(--border2); border-radius: var(--radius);
  padding: 6px 10px; font-size: 13px; background: var(--input-bg);
  color: var(--txt); width: 100%; font-family: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--p1); outline-offset: 1px; }
.btn-add-row { width: 100%; margin-top: 8px; padding: 8px; border: 0.5px dashed var(--border2); border-radius: var(--radius); background: none; cursor: pointer; font-size: 13px; color: var(--txt2); }
.btn-add-row:hover { background: var(--bg2); }

/* ── Carga ───────────────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; height: 200px; color: var(--txt3); font-size: 13px; gap: 10px; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--p1); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Gráfica ─────────────────────────────────────────────── */
.chart-wrap      { background: var(--bg); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.chart-container { position: relative; width: 100%; height: 260px; }
.chart-legend    { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--txt2); flex-wrap: wrap; }
.legend-dot      { width: 10px; height: 3px; display: inline-block; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

/* ── Metric card ─────────────────────────────────────────── */
.metric-grid  { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.metric-card  { background: var(--card-bg); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; }
.metric-label { font-size: 11px; color: var(--txt2); margin-bottom: 8px; min-height: 28px; line-height: 1.3; }
.metric-value { font-size: 22px; font-weight: 500; line-height: 1; }
.metric-sub   { font-size: 11px; margin-top: 6px; }

/* ── NPS ─────────────────────────────────────────────────── */
.nps-wrap       { display: flex; gap: 12px; flex-wrap: wrap; }
.nps-score-card { background: var(--bg); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 20px 24px; text-align: center; min-width: 120px; }
.nps-big        { font-size: 42px; font-weight: 500; }
.nps-dist       { flex: 1; background: var(--bg); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; min-width: 200px; }
.bar-row        { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; font-size: 12px; }
.bar-label      { width: 76px; color: var(--txt2); flex-shrink: 0; }
.bar-track      { flex: 1; background: var(--border); border-radius: 4px; height: 10px; overflow: hidden; }
.bar-fill       { height: 100%; border-radius: 4px; }
.bar-pct        { width: 34px; text-align: right; font-weight: 500; }

/* ── Recomendaciones ─────────────────────────────────────── */
.rec-list    { list-style: none; background: var(--bg); border: 0.5px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.rec-list li { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 0.5px solid var(--border); font-size: 13px; align-items: flex-start; }
.rec-list li:last-child { border-bottom: none; }
.rec-icon      { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 500; flex-shrink: 0; margin-top: 1px; }
.rec-icon-warn { background: #eeeeff; color: #280071; }
.rec-icon-ok   { background: #e6faf2; color: #1a7a52; }
.rec-icon-info { background: #eae8fd; color: #4e33e9; }

/* ── Print header ────────────────────────────────────────── */
.print-header { display: none; background: #280071; color: #fff; padding: 20px 24px 18px; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.print-header-logo { height: 32px; object-fit: contain; filter: brightness(0) invert(1); }
.print-header-title { font-size: 18px; font-weight: 500; }
.print-header-sub   { font-size: 12px; color: rgba(255,255,255,0.7); margin-top: 2px; }
.print-header-badge { display: inline-block; background: rgba(255,255,255,0.15); border-radius: 6px; padding: 4px 12px; font-size: 12px; }
.print-header-date  { font-size: 11px; color: rgba(255,255,255,0.6); margin-top: 4px; }

/* ── Status badge ────────────────────────────────────────── */
.status-badge { font-size: 12px; padding: 4px 10px; border-radius: 6px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .content  { padding: 16px 16px 40px; }
  .topbar   { padding: 10px 16px; }
  .form-grid2, .form-grid4 { grid-template-columns: 1fr; }
  .kpi-row  { grid-template-columns: repeat(2, 1fr); }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}

@media print {
  .sidebar, .topbar, .modal-overlay, .admin-only,
  .edit-link, .action-btn { display: none !important; }
  .app  { display: block; height: auto; }
  .main { display: block; overflow: visible; }
  .print-header { display: flex !important; }
  body  { background: #fff; }
  @page { size: letter portrait; margin: 12mm 10mm; }
}
