/* ============================================================
   PROFFBankrot Dashboard — Reusable Components
   ============================================================ */

/* ------------------------------------------------------------
   1. Stats Grid & Cards
   ------------------------------------------------------------ */
.stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }

.stat-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--r); padding: 18px; transition: all 0.2s; position: relative; overflow: hidden; }
.stat-card:hover { box-shadow: var(--sh2); transform: translateY(-1px); }
.stat-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.stat-card-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.stat-card-delta { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.stat-card-delta.up { background: var(--green-l); color: #065f46; }
.stat-card-delta.down { background: var(--red-l); color: var(--red); }
.stat-card-delta.flat { background: var(--border2); color: var(--muted); }
.stat-card-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 4px; }
.stat-card-value { font-size: 28px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; }
.stat-card-sub { font-size: 11px; color: var(--text2); margin-top: 4px; }
.stat-card-spark { margin-top: 8px; }

/* ------------------------------------------------------------
   2. Content Cards
   ------------------------------------------------------------ */
.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--r2); box-shadow: var(--sh); margin-bottom: 16px; overflow: hidden; }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--border2); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 14px; font-weight: 700; }
.card-badge { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 100px; }
.badge-blue { background: var(--blue-l); color: var(--blue); }
.badge-green { background: var(--green-l); color: #065f46; }
.badge-red { background: var(--red-l); color: var(--red); }
.badge-yellow { background: var(--yellow-l); color: #92400e; }
.badge-purple { background: var(--purple-l); color: var(--purple); }
.card-body { padding: 18px; }

/* ------------------------------------------------------------
   3. Grid Layouts
   ------------------------------------------------------------ */
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.cols-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.cols-23 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.cols-32 { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; margin-bottom: 16px; }

/* ------------------------------------------------------------
   4. Bar Charts
   ------------------------------------------------------------ */
.bar-chart { display: flex; align-items: flex-end; gap: 3px; padding-top: 8px; position: relative; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; height: 100%; justify-content: flex-end; position: relative; }
.bar-col .bar-tooltip { display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: #1f2937; color: #fff; padding: 4px 8px; border-radius: 6px; font-size: 11px; white-space: nowrap; z-index: 10; margin-bottom: 4px; pointer-events: none; }
.bar-col:hover .bar-tooltip { display: block; }
.bar { border-radius: 4px 4px 0 0; width: 100%; min-height: 2px; transition: height 0.4s ease; }
.bar-stack { display: flex; flex-direction: column-reverse; width: 100%; border-radius: 4px 4px 0 0; overflow: hidden; }
.bar-label { font-size: 9px; color: var(--muted); font-weight: 500; white-space: nowrap; margin-top: 4px; }

/* ------------------------------------------------------------
   5. Horizontal Bar List
   ------------------------------------------------------------ */
.h-bar-list { display: flex; flex-direction: column; gap: 8px; }
.h-bar-row { display: flex; align-items: center; gap: 10px; cursor: default; }
.h-bar-label { width: 140px; font-size: 12px; font-weight: 500; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.h-bar-track { flex: 1; height: 24px; background: var(--border2); border-radius: 6px; overflow: hidden; position: relative; }
.h-bar-fill { height: 100%; border-radius: 6px; transition: width 0.5s ease; display: flex; align-items: center; padding: 0 8px; }
.h-bar-fill-text { font-size: 10px; font-weight: 700; color: white; }
.h-bar-value { width: 50px; text-align: right; font-size: 12px; font-weight: 600; color: var(--text); flex-shrink: 0; }

/* ------------------------------------------------------------
   6. Donut Chart
   ------------------------------------------------------------ */
.donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.donut-svg { flex-shrink: 0; }
.donut-legend { display: flex; flex-direction: column; gap: 6px; }
.donut-legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.donut-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.donut-legend-label { color: var(--text2); flex: 1; }
.donut-legend-value { font-weight: 600; color: var(--text); white-space: nowrap; }

/* ------------------------------------------------------------
   7. Leaderboard
   ------------------------------------------------------------ */
.lb-list { display: flex; flex-direction: column; gap: 8px; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 8px; cursor: pointer; transition: background 0.15s; }
.lb-row:hover { background: var(--bg); }
.lb-pos { width: 20px; font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; }
.lb-avatar { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: white; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-bar { height: 4px; background: var(--border2); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.lb-bar-fill { height: 100%; border-radius: 2px; transition: width 0.5s ease; }
.lb-value { font-size: 13px; font-weight: 700; white-space: nowrap; }

/* ------------------------------------------------------------
   8. Tables
   ------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; padding: 8px 12px; border-bottom: 2px solid var(--border); text-align: left; white-space: nowrap; }
thead th.num { text-align: right; }
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--accent); }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border2); }
tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--bg); }
tbody tr.clickable { cursor: pointer; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }

/* ------------------------------------------------------------
   9. Tabs
   ------------------------------------------------------------ */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; padding: 4px; background: var(--border2); border-radius: 10px; }
.tab { padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s; color: var(--text2); border: none; background: none; font-family: inherit; }
.tab:hover { background: var(--white); color: var(--text); }
.tab.active { background: var(--white); color: var(--accent); font-weight: 600; box-shadow: var(--sh); }

/* ------------------------------------------------------------
   10. Funnel
   ------------------------------------------------------------ */
.funnel { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.funnel-phase { padding: 14px 20px; text-align: center; color: white; transition: all 0.3s; }
.funnel-phase-name { font-size: 12px; font-weight: 600; opacity: 0.9; }
.funnel-phase-value { font-size: 20px; font-weight: 800; }
.funnel-phase-sum { font-size: 11px; opacity: 0.8; }
.funnel-arrow { font-size: 14px; color: var(--muted); padding: 2px 0; }
.funnel-arrow-pct { font-weight: 700; color: var(--accent); }

/* ------------------------------------------------------------
   11. Conversion Waterfall / Matrix
   ------------------------------------------------------------ */
.conv-matrix { display: flex; flex-direction: column; gap: 6px; }
.conv-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; }
.conv-row:hover { background: var(--bg); }
.conv-from, .conv-to { font-size: 12px; font-weight: 500; flex: 1; }
.conv-from { text-align: right; color: var(--text2); }
.conv-to { color: var(--text); }
.conv-arrow { color: var(--muted); font-size: 14px; flex-shrink: 0; }
.conv-rate { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; flex-shrink: 0; }
.conv-rate.high { background: var(--green-l); color: #065f46; }
.conv-rate.mid { background: var(--yellow-l); color: #92400e; }
.conv-rate.low { background: var(--red-l); color: var(--red); }

/* ------------------------------------------------------------
   12. Recommendations
   ------------------------------------------------------------ */
.rec-list { display: flex; flex-direction: column; gap: 10px; }
.rec-card { padding: 14px 16px; border-radius: var(--r); border-left: 4px solid; }
.rec-card.critical { background: var(--red-l); border-color: var(--red); }
.rec-card.warning { background: var(--yellow-l); border-color: var(--yellow); }
.rec-card.opportunity { background: var(--green-l); border-color: var(--green); }
.rec-card.info { background: var(--blue-l); border-color: var(--blue); }
.rec-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.rec-title { font-size: 13px; font-weight: 700; }
.rec-metric { font-size: 11px; font-weight: 600; color: var(--text2); }
.rec-desc { font-size: 12px; color: var(--text2); line-height: 1.5; }
.rec-action { font-size: 12px; font-weight: 600; color: var(--accent); margin-top: 6px; }

/* ------------------------------------------------------------
   13. Heatmap & Radar Wrap
   ------------------------------------------------------------ */
.heatmap { display: grid; grid-template-columns: repeat(auto-fill, minmax(28px, 1fr)); gap: 2px; }
.heatmap-cell { aspect-ratio: 1; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; }
.heatmap-labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(28px, 1fr)); gap: 2px; margin-top: 2px; }
.heatmap-label { text-align: center; font-size: 9px; color: var(--muted); }
.radar-wrap { display: flex; justify-content: center; padding: 10px; }

/* ------------------------------------------------------------
   14. Pipeline Cards
   ------------------------------------------------------------ */
.pipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.pipe-card { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r); cursor: pointer; transition: all 0.2s; }
.pipe-card:hover { box-shadow: var(--sh2); border-color: var(--accent); transform: translateY(-1px); }
.pipe-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.pipe-card-name { font-size: 13px; font-weight: 700; }
.pipe-card-count { font-size: 18px; font-weight: 800; color: var(--accent); }

/* ------------------------------------------------------------
   15. CRM Link & Misc
   ------------------------------------------------------------ */
.crm-link { color: var(--accent); text-decoration: none; font-size: 11px; font-weight: 600; }
.crm-link:hover { text-decoration: underline; }
.mgr-link { color: var(--accent); cursor: pointer; font-weight: 600; }
.mgr-link:hover { text-decoration: underline; }

/* ------------------------------------------------------------
   16. Filters
   ------------------------------------------------------------ */
.filters-bar { display: flex; align-items: center; gap: 10px; padding: 12px 0; flex-wrap: wrap; }
.filter-group { display: flex; align-items: center; gap: 6px; }
.filter-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; }
.filter-chip { padding: 5px 12px; border-radius: 100px; font-size: 12px; font-weight: 500; border: 1px solid var(--border); background: var(--white); cursor: pointer; transition: all 0.15s; color: var(--text2); }
.filter-chip:hover { border-color: var(--accent); color: var(--accent); }
.filter-chip.active { background: var(--accent); color: white; border-color: var(--accent); }
.filter-select { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 12px; font-family: inherit; background: var(--white); color: var(--text); cursor: pointer; }
.filter-select:focus { outline: none; border-color: var(--accent); }
