/* ═══════════════════════════════════════════
   Kiara MFI - Collection Portal Styles
   Professional Blue & White Theme
═══════════════════════════════════════════ */

:root {
  --primary: #1a4fa0;
  --primary-dark: #123a7a;
  --primary-light: #e8effc;
  --sidebar-width: 240px;
  --sidebar-bg: #0f2d5e;
  --sidebar-text: rgba(255,255,255,0.85);
  --sidebar-hover: rgba(255,255,255,0.1);
  --sidebar-active: rgba(255,255,255,0.15);
  --topbar-height: 56px;
  --body-bg: #f4f6fb;
}

* { box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--body-bg); margin: 0; font-size: 14px; }

/* ── LOGIN ─────────────────────────────────── */
.login-page { background: linear-gradient(135deg, #0f2d5e 0%, #1a4fa0 60%, #2563eb 100%); }
.login-card  { width: 100%; max-width: 420px; border: none; border-radius: 16px; }
.logo-icon   { width: 64px; height: 64px; background: var(--primary-light); border-radius: 50%;
               display: inline-flex; align-items: center; justify-content: center;
               font-size: 28px; color: var(--primary); }

/* ── SIDEBAR ───────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform 0.3s ease;
  overflow: hidden;
}
.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
}
.sidebar-logo { display: flex; align-items: center; color: #fff; font-size: 15px; font-weight: 700; }
.sidebar-logo i { font-size: 20px; color: #60a5fa; }
.sidebar-title { white-space: nowrap; overflow: hidden; }
.sidebar-close { color: rgba(255,255,255,0.7) !important; padding: 4px; }
.sidebar-user {
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px; flex-shrink: 0;
}
.sidebar-user .fw-semibold { color: #fff; font-size: 13px; line-height: 1.3; }
.badge-role {
  font-size: 10px; padding: 2px 8px; border-radius: 20px;
  background: rgba(96,165,250,0.25); color: #93c5fd;
  text-transform: uppercase; letter-spacing: 0.5px;
  display: inline-block; margin-top: 2px;
}
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-nav .nav-link,
.sidebar-footer .nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text) !important;
  text-decoration: none;
  border-radius: 0;
  transition: all 0.2s;
  cursor: pointer;
  font-size: 13.5px;
  white-space: nowrap;
}
.sidebar-nav .nav-link i,
.sidebar-footer .nav-link i { width: 18px; text-align: center; font-size: 14px; flex-shrink: 0; }
.sidebar-nav .nav-link:hover,
.sidebar-footer .nav-link:hover { background: var(--sidebar-hover); color: #fff !important; }
.sidebar-nav .nav-link.active { background: var(--sidebar-active); color: #fff !important;
  border-left: 3px solid #60a5fa; }
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 8px 0;
}
.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1039;
}

/* ── MAIN CONTENT ─────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.top-navbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex; align-items: center;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 100;
  gap: 12px;
}
.navbar-brand-sm { font-size: 15px; }
.page-content { padding: 20px; flex: 1; }

/* ── PAGE SECTIONS ─────────────────────────── */
.page-section { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.page-title { margin: 0; font-size: 17px; font-weight: 700; color: #1e293b; }

/* ── KPI CARDS ─────────────────────────────── */
.kpi-card {
  border-radius: 12px; padding: 16px 20px;
  cursor: default; transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.15); }
.kpi-icon { font-size: 22px; opacity: 0.8; margin-bottom: 6px; }
.kpi-value { font-size: 20px; font-weight: 700; line-height: 1.2; }
.kpi-label { font-size: 11px; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

/* ── BUCKET TILES ──────────────────────────── */
.bucket-tile {
  border-radius: 12px; padding: 16px 14px;
  text-align: center; cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 2px solid transparent;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.bucket-tile:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.15); }
.bucket-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.75; }
.bucket-count { font-size: 28px; font-weight: 800; margin: 4px 0; }
.bucket-amount { font-size: 12px; font-weight: 600; }
.bucket-sub { font-size: 10px; opacity: 0.65; margin-top: 4px; }
.bucket-regular { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.bucket-sma0    { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.bucket-sma1    { background: #fff7ed; color: #9a3412; border-color: #fdba74; }
.bucket-sma2    { background: #fff1f2; color: #9f1239; border-color: #fecdd3; }
.bucket-npa     { background: #fff1f2; color: #7f1d1d; border-color: #fca5a5; }

/* ── TABLES ────────────────────────────────── */
.sticky-header th { position: sticky; top: 0; z-index: 2; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { background: rgba(0,0,0,0.05); }
.table-toolbar { background: #f8f9fa; }

/* ── ASSET CLASS BADGES ────────────────────── */
.badge-regular { background: #d1fae5; color: #065f46; }
.badge-sma     { background: #fef3c7; color: #92400e; }
.badge-npa     { background: #fee2e2; color: #991b1b; }

/* ── DETAIL LABELS ─────────────────────────── */
.detail-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: #94a3b8; font-weight: 600; margin-bottom: 2px; }
.detail-value { font-size: 13px; font-weight: 500; color: #1e293b; }

/* ── SEARCH DROPDOWN ───────────────────────── */
.search-dropdown {
  position: absolute; width: 100%; background: #fff;
  border: 1px solid #dee2e6; border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  max-height: 320px; overflow-y: auto;
  z-index: 200;
}
.search-item {
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s;
}
.search-item:hover { background: #f0f7ff; }
.search-item:last-child { border-bottom: none; }
.search-item-name { font-weight: 600; font-size: 13px; color: #1e293b; }
.search-item-sub  { font-size: 11px; color: #64748b; }
.search-item-sched { font-size: 11px; margin-top: 2px; padding-top: 2px; border-top: 1px dashed #dbeafe; }

/* ── Demand tiles ──────────────────────────── */
.demand-tile {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  min-width: 0;
}
.demand-tile:hover { box-shadow: 0 2px 8px rgba(0,0,0,.12); border-color: #93c5fd; }
.demand-tile-name  { font-size: 11px; color: #64748b; font-weight: 600; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.demand-tile-amount { font-size: 15px; font-weight: 700; color: #1a4fa0; }
.demand-tile-sub   { font-size: 10px; color: #94a3b8; margin-top: 1px; }
.sortable-col      { cursor: pointer; user-select: none; }
.sortable-col:hover { background: rgba(255,255,255,.1); }

/* ── FORM WRAPPER for search relative ──── */
#collSearchInput { position: relative; }
.card-body { position: relative; }

/* ── RESPONSIVE ────────────────────────────── */
@media (max-width: 767.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-content { padding: 12px; }
  .kpi-value { font-size: 17px; }
  .bucket-count { font-size: 22px; }
  .bucket-tile { padding: 12px 8px; }
  .table th, .table td { font-size: 12px; padding: 6px 8px; }
}

@media (min-width: 768px) {
  .sidebar-close { display: none !important; }
  .sidebar-overlay { display: none !important; }
}

/* ── UTILITIES ─────────────────────────────── */
.currency::before { content: '₹'; font-size: 0.8em; }
.text-od-ok   { color: #16a34a !important; }
.text-od-warn { color: #d97706 !important; }
.text-od-bad  { color: #dc2626 !important; }
.clickable { cursor: pointer; }
.clickable:hover { text-decoration: underline; }

/* card tweaks */
.card { border: 1px solid #e5e7eb; border-radius: 10px; }
.card-header { border-radius: 10px 10px 0 0 !important; border-bottom: 1px solid #e5e7eb; padding: 12px 16px; }

/* Toast */
#appToast.success { background: #16a34a; color: #fff; }
#appToast.error   { background: #dc2626; color: #fff; }
#appToast.info    { background: var(--primary); color: #fff; }

/* ── FILTER ROW ────────────────────────────────── */
.filter-row th, .filter-row td { background: #1e2a3a !important; padding: 4px 6px !important; }
.filter-row input, .filter-row select {
  background: rgba(255,255,255,0.1) !important;
  border: 1px solid rgba(255,255,255,0.2) !important;
  color: #fff !important;
  font-size: 11px !important;
}
.filter-row input::placeholder { color: rgba(255,255,255,0.5) !important; }
.filter-row select option { background: #1e2a3a; color: #fff; }

/* ── SORT ICONS ─────────────────────────────────── */
.sort-icon::after { content: ' ⇅'; opacity: 0.4; font-size: 11px; }
.sort-icon.asc::after  { content: ' ↑'; opacity: 1; color: #60a5fa; }
.sort-icon.desc::after { content: ' ↓'; opacity: 1; color: #60a5fa; }

/* ── KPI Clickable style ─────────────────────────── */
.kpi-card.clickable { cursor: pointer; }
.kpi-card.clickable:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.25); }

/* scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
