/* ═══════════════════════════════════════════════════════════
   QHPlus Credit Hub — Design System
   ═══════════════════════════════════════════════════════════ */

* { font-family: 'Inter', sans-serif; }
body { background: #F8F9FA; color: #212529; -webkit-font-smoothing: antialiased; }

.glass-panel { background: rgba(255,255,255,0.8); backdrop-filter: blur(20px); border: 1px solid rgba(233,236,239,0.5); box-shadow: 0 2px 4px rgba(0,0,0,0.02), 0 10px 20px rgba(0,0,0,0.04); }
.bento-card { background: #fff; border: 1px solid rgba(233,236,239,0.5); border-radius: 32px; padding: 2rem; box-shadow: 0 2px 4px rgba(0,0,0,0.02), 0 10px 20px rgba(0,0,0,0.04); transition: all 0.5s; }
.bento-card:hover { box-shadow: 0 20px 40px rgba(0,0,0,0.08); transform: translateY(-4px); }

.sidebar-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1.25rem; border-radius: 1rem; transition: all 0.3s; cursor: pointer; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; font-size: 12px; white-space: nowrap; overflow: hidden; }
.sidebar-item:hover { background: #FDF2F4; color: #8B1A2C; }
.sidebar-item.active { background: #8B1A2C; color: #fff; box-shadow: 0 10px 20px rgba(139,26,44,0.2); }

.kpi-number { font-size: 2rem; font-weight: 900; letter-spacing: -0.05em; line-height: 1; }
.label { font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.15em; color: #ADB5BD; }

.level-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.level-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 9px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.1em; }

.progress-bar { height: 8px; background: #F1F3F5; border-radius: 999px; overflow: hidden; border: 1px solid rgba(233,236,239,0.3); }
.progress-fill { height: 100%; border-radius: 999px; transition: width 1s ease; }

.table-row:hover { background: #212529; color: #F8F9FA; }
.table-row:hover .badge-cell { background: rgba(255,255,255,0.2) !important; }

@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.animate-pulse-dot { animation: pulse-dot 2s ease-in-out infinite; }

@keyframes fade-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.animate-in { animation: fade-in 0.7s ease both; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #E9ECEF; border-radius: 3px; }

/* Calendar */
.cal-cell { height: calc((100vh - 280px) / 6); min-height: 90px; max-height: 130px; border-right: 1px solid rgba(233,236,239,0.3); border-bottom: 1px solid rgba(233,236,239,0.3); padding: 6px 8px; transition: all 0.2s; cursor: pointer; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.cal-cell:hover { background: rgba(253,242,244,0.5); }
.cal-cell.selected { background: rgba(139,26,44,0.05); box-shadow: inset 0 0 0 2px #8B1A2C; z-index: 10; }
.cal-cell.today { background: rgba(28,126,214,0.05); }
.cal-cell.other-month { opacity: 0.35; }

/* Metric Cards (v2) */
.metric-card {
  position: relative; padding: 1.25rem; border-radius: 28px;
  overflow: hidden; min-height: 150px;
  display: flex; flex-direction: column; justify-content: space-between;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: help;
}
.metric-card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(0,0,0,0.12); }
#bucketCardsRow .metric-card { min-height: auto; padding: 1rem; border-radius: 20px; cursor: pointer; }
#bucketCardsRow .metric-card:hover { transform: translateY(-2px); }
#kpiCardOverdue.metric-card, #kpiCardToday.metric-card { min-height: auto; border-radius: 20px; padding: 1rem 1.25rem; }
.metric-card::after {
  content: ''; position: absolute; top: -20px; right: -20px;
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(255,255,255,0.06); filter: blur(20px);
  pointer-events: none;
}
.mc-header { margin-bottom: 1rem; position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; }
.mc-icon { padding: 0.5rem; background: rgba(255,255,255,0.12); border-radius: 12px; backdrop-filter: blur(8px); display: inline-flex; }
.mc-label { font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.12em; color: rgba(255,255,255,0.5); margin-bottom: 4px; position: relative; z-index: 2; }
.mc-value { font-size: 1.75rem; font-weight: 900; letter-spacing: -0.04em; line-height: 1; color: white; position: relative; z-index: 2; }

/* Hover overlay */
.mc-overlay {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(0,0,0,0.88); backdrop-filter: blur(16px);
  padding: 1.25rem; display: flex; flex-direction: column; justify-content: center;
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none; border-radius: 28px;
}
.metric-card:hover .mc-overlay { opacity: 1; transform: translateY(0); pointer-events: auto; }
.mc-overlay-title { font-size: 9px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.2em; color: #8B1A2C; margin-bottom: 10px; }
.mc-overlay-desc { font-size: 12px; font-weight: 600; color: white; line-height: 1.65; }

/* Smart Alert card overlay */
.sa-overlay {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(15,15,15,0.94); backdrop-filter: blur(16px);
  padding: 1rem 1.25rem; display: flex; flex-direction: column; justify-content: flex-start;
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none; border-radius: 16px;
  overflow-y: auto;
}
.sa-overlay::-webkit-scrollbar { width: 3px; }
.sa-overlay::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }
.sa-overlay .mc-overlay-title { margin-bottom: 8px; margin-top: 4px; }
.sa-overlay .mc-overlay-desc { font-size: 11px; line-height: 1.7; }
.smart-alert-card:hover .sa-overlay { opacity: 1; transform: translateY(0); pointer-events: auto; }

/* Sidebar transitions */
#sidebar .sb-text {
  transition: opacity 0.3s ease, max-width 0.3s ease, margin 0.3s ease, padding 0.3s ease;
  opacity: 1; max-width: 200px; overflow: hidden; white-space: nowrap;
}
#sidebar .sidebar-item { transition: padding 0.4s ease; }
#sidebar .sidebar-item svg { width: 20px; height: 20px; flex-shrink: 0; }
#sidebar nav { transition: padding 0.4s ease; }
#sidebar .user-section { transition: padding 0.4s ease; }
#sidebar .user-card { transition: padding 0.4s ease; }

/* Floating toggle button */
.sidebar-toggle {
  position: absolute; right: -12px; top: 50px;
  width: 24px; height: 24px; border-radius: 50%;
  background: white; border: 1px solid #e5e7eb;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 50;
  transition: transform 0.3s ease, background 0.2s ease;
}
.sidebar-toggle:hover { background: #f3f4f6; transform: scale(1.15); }
.sidebar-toggle svg { width: 12px; height: 12px; color: #6b7280; transition: transform 0.4s ease; }

/* Alert badge */
#alertBadge { transition: all 0.3s ease; }

/* Sidebar collapsed state */
#sidebar.collapsed { width: 64px !important; }
#sidebar.collapsed .sidebar-header-content { justify-content: center; }
#sidebar.collapsed .sidebar-item {
  display: flex; align-items: center; justify-content: center;
  width: 40px !important; height: 40px !important;
  padding: 0 !important; border-radius: 12px;
  position: relative; overflow: visible;
  box-sizing: border-box;
}
#sidebar.collapsed .sb-text {
  opacity: 0; max-width: 0; pointer-events: none; margin: 0; padding: 0;
  position: absolute;
}
#sidebar.collapsed #alertBadge {
  opacity: 1 !important; max-width: none !important;
  position: absolute; top: -3px; right: -6px;
  width: 18px; height: 18px; font-size: 9px;
  margin: 0; padding: 0;
  pointer-events: auto;
}
#sidebar.collapsed .sidebar-toggle svg { transform: rotate(180deg); }
#sidebar.collapsed nav {
  display: flex; flex-direction: column; align-items: center;
  padding-left: 0; padding-right: 0;
}
#sidebar.collapsed .user-section { padding: 0.25rem 0.625rem 0.5rem; }
#sidebar.collapsed .user-card { padding: 0.25rem; justify-content: center; }
#sidebar.collapsed ~ #mainContent { margin-left: 64px; }

/* Loading overlay */
#loadingOverlay { position: fixed; inset: 0; z-index: 9999; background: rgba(248,249,250,0.95); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; backdrop-filter: blur(4px); transition: opacity 0.4s ease; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader { width: 40px; height: 40px; border: 3px solid rgba(139,26,44,0.15); border-top-color: #8B1A2C; border-radius: 50%; animation: spin 0.8s ease-in-out infinite; }

/* CFF Table */
#cffTable { border-collapse: collapse; min-width: max-content; }
#cffTable th, #cffTable td { padding: 6px 10px; font-size: 11px; white-space: nowrap; border: 1px solid rgba(233,236,239,0.5); }
#cffTable th { font-size: 9px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; }
#cffTable td:first-child, #cffTable th:first-child { position: sticky; left: 0; z-index: 3; min-width: 36px; text-align: center; }
#cffTable td:nth-child(2), #cffTable th:nth-child(2) { position: sticky; left: 36px; z-index: 3; min-width: 220px; }
.cff-entity { background: linear-gradient(135deg, #1B6680, #2E7D9B) !important; color: white !important; font-weight: 900 !important; font-size: 12px !important; }
.cff-entity td { background: linear-gradient(135deg, #1B6680, #2E7D9B) !important; color: white !important; border-color: rgba(255,255,255,0.15) !important; }
.cff-net { background: #F0F4F8 !important; font-weight: 900 !important; }
.cff-net td { background: #F0F4F8 !important; font-weight: 900 !important; border-color: rgba(30,41,59,0.1) !important; }
.cff-group { background: #EDF2F7 !important; font-weight: 900 !important; }
.cff-group td { background: #EDF2F7 !important; font-weight: 900 !important; }
.cff-sub td { background: white; }
.cff-sub td:nth-child(2) { padding-left: 24px !important; font-style: italic; color: #495057; }
.cff-negative { color: #C41E3A; }
.cff-positive { color: #099268; }
#cffTableWrapper { max-height: calc(100vh - 240px); }
