/* ═══════════════════════════════════════════════════════════════
   KLINAFY - DASHBOARD DE PRODUCTIVIDAD - ESTILOS
   Panel flotante de métricas y reportes del consultorio
   v1.0 - Marzo 2026
   ═══════════════════════════════════════════════════════════════ */

/* ── BOTÓN FLOTANTE (FAB) ─────────────────────────────────── */
.dashboard-floating-btn {
  position: fixed;
  bottom: 400px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  border: none;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
  z-index: 9998;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dashboard-floating-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}
.dashboard-floating-btn:active { transform: scale(0.95); }

/* ── PANEL PRINCIPAL ──────────────────────────────────────── */
#pantallaDashboard {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg-primary, #f0f4f8);
  overflow-y: auto;
  animation: dashSlideIn 0.25s ease-out;
}
@keyframes dashSlideIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.dashboard-container {
  max-width: 1060px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* ── HEADER ───────────────────────────────────────────────── */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.dashboard-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary, #1a202c);
  margin: 0;
}
.dashboard-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ── SELECTOR DE PERIODO ──────────────────────────────────── */
.dash-period-selector {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary, #fff);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid var(--border-color, #e2e8f0);
}
.dash-period-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary, #64748b);
  transition: all 0.15s;
}
.dash-period-btn.active {
  background: var(--accent-primary, #6366f1);
  color: #fff;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}
.dash-period-btn:hover:not(.active) {
  background: var(--bg-primary, #f0f4f8);
}

/* ── KPI CARDS ────────────────────────────────────────────── */
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.dash-kpi-card {
  background: var(--bg-secondary, #fff);
  border-radius: 12px;
  padding: 18px;
  border: 1px solid var(--border-color, #e2e8f0);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  position: relative;
  overflow: hidden;
}
.dash-kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.dash-kpi-card.kpi-patients::before { background: #6366f1; }
.dash-kpi-card.kpi-appointments::before { background: #0ea5e9; }
.dash-kpi-card.kpi-noshow::before { background: #f59e0b; }
.dash-kpi-card.kpi-income::before { background: #10b981; }
.dash-kpi-card.kpi-cases::before { background: #8b5cf6; }
.dash-kpi-card.kpi-inventory::before { background: #ef4444; }

.dash-kpi-icon {
  font-size: 1.4rem;
  margin-bottom: 6px;
}
.dash-kpi-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary, #1a202c);
  line-height: 1;
  margin-bottom: 2px;
}
.dash-kpi-label {
  font-size: 0.78rem;
  color: var(--text-secondary, #64748b);
  font-weight: 500;
}
.dash-kpi-trend {
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 10px;
}
.trend-up { background: #dcfce7; color: #15803d; }
.trend-down { background: #fee2e2; color: #dc2626; }
.trend-neutral { background: #f1f5f9; color: #64748b; }

/* ── SECCIONES / PANELS ───────────────────────────────────── */
.dash-section {
  background: var(--bg-secondary, #fff);
  border-radius: 12px;
  border: 1px solid var(--border-color, #e2e8f0);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  margin-bottom: 16px;
  overflow: hidden;
}
.dash-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}
.dash-section-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary, #1a202c);
  margin: 0;
}
.dash-section-body { padding: 18px; }

/* ── GRID 2 COLUMNAS PARA SECCIONES ──────────────────────── */
.dash-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── BARRAS HORIZONTALES (chart simple) ───────────────────── */
.dash-bar-chart { display: flex; flex-direction: column; gap: 10px; }
.dash-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dash-bar-label {
  min-width: 100px;
  font-size: 0.8rem;
  color: var(--text-primary, #1a202c);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-bar-track {
  flex: 1;
  height: 22px;
  background: var(--bg-primary, #f0f4f8);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.dash-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.6s ease-out;
  min-width: 2px;
}
.dash-bar-fill.bar-purple { background: linear-gradient(90deg, #8b5cf6, #6366f1); }
.dash-bar-fill.bar-blue { background: linear-gradient(90deg, #38bdf8, #0ea5e9); }
.dash-bar-fill.bar-green { background: linear-gradient(90deg, #34d399, #10b981); }
.dash-bar-fill.bar-amber { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.dash-bar-fill.bar-red { background: linear-gradient(90deg, #f87171, #ef4444); }
.dash-bar-value {
  min-width: 36px;
  text-align: right;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary, #1a202c);
}

/* ── MINI SPARKLINE (CSS-only) ────────────────────────────── */
.dash-sparkline {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 40px;
}
.dash-spark-bar {
  flex: 1;
  min-width: 4px;
  border-radius: 2px 2px 0 0;
  transition: height 0.4s ease-out;
}
.dash-spark-bar.spark-purple { background: #6366f1; }
.dash-spark-bar.spark-blue { background: #0ea5e9; }
.dash-spark-bar.spark-green { background: #10b981; }

/* ── TABLA SIMPLE ─────────────────────────────────────────── */
.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.dash-table th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  border-bottom: 2px solid var(--border-color, #e2e8f0);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.dash-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  color: var(--text-primary, #1a202c);
}
.dash-table tr:last-child td { border-bottom: none; }
.dash-table tr:hover td { background: var(--bg-primary, #f7fafc); }
.dash-table .td-right { text-align: right; }
.dash-table .td-bold { font-weight: 700; }
.dash-table .td-green { color: #10b981; }
.dash-table .td-red { color: #ef4444; }

/* ── ALERTAS ──────────────────────────────────────────────── */
.dash-alerts-list { display: flex; flex-direction: column; gap: 8px; }
.dash-alert-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
}
.dash-alert-item.alert-warn {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}
.dash-alert-item.alert-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}
.dash-alert-item.alert-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}
.dash-alert-icon { font-size: 1.1rem; }

/* ── MODAL DE INGRESO ─────────────────────────────────────── */
.dash-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  padding: 16px;
  animation: dashFadeIn 0.15s ease-out;
}
@keyframes dashFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.dash-modal {
  background: var(--bg-secondary, #fff);
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.dash-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}
.dash-modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary, #1a202c);
}
.dash-modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-secondary, #64748b);
  padding: 4px 8px;
  border-radius: 6px;
}
.dash-modal-close:hover { background: var(--bg-primary, #f7fafc); }
.dash-modal-body { padding: 20px; }
.dash-modal-body .form-group { margin-bottom: 14px; }
.dash-modal-body .form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  margin-bottom: 5px;
}
.dash-modal-body .form-group input,
.dash-modal-body .form-group select,
.dash-modal-body .form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--bg-primary, #f7fafc);
  color: var(--text-primary, #1a202c);
  box-sizing: border-box;
}
.dash-modal-body .form-group input:focus,
.dash-modal-body .form-group select:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.dash-modal-body .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.dash-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-color, #e2e8f0);
}

/* ── TABS ─────────────────────────────────────────────────── */
.dash-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-color, #e2e8f0);
  margin-bottom: 18px;
}
.dash-tab {
  padding: 10px 18px;
  border: none;
  background: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}
.dash-tab.active {
  color: #6366f1;
  border-bottom-color: #6366f1;
}
.dash-tab:hover:not(.active) { color: var(--text-primary, #1a202c); }

/* ── EMPTY STATE ──────────────────────────────────────────── */
.dash-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary, #64748b);
}
.dash-empty-icon { font-size: 2.5rem; margin-bottom: 10px; }
.dash-empty h4 {
  font-size: 1rem;
  color: var(--text-primary, #1a202c);
  margin-bottom: 4px;
}
.dash-empty p { font-size: 0.85rem; }

/* ── BOTONES REUTILIZADOS ─────────────────────────────────── */
.dashboard-container .btn,
.dash-modal .btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.dashboard-container .btn-primary,
.dash-modal .btn-primary {
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
}
.dashboard-container .btn-primary:hover,
.dash-modal .btn-primary:hover { background: #4f46e5; }
.dashboard-container .btn-secondary,
.dash-modal .btn-secondary {
  background: var(--bg-secondary, #fff);
  color: var(--text-primary, #1a202c);
  border-color: var(--border-color, #e2e8f0);
}
.dashboard-container .btn-secondary:hover,
.dash-modal .btn-secondary:hover { background: var(--bg-primary, #f7fafc); }

/* ── RESUMEN RÁPIDO (inline en KPI) ──────────────────────── */
.dash-kpi-detail {
  font-size: 0.72rem;
  color: var(--text-secondary, #64748b);
  margin-top: 4px;
  line-height: 1.4;
}

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .dash-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid-2 { grid-template-columns: 1fr; }
  .dash-period-selector { flex-wrap: wrap; }
  .dashboard-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
  .dash-kpi-grid { grid-template-columns: 1fr; }
  .dash-bar-label { min-width: 70px; font-size: 0.75rem; }
}
