/* ═══════════════════════════════════════════════════════════════════
   ProcuraDesk Dashboard v2 — Visual Polish & Hierarchy
   Overrides enhancements.js inline styles for a cleaner dashboard.
   Spacing scale: 4, 8, 12, 16, 24, 32, 48
   ═══════════════════════════════════════════════════════════════════ */

/* ── KPI Cards — Restore breathing room ───────────────────────────── */
.dashboard-kpis {
  gap: 12px !important;
  padding: 12px 16px !important;
}

.kpi-row {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 8px !important;
}

.kpi-card-v2 {
  padding: 12px 16px !important;
  min-height: 0 !important;
  border-radius: 8px !important;
  border: 1px solid var(--border-muted, #21262d) !important;
  background: var(--bg-default, #161b22) !important;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.kpi-card-v2:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  border-color: var(--border, #30363d) !important;
}

.kpi-card-v2:active {
  transform: translateY(0);
}

.kpi-v2-value {
  font-size: 24px !important;
  font-weight: 700 !important;
  line-height: 1.1 !important;
  letter-spacing: 0;
}

.kpi-v2-label {
  font-size: 10px !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
  color: var(--fg-muted, #8b949e) !important;
  margin-top: 4px;
}

.kpi-v2-sub {
  font-size: 11px !important;
  color: var(--fg-subtle, #6e7681) !important;
}


/* ── Radar de Riesgo Procesal — Refined blocks ────────────────────── */
#pd-radar {
  background: var(--bg-default, #161b22) !important;
  border: 1px solid var(--border-muted, #21262d) !important;
  border-radius: 10px;
  padding: 16px !important;
  margin: 0 16px 12px !important;
}

#pd-radar h3 {
  font-size: 11px !important;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted, #8b949e) !important;
  margin: 0 0 12px !important;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rd-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px !important;
}

.rd-block {
  border-radius: 10px !important;
  padding: 14px 10px !important;
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s;
}

.rd-block:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.rd-num {
  font-size: 28px !important;
  font-weight: 800 !important;
  line-height: 1;
  margin-bottom: 6px !important;
  letter-spacing: 0;
}

.rd-lbl {
  font-size: 10px !important;
  font-weight: 500;
  color: var(--fg-muted, #8b949e) !important;
  line-height: 1.3;
}

#pd-radar-detail {
  border-top: 1px solid var(--border-muted, #21262d);
  margin-top: 14px;
  padding-top: 14px;
}

.rd-row {
  padding: 8px 4px !important;
  border-bottom: 1px solid var(--bg-subtle, #21262d);
  border-radius: 4px;
  transition: background 0.1s;
}

.rd-row:hover {
  background: var(--bg-subtle, #21262d) !important;
  opacity: 1 !important;
}


/* ── Dashboard 3-Zone Panel — More height, better readability ─────── */
.pd-dash-panel {
  display: grid;
  grid-template-columns: 58% 42% !important;
  gap: 0;
  margin: 0 16px 12px !important;
  height: 280px !important;
  border: 1px solid var(--border-muted, #21262d) !important;
  border-radius: 10px !important;
  overflow: hidden;
  background: var(--bg-default, #161b22) !important;
}

.pd-dash-col {
  overflow-y: auto;
  padding: 0;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

.pd-dash-col::-webkit-scrollbar {
  width: 4px;
}

.pd-dash-col::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.pd-dash-col + .pd-dash-col {
  border-left: 1px solid var(--border-muted, #21262d) !important;
}

.pd-dash-col-title {
  font-size: 10px !important;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em !important;
  color: var(--fg-muted, #8b949e) !important;
  padding: 8px 12px !important;
  background: var(--bg-default, #161b22) !important;
  border-bottom: 1px solid var(--border-muted, #21262d) !important;
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(8px);
}

/* Day headers in señalamientos */
.pd-day {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px !important;
  font-size: 10px !important;
  font-weight: 800;
  color: var(--fg-muted, #8b949e) !important;
  background: var(--bg-subtle, #21262d) !important;
  border-bottom: 1px solid var(--border-muted, #21262d) !important;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  position: sticky;
  top: 28px;
  z-index: 1;
}

/* Señalamiento rows */
.pd-sr {
  display: grid !important;
  grid-template-columns: 46px minmax(80px, 120px) minmax(0, 1fr) 90px !important;
  align-items: center;
  min-height: 30px !important;
  height: auto !important;
  padding: 4px 12px !important;
  gap: 8px;
  border-bottom: 1px solid var(--border-muted, rgba(255, 255, 255, 0.04)) !important;
  cursor: pointer;
  transition: background 0.1s;
}

.pd-sr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

.pd-sr:hover {
  background: var(--bg-subtle, #21262d) !important;
}

.pd-sr[data-mj] {
  background: rgba(79, 156, 249, 0.05) !important;
}

.pd-sr-hora {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px !important;
  color: var(--fg-subtle, #6e7681);
  white-space: nowrap;
  font-weight: 500;
}

.pd-sr-proc {
  font-size: 12px !important;
  color: var(--fg, #e6edf3) !important;
  font-weight: 600 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.pd-sr-juz {
  font-size: 11px !important;
  color: var(--fg-muted, #8b949e) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.pd-sr-cli {
  font-size: 10px !important;
  color: var(--fg-subtle, #6e7681) !important;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pd-sr-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(79, 156, 249, 0.12);
  color: var(--accent, #58a6ff);
  padding: 2px 6px;
  border-radius: 10px;
  text-transform: uppercase;
}


/* Plazo sections */
.pd-pz-sec {
  padding: 4px 10px !important;
  margin: 0;
  font-size: 10px !important;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-top: 1px solid var(--border-muted, #21262d);
  position: sticky;
  top: 28px;
  z-index: 1;
  background: var(--bg-default, #161b22) !important;
}

/* Plazo rows */
.pd-pz {
  display: flex;
  align-items: center;
  min-height: 36px !important;
  height: auto !important;
  padding: 4px 10px !important;
  border-bottom: 1px solid var(--border-muted, rgba(255, 255, 255, 0.04)) !important;
  gap: 8px;
  cursor: pointer;
  transition: background 0.1s;
}

.pd-pz:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

.pd-pz:hover {
  background: var(--bg-subtle, #21262d) !important;
}

.pd-pz.crit {
  background: rgba(248, 113, 113, 0.05) !important;
}

.pd-pz-dias {
  width: 40px !important;
  flex-shrink: 0;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px !important;
  font-weight: 700;
  text-align: center;
}

.pd-pz-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  line-height: 1.4 !important;
  flex: 1;
  gap: 1px;
}


/* ── Z3 Filter Bar — Cleaner, more integrated ────────────────────── */
.pd-z3-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px !important;
  border-bottom: 1px solid var(--border-muted, #21262d) !important;
  flex-shrink: 0;
  background: var(--bg-default, #161b22) !important;
}

.pd-z3-search {
  flex: 1;
  background: var(--bg-subtle, #21262d) !important;
  border: 1px solid var(--border-muted, #21262d) !important;
  border-radius: 6px !important;
  color: var(--fg, #e6edf3) !important;
  padding: 6px 12px !important;
  font-size: 12px !important;
  outline: none;
  min-width: 0;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.pd-z3-search:focus {
  border-color: var(--accent, #58a6ff) !important;
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.15) !important;
}

.pd-z3-search::placeholder {
  color: var(--fg-subtle, #6e7681);
}

.pd-z3-select {
  background: var(--bg-subtle, #21262d) !important;
  border: 1px solid var(--border-muted, #21262d) !important;
  border-radius: 6px !important;
  color: var(--fg-muted, #8b949e) !important;
  padding: 5px 8px !important;
  font-size: 11px !important;
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
}

.pd-z3-count {
  font-size: 11px !important;
  color: var(--fg-subtle, #6e7681) !important;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 90px;
  text-align: right;
  font-weight: 500;
}

.pd-z3-new-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent, #58a6ff) !important;
  border: none;
  border-radius: 8px !important;
  color: #fff;
  padding: 8px 18px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(88, 166, 255, 0.3);
  transition: all 0.15s;
  letter-spacing: 0.01em;
}

.pd-z3-new-btn:hover {
  box-shadow: 0 4px 12px rgba(88, 166, 255, 0.4) !important;
  transform: translateY(-1px);
  filter: brightness(1.1);
}

.pd-z3-new-btn:active {
  transform: translateY(0) !important;
}

.pd-z3-new-ico {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  flex-shrink: 0;
}

.pd-z3-qfilters {
  display: flex;
  gap: 6px !important;
  padding: 6px 16px !important;
  border-bottom: 1px solid var(--border-muted, #21262d) !important;
  flex-shrink: 0;
  background: var(--bg-default, #161b22);
}

.pd-qf {
  font-size: 10px !important;
  padding: 3px 10px !important;
  border-radius: 12px !important;
  border: 1px solid var(--border-muted, #21262d) !important;
  background: none;
  color: var(--fg-subtle, #6e7681) !important;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}

.pd-qf:hover {
  border-color: var(--fg-subtle, #6e7681) !important;
  color: var(--fg-muted, #8b949e) !important;
}

.pd-qf.active {
  background: rgba(88, 166, 255, 0.1) !important;
  border-color: var(--accent, #58a6ff) !important;
  color: var(--accent, #58a6ff) !important;
}


/* ── "Día despejado" status bar — Refined ─────────────────────────── */
.pd-estado-dia {
  background: rgba(63, 185, 80, 0.06) !important;
  border: 1px solid rgba(63, 185, 80, 0.2) !important;
  color: var(--green, #3fb950) !important;
  padding: 8px 20px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  border-radius: 8px !important;
  margin: 8px 16px !important;
  display: flex;
  align-items: center;
  gap: 8px;
}


/* ═══════════════════════════════════════════════════════════════════
   Light Mode — Complete overrides
   ═══════════════════════════════════════════════════════════════════ */
html[style*="color-scheme: light"] .kpi-card-v2 {
  background: #fff !important;
  border-color: #d8dee4 !important;
}

html[style*="color-scheme: light"] .kpi-card-v2:hover {
  box-shadow: 0 6px 20px rgba(31, 35, 40, 0.12);
  border-color: #d0d7de !important;
}

html[style*="color-scheme: light"] #pd-radar {
  background: #fff !important;
  border-color: #d8dee4 !important;
}

html[style*="color-scheme: light"] #pd-radar h3 {
  color: #57606a !important;
}

html[style*="color-scheme: light"] .rd-lbl {
  color: #57606a !important;
}

html[style*="color-scheme: light"] .rd-row {
  border-bottom-color: #eaeef2;
}

html[style*="color-scheme: light"] .rd-row:hover {
  background: #f6f8fa !important;
}

html[style*="color-scheme: light"] #pd-radar-detail {
  border-top-color: #d8dee4;
}

html[style*="color-scheme: light"] .pd-dash-panel {
  background: #fff !important;
  border-color: #d8dee4 !important;
}

html[style*="color-scheme: light"] .pd-dash-col + .pd-dash-col {
  border-color: #d8dee4 !important;
}

html[style*="color-scheme: light"] .pd-dash-col-title {
  background: #f6f8fa !important;
  border-bottom-color: #d8dee4 !important;
  color: #57606a !important;
}

html[style*="color-scheme: light"] .pd-day {
  background: #eaeef2 !important;
  border-bottom-color: #d8dee4 !important;
  color: #57606a !important;
}

html[style*="color-scheme: light"] .pd-sr {
  border-bottom-color: #f1f5f9 !important;
}

html[style*="color-scheme: light"] .pd-sr:hover {
  background: #f6f8fa !important;
}

html[style*="color-scheme: light"] .pd-sr-proc {
  color: #24292f !important;
}

html[style*="color-scheme: light"] .pd-sr-juz {
  color: #57606a !important;
}

html[style*="color-scheme: light"] .pd-sr-cli {
  color: #6e7781 !important;
}

html[style*="color-scheme: light"] .pd-sr-hora {
  color: #6e7781 !important;
}

html[style*="color-scheme: light"] .pd-pz {
  border-bottom-color: #f1f5f9 !important;
}

html[style*="color-scheme: light"] .pd-pz:hover {
  background: #f6f8fa !important;
}

html[style*="color-scheme: light"] .pd-pz-sec {
  background: #f6f8fa !important;
  border-top-color: #d8dee4 !important;
}

html[style*="color-scheme: light"] .pd-z3-header {
  background: #f6f8fa !important;
  border-bottom-color: #d8dee4 !important;
}

html[style*="color-scheme: light"] .pd-z3-search {
  background: #fff !important;
  border-color: #d0d7de !important;
  color: #24292f !important;
}

html[style*="color-scheme: light"] .pd-z3-search:focus {
  border-color: #0969da !important;
  box-shadow: 0 0 0 2px rgba(9, 105, 218, 0.15) !important;
}

html[style*="color-scheme: light"] .pd-z3-select {
  background: #fff !important;
  border-color: #d0d7de !important;
  color: #24292f !important;
}

html[style*="color-scheme: light"] .pd-z3-count {
  color: #6e7781 !important;
}

html[style*="color-scheme: light"] .pd-z3-new-btn {
  background: #0969da !important;
  box-shadow: 0 2px 6px rgba(9, 105, 218, 0.25);
}

html[style*="color-scheme: light"] .pd-z3-new-btn:hover {
  box-shadow: 0 4px 12px rgba(9, 105, 218, 0.35) !important;
}

html[style*="color-scheme: light"] .pd-z3-qfilters {
  background: #f6f8fa !important;
  border-bottom-color: #d8dee4 !important;
}

html[style*="color-scheme: light"] .pd-qf {
  border-color: #d0d7de !important;
  color: #57606a !important;
}

html[style*="color-scheme: light"] .pd-qf:hover {
  border-color: #57606a !important;
  color: #24292f !important;
}

html[style*="color-scheme: light"] .pd-qf.active {
  background: rgba(9, 105, 218, 0.08) !important;
  border-color: #0969da !important;
  color: #0969da !important;
}

html[style*="color-scheme: light"] .pd-estado-dia {
  background: rgba(26, 127, 55, 0.06) !important;
  border-color: rgba(26, 127, 55, 0.25) !important;
  color: #1a7f37 !important;
}

html[style*="color-scheme: light"] .pd-dash-col::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
}

/* Radar blocks light mode */
html[style*="color-scheme: light"] .rd-block.rd-hoy {
  background: rgba(207, 34, 46, 0.08);
  border-color: rgba(207, 34, 46, 0.25);
}

html[style*="color-scheme: light"] .rd-block.rd-48h {
  background: rgba(188, 76, 0, 0.08);
  border-color: rgba(188, 76, 0, 0.25);
}

html[style*="color-scheme: light"] .rd-block.rd-semana {
  background: rgba(154, 103, 0, 0.08);
  border-color: rgba(154, 103, 0, 0.25);
}

html[style*="color-scheme: light"] .rd-block.rd-vencidos {
  background: rgba(207, 34, 46, 0.08);
  border-color: rgba(207, 34, 46, 0.25);
}

html[style*="color-scheme: light"] .rd-block.rd-sin_resp {
  background: rgba(110, 119, 129, 0.08);
  border-color: rgba(110, 119, 129, 0.25);
}

html[style*="color-scheme: light"] .rd-block:hover {
  box-shadow: 0 6px 18px rgba(31, 35, 40, 0.1);
}


/* ═══════════════════════════════════════════════════════════════════
   Tablet adjustments for dashboard
   ═══════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) and (max-width: 1024px) {
  .pd-dash-panel {
    height: 240px !important;
    margin: 0 12px 8px !important;
  }

  #pd-radar {
    margin: 0 12px 8px !important;
  }

  .rd-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px !important;
  }

  .rd-block {
    padding: 10px 6px !important;
  }

  .rd-num {
    font-size: 22px !important;
  }
}
