/* === dashboard.css === */

/* ============================================
   KPI CARDS
   ============================================ */
.kpi-grid {
  display:grid; grid-template-columns:repeat(4, 1fr); gap:16px;
  margin-bottom:24px;
}
.kpi-card {
  background:var(--card-bg); border-radius:var(--radius-lg); padding:20px 22px 16px;
  position:relative; overflow:hidden;
  border:1px solid var(--card-border);
  transition:all 0.3s cubic-bezier(0.25,0.46,0.45,0.94);
  cursor:default;
}
.kpi-card:hover { border-color:var(--primary-glow); transform:translateY(-2px); box-shadow:0 8px 25px rgba(0,0,0,0.06); }
.kpi-card::after {
  content:''; position:absolute; bottom:0; left:0; right:0; height:3px;
  background:var(--primary); border-radius:0 0 var(--radius-lg) var(--radius-lg);
  opacity:0; transition:opacity 0.3s ease;
}
.kpi-card:hover::after { opacity:1; }
.kpi-card.accent-primary::after { background:var(--primary); }
.kpi-card.accent-success::after { background:var(--success); }
.kpi-card.accent-info::after { background:var(--info); }
.kpi-card.accent-warning::after { background:var(--warning); }
.kpi-top { display:flex; align-items:flex-start; justify-content:space-between; margin-bottom:14px; }
.kpi-icon {
  width:40px; height:40px; border-radius:12px; display:flex; align-items:center;
  justify-content:center; font-size:16px;
}
.kpi-icon.blue { background:rgba(0,122,255,0.1); color:var(--primary); }
.kpi-icon.green { background:var(--success-light); color:var(--success); }
.kpi-icon.orange { background:var(--warning-light); color:var(--warning); }
.kpi-icon.red { background:var(--danger-light); color:var(--danger); }
.kpi-icon.info { background:var(--info-light); color:var(--info); }
.kpi-trend { display:flex; align-items:center; gap:4px; font-size:11px; font-weight:600; padding:3px 8px; border-radius:20px; }
.kpi-trend.up { background:var(--success-light); color:var(--success); }
.kpi-trend.down { background:var(--danger-light); color:var(--danger); }
.kpi-trend.neutral { background:var(--bg-secondary); color:var(--text-muted); }
.kpi-value { font-size:32px; font-weight:700; letter-spacing:-1px; margin-bottom:4px; line-height:1; color:var(--text); }
.kpi-label { font-size:13px; color:var(--text-muted); font-weight:400; }
.kpi-sparkline { margin-top:14px; height:36px; }
.kpi-sparkline canvas { width:100%!important; height:36px!important; }
.kpi-sub { font-size:11px; color:var(--text-muted); margin-top:8px; display:flex; align-items:center; gap:4px; }
.kpi-sub i { font-size:10px; }
.kpi-card[onclick] { cursor:pointer; }

/* KPI Detail Popup */
.kpi-popup-overlay { display:none; position:fixed; inset:0; z-index:200; background:rgba(0,0,0,0.25); backdrop-filter:blur(4px); -webkit-backdrop-filter:blur(4px); }
.kpi-popup-overlay.active { display:flex; align-items:flex-start; justify-content:center; padding-top:12vh; animation:fadeIn 0.15s ease; }
.kpi-popup {
  background:var(--card-bg); border-radius:14px; width:420px; max-width:90vw;
  box-shadow:0 20px 60px rgba(0,0,0,0.15); border:1px solid var(--card-border);
  animation:scaleIn 0.2s ease; overflow:hidden;
}
.kpi-popup-header {
  padding:16px 20px; display:flex; align-items:center; gap:10px;
  border-bottom:1px solid var(--border-light);
}
.kpi-popup-header .kp-icon { width:32px; height:32px; border-radius:9px; display:flex; align-items:center; justify-content:center; font-size:13px; }
.kpi-popup-header h4 { font-size:15px; font-weight:600; flex:1; }
.kpi-popup-header .kp-close { background:none; border:none; cursor:pointer; color:var(--text-muted); font-size:14px; padding:4px; border-radius:6px; }
.kpi-popup-header .kp-close:hover { background:var(--bg-secondary); }
.kpi-popup-body { padding:16px 20px; max-height:50vh; overflow-y:auto; }
.kpi-popup-body .kp-stat { display:flex; justify-content:space-between; padding:8px 0; border-bottom:1px solid var(--border-light); font-size:13px; }
.kpi-popup-body .kp-stat:last-child { border-bottom:none; }
.kpi-popup-body .kp-stat .kp-label { color:var(--text-secondary); }
.kpi-popup-body .kp-stat .kp-value { font-weight:600; color:var(--text); }
.kpi-popup-body .kp-list { margin-top:10px; }
.kpi-popup-body .kp-list-item {
  display:flex; align-items:center; gap:10px; padding:8px 0;
  border-bottom:1px solid var(--border-light); font-size:12px;
}
.kpi-popup-body .kp-list-item:last-child { border-bottom:none; }
.kpi-popup-body .kp-list-item .kp-avatar { width:28px; height:28px; border-radius:8px; display:flex; align-items:center; justify-content:center; font-size:11px; flex-shrink:0; }
.kpi-popup-body .kp-list-item .kp-name { font-weight:500; color:var(--text); flex:1; }
.kpi-popup-body .kp-list-item .kp-meta { color:var(--text-muted); font-size:11px; }
.kpi-popup-footer { padding:12px 20px; border-top:1px solid var(--border-light); text-align:center; }
.kpi-popup-footer a { font-size:12px; color:var(--primary); font-weight:500; cursor:pointer; text-decoration:none; }
.kpi-popup-footer a:hover { text-decoration:underline; }
[data-theme="dark"] .kpi-popup { box-shadow:0 20px 60px rgba(0,0,0,0.4); }

/* Dashboard Welcome */
.dash-welcome {
  display:flex; align-items:center; justify-content:space-between; margin-bottom:28px;
}
.dash-welcome-left h1 { font-size:26px; font-weight:700; letter-spacing:-0.5px; margin-bottom:4px; color:var(--text); }
.dash-welcome-left p { font-size:14px; color:var(--text-secondary); }
.dash-welcome-right { display:flex; gap:8px; align-items:center; }
.dash-time-pill {
  display:flex; background:var(--bg-secondary); border-radius:var(--radius); padding:2px; gap:2px;
  border:1px solid var(--card-border);
}
.dash-time-pill button {
  padding:6px 14px; border-radius:6px; font-size:12px; font-weight:500;
  cursor:pointer; border:none; background:transparent; color:var(--text-secondary);
  transition:var(--transition); font-family:inherit;
}
.dash-time-pill button.active { background:var(--card-bg); color:var(--text); box-shadow:0 1px 3px rgba(0,0,0,0.08); }
.dash-time-pill button:hover:not(.active) { color:var(--text); }

/* Dashboard Grid Layout */
.dash-grid {
  display:grid; grid-template-columns:1fr 340px; gap:16px; margin-bottom:16px;
}
.dash-grid-full { grid-column:1/-1; }

/* Activity Feed */
.activity-feed { background:var(--card-bg); border-radius:var(--radius-lg); border:1px solid var(--card-border); overflow:hidden; }
.activity-feed-header {
  padding:16px 20px; border-bottom:1px solid var(--border-light);
  display:flex; align-items:center; justify-content:space-between;
}
.activity-feed-header h3 { font-size:14px; font-weight:600; color:var(--text); display:flex; align-items:center; gap:8px; }
.activity-feed-header .live-dot { width:7px; height:7px; border-radius:50%; background:var(--success); animation:pulse 2s infinite; }
.activity-feed-body { max-height:420px; overflow-y:auto; }
.activity-item {
  display:flex; align-items:flex-start; gap:12px; padding:14px 20px;
  border-bottom:1px solid var(--border-light); transition:background 0.15s ease;
}
.activity-item:hover { background:var(--bg-secondary); }
.activity-item:last-child { border-bottom:none; }
.activity-avatar {
  width:34px; height:34px; border-radius:10px; display:flex; align-items:center;
  justify-content:center; font-size:13px; flex-shrink:0;
}
.activity-avatar.a-msg { background:rgba(0,122,255,0.1); color:var(--primary); }
.activity-avatar.a-book { background:var(--success-light); color:var(--success); }
.activity-avatar.a-esc { background:var(--warning-light); color:var(--warning); }
.activity-avatar.a-new { background:rgba(88,86,214,0.1); color:#5856d6; }
.activity-content { flex:1; min-width:0; }
.activity-content .a-title { font-size:13px; font-weight:500; color:var(--text); margin-bottom:2px; }
.activity-content .a-title strong { font-weight:600; }
.activity-content .a-desc { font-size:12px; color:var(--text-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.activity-time { font-size:11px; color:var(--text-muted); white-space:nowrap; flex-shrink:0; margin-top:2px; }
.activity-empty { padding:40px 20px; text-align:center; color:var(--text-muted); font-size:13px; }
.activity-empty i { font-size:24px; margin-bottom:8px; display:block; opacity:0.4; }

/* Quick Stats Row */
.quick-stats {
  display:grid; grid-template-columns:repeat(3, 1fr); gap:12px;
  background:var(--card-bg); border-radius:var(--radius-lg); border:1px solid var(--card-border);
  padding:16px 20px;
}
.quick-stat { text-align:center; }
.quick-stat .qs-value { font-size:20px; font-weight:700; color:var(--text); letter-spacing:-0.5px; }
.quick-stat .qs-label { font-size:11px; color:var(--text-muted); margin-top:2px; }
.quick-stat .qs-bar { height:4px; background:var(--bg-secondary); border-radius:2px; margin-top:8px; overflow:hidden; }
.quick-stat .qs-bar-fill { height:100%; border-radius:2px; transition:width 1s ease; }

/* Bot Status Indicator */
.bot-status-card {
  background:var(--card-bg); border-radius:var(--radius-lg); border:1px solid var(--card-border);
  padding:16px 20px; display:flex; align-items:center; gap:14px;
}
.bot-status-dot { width:10px; height:10px; border-radius:50%; flex-shrink:0; }
.bot-status-dot.online { background:var(--success); box-shadow:0 0 8px rgba(36,138,61,0.4); animation:pulse 2s infinite; }
.bot-status-dot.offline { background:var(--danger); }
.bot-status-info { flex:1; }
.bot-status-info .bs-title { font-size:13px; font-weight:600; color:var(--text); }
.bot-status-info .bs-sub { font-size:11px; color:var(--text-muted); }

/* ============================================
   WELCOME BANNER
   ============================================ */
.welcome-banner {
  border-radius:var(--radius-lg); padding:24px 28px; margin-bottom:24px;
  background:var(--card-bg); border:1px solid var(--card-border);
  color:var(--text); display:flex; align-items:center; justify-content:space-between;
  position:relative; overflow:hidden;
}
.welcome-banner::before { display:none; }
.welcome-banner .wb-content { position:relative; z-index:1; }
.welcome-banner .wb-content h2 { font-size:20px; font-weight:600; letter-spacing:-0.3px; margin-bottom:4px; color:var(--text); }
.welcome-banner .wb-content p { font-size:13px; color:var(--text-secondary); }
.welcome-banner .wb-actions { position:relative; z-index:1; display:flex; gap:8px; }
.welcome-banner .wb-actions .btn-banner {
  padding:8px 16px; border-radius:var(--radius); font-size:13px; font-weight:500;
  cursor:pointer; transition:var(--transition); font-family:inherit; border:none;
  display:flex; align-items:center; gap:6px;
}
.welcome-banner .wb-actions .btn-banner.primary { background:var(--primary); color:#fff; }
.welcome-banner .wb-actions .btn-banner.primary:hover { opacity:0.85; }
.welcome-banner .wb-actions .btn-banner.secondary { background:var(--bg-secondary); color:var(--text); border:1px solid var(--border); }
.welcome-banner .wb-actions .btn-banner.secondary:hover { background:var(--border-light); }

/* ============================================
   CHARTS / CARDS
   ============================================ */
.charts-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(380px,1fr)); gap:16px; margin-bottom:16px; }
.chart-card {
  background:var(--card-bg); border-radius:var(--radius-lg); padding:22px;
  border:1px solid var(--card-border);
  transition:all 0.3s cubic-bezier(0.25,0.46,0.45,0.94);
}
.chart-card:hover { box-shadow:0 8px 25px rgba(0,0,0,0.06); transform:translateY(-1px); }
.chart-card-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:18px; }
.chart-card-header h3 { font-size:14px; font-weight:600; color:var(--text); display:flex; align-items:center; gap:8px; }
.chart-card-header h3 i { font-size:14px; color:var(--text-muted); }
.chart-card-header .chart-actions { display:flex; gap:4px; }
.chart-card-header .chart-pill {
  padding:5px 12px; border-radius:20px; font-size:11px; font-weight:600;
  cursor:pointer; border:none; background:var(--bg-secondary); color:var(--text-secondary);
  transition:var(--transition);
}
.chart-card-header .chart-pill.active { background:var(--primary); color:#fff; }
.chart-card-header .chart-pill:hover:not(.active) { background:var(--border-light); }
.chart-card canvas { width:100%!important; max-height:260px; }
.chart-card-footer { margin-top:12px; padding-top:12px; border-top:1px solid var(--border-light); display:flex; justify-content:space-between; font-size:11px; color:var(--text-muted); }

/* System Health */
.system-health {
  background:var(--card-bg); border-radius:var(--radius-md); padding:20px;
  box-shadow:var(--shadow-sm); border:1px solid var(--card-border); margin-bottom:28px;
}
.system-health h3 { font-size:15px; font-weight:600; margin-bottom:16px; display:flex; align-items:center; gap:8px; }
.health-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(200px,1fr)); gap:12px; }
.health-item {
  display:flex; align-items:center; gap:10px; padding:10px 14px;
  background:var(--bg-secondary); border-radius:var(--radius); font-size:13px; font-weight:500;
}
.health-dot { width:8px; height:8px; border-radius:50%; flex-shrink:0; }
.health-dot.green { background:var(--success); box-shadow:0 0 6px var(--success); }
.health-dot.red { background:var(--danger); box-shadow:0 0 6px var(--danger); }
.health-dot.yellow { background:var(--warning); box-shadow:0 0 6px var(--warning); }
.health-dot.checking { background:var(--text-muted); animation:pulse 1s infinite; }

/* Live Activity Feed */
.activity-feed {
  background:var(--card-bg); border-radius:var(--radius-md); padding:20px;
  box-shadow:var(--shadow-sm); border:1px solid var(--card-border);
}
.activity-feed h3 { font-size:15px; font-weight:600; margin-bottom:16px; display:flex; align-items:center; gap:8px; }
.activity-feed h3 .live-dot { width:8px; height:8px; border-radius:50%; background:var(--success); animation:pulse 1.5s infinite; display:inline-block; }
.activity-list { max-height:400px; overflow-y:auto; }
.activity-item {
  display:flex; gap:12px; padding:10px 0; border-bottom:1px solid var(--border-light);
  animation: fadeInLeft 0.3s ease;
}
.activity-item:last-child { border-bottom:none; }
.activity-item .a-icon {
  width:34px; height:34px; border-radius:8px; display:flex; align-items:center;
  justify-content:center; font-size:13px; flex-shrink:0;
}
.activity-item .a-content { flex:1; }
.activity-item .a-content .a-text { font-size:13px; font-weight:500; line-height:1.4; }
.activity-item .a-content .a-time { font-size:11px; color:var(--text-muted); margin-top:2px; }
