/* ============================================================
   EduFlow CRM & Moliya (Director Finance Dashboard)
   Theme: Obsidian (#0b0f19), Glassmorphism, Neon Cyan & Violet
   ============================================================ */

:root {
  --crm-bg: #0b0f19;
  --crm-card-bg: rgba(17, 24, 39, 0.72);
  --crm-card-border: rgba(255, 255, 255, 0.08);
  --crm-card-hover-border: rgba(6, 182, 212, 0.4);
  --crm-cyan: #06b6d4;
  --crm-cyan-glow: rgba(6, 182, 212, 0.25);
  --crm-violet: #8b5cf6;
  --crm-violet-glow: rgba(139, 92, 246, 0.25);
  --crm-emerald: #10b981;
  --crm-rose: #f43f5e;
  --crm-amber: #f59e0b;
  --crm-text-main: #f8fafc;
  --crm-text-muted: #94a3b8;
}

/* ==================== DIRECTOR LAYOUT ==================== */
.director-layout {
  display: flex;
  min-height: calc(100vh - 73px);
  background: var(--crm-bg, #0b0f19);
  margin: 0 calc(var(--space-lg, 24px) * -1);
  width: calc(100% + (var(--space-lg, 24px) * 2));
}

.director-sidebar {
  width: 270px;
  background: #0f172a;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.director-sidebar-brand {
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.director-nav {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.director-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  color: #94a3b8;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
}

.director-nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.director-nav-item.active {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.18), rgba(139, 92, 246, 0.18));
  border-color: rgba(6, 182, 212, 0.4);
  color: #38bdf8;
  box-shadow: 0 2px 10px rgba(6, 182, 212, 0.2);
}

.director-nav-item i {
  width: 17px;
  height: 17px;
}

.director-content {
  flex: 1;
  padding: 24px 32px;
  background: #0b0f19;
  min-width: 0;
  overflow-y: auto;
}

.director-tab-content {
  display: none;
}

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

@media (max-width: 900px) {
  .director-layout {
    flex-direction: column !important;
    width: 100% !important;
    margin: 0 !important;
  }
  .director-sidebar {
    width: 100% !important;
    border-right: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  }
  .director-nav {
    flex-direction: row;
    overflow-x: auto;
    white-space: nowrap;
    padding: 10px;
  }
  .director-content {
    padding: 16px;
  }
}

/* Container */
.crm-finance-container {
  padding: 24px 0 60px 0;
  color: var(--crm-text-main);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Glassmorphism Surface */
.crm-glass-panel {
  background: var(--crm-card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--crm-card-border);
  border-radius: 20px;
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.4);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.crm-glass-panel:hover {
  border-color: var(--crm-card-hover-border);
}

/* Header Banner */
.crm-header-banner {
  padding: 28px 32px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(11, 15, 25, 0.95), rgba(17, 24, 39, 0.88));
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.crm-header-banner::before {
  content: '';
  position: absolute;
  top: -80px;
  right: -80px;
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.18), transparent 70%);
  pointer-events: none;
}

.crm-header-banner::after {
  content: '';
  position: absolute;
  bottom: -60px;
  left: 30%;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.15), transparent 70%);
  pointer-events: none;
}

.crm-header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  position: relative;
  z-index: 2;
}

.crm-badge-top {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--crm-cyan);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.crm-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 30%, #38bdf8 70%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.crm-subtitle {
  margin: 6px 0 0 0;
  color: var(--crm-text-muted);
  font-size: 0.92rem;
}

.crm-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-crm-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  text-decoration: none;
}

.btn-crm-cyan {
  background: linear-gradient(135deg, #0284c7, #06b6d4);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(6, 182, 212, 0.35);
}

.btn-crm-cyan:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.45);
}

.btn-crm-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--crm-text-main);
  border: 1px solid var(--crm-card-border);
}

.btn-crm-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ==================== 1. KPI WIDGETS ==================== */
.crm-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.crm-kpi-card {
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.crm-kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--kpi-accent, var(--crm-cyan));
  opacity: 0.85;
}

.crm-kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.crm-kpi-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--crm-text-muted);
}

.crm-kpi-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--kpi-icon-bg, rgba(6, 182, 212, 0.15));
  color: var(--kpi-accent, var(--crm-cyan));
}

.crm-kpi-icon-box i {
  width: 20px;
  height: 20px;
}

.crm-kpi-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--crm-text-main);
  line-height: 1.15;
  margin-bottom: 6px;
}

.crm-kpi-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  align-self: flex-start;
}

.crm-kpi-badge.emerald {
  background: rgba(16, 185, 129, 0.15);
  color: var(--crm-emerald);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.crm-kpi-badge.rose {
  background: rgba(244, 63, 94, 0.15);
  color: var(--crm-rose);
  border: 1px solid rgba(244, 63, 94, 0.35);
}

.crm-kpi-badge.cyan {
  background: rgba(6, 182, 212, 0.15);
  color: var(--crm-cyan);
  border: 1px solid rgba(6, 182, 212, 0.35);
}

.crm-kpi-badge.violet {
  background: rgba(139, 92, 246, 0.15);
  color: var(--crm-violet);
  border: 1px solid rgba(139, 92, 246, 0.35);
}

/* ==================== 2. CONTROLS & FILTER BAR ==================== */
.crm-controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 16px 20px;
  margin-bottom: 24px;
}

.crm-search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--crm-card-border);
  padding: 10px 16px;
  border-radius: 12px;
  flex: 1;
  min-width: 240px;
  max-width: 420px;
  transition: all 0.2s;
}

.crm-search-box:focus-within {
  border-color: var(--crm-cyan);
  box-shadow: 0 0 14px rgba(6, 182, 212, 0.25);
}

.crm-search-box i {
  width: 17px;
  height: 17px;
  color: var(--crm-text-muted);
}

.crm-search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-size: 0.88rem;
  width: 100%;
}

.crm-filter-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.crm-pill-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--crm-card-border);
  color: var(--crm-text-muted);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.crm-pill-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.crm-pill-btn.active {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(139, 92, 246, 0.2));
  border-color: var(--crm-cyan);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(6, 182, 212, 0.2);
}

/* ==================== 3. 12 SUBJECTS GRID ==================== */
.crm-subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
}

.crm-subject-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px;
  position: relative;
  overflow: hidden;
}

.crm-subject-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--subject-gradient, linear-gradient(90deg, var(--crm-cyan), var(--crm-violet)));
  opacity: 0.85;
}

/* Subject Card Header */
.crm-subj-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.crm-subj-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.crm-subj-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--subj-bg, rgba(6, 182, 212, 0.12));
  border: 1px solid var(--subj-border, rgba(6, 182, 212, 0.25));
  color: var(--subj-color, var(--crm-cyan));
  flex-shrink: 0;
}

.crm-subj-icon-wrap i {
  width: 22px;
  height: 22px;
}

.crm-subj-title-group {
  min-width: 0;
}

.crm-subj-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-subj-subtitle {
  font-size: 0.76rem;
  color: var(--crm-text-muted);
  font-weight: 600;
}

.crm-subj-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.crm-pill-count {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--crm-card-border);
  color: var(--crm-text-muted);
}

/* ==================== 4. GROUPS LIST INSIDE CARD ==================== */
.crm-groups-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.crm-group-item {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.crm-group-item:hover {
  background: rgba(6, 182, 212, 0.06);
  border-color: rgba(6, 182, 212, 0.35);
  transform: translateY(-1px);
}

.crm-group-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.crm-group-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.crm-group-name i {
  width: 14px;
  height: 14px;
  color: var(--crm-cyan);
}

.crm-group-status-pills {
  display: flex;
  align-items: center;
  gap: 6px;
}

.crm-badge-paid {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--crm-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.crm-badge-debt {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(244, 63, 94, 0.15);
  color: var(--crm-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Progress bar */
.crm-progress-wrap {
  margin-bottom: 8px;
}

.crm-progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.crm-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--crm-cyan), var(--crm-emerald));
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.crm-progress-fill.warn {
  background: linear-gradient(90deg, var(--crm-amber), var(--crm-rose));
}

.crm-group-row-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.76rem;
  color: var(--crm-text-muted);
}

.crm-group-collected {
  font-weight: 700;
  color: var(--crm-emerald);
}

.crm-group-total {
  opacity: 0.8;
}

/* ==================== 5. SUBJECT SUMMARY FOOTER ==================== */
.crm-subj-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 14px;
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.crm-subj-stat-block {
  display: flex;
  flex-direction: column;
}

.crm-subj-stat-lbl {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--crm-text-muted);
  letter-spacing: 0.4px;
}

.crm-subj-stat-val {
  font-size: 1.05rem;
  font-weight: 800;
  color: #ffffff;
}

.crm-subj-stat-val.green {
  color: var(--crm-emerald);
}

.crm-subj-stat-val.red {
  color: var(--crm-rose);
}

/* ==================== 6. MODAL / SLIDE-OVER (Guruh Tafsiloti) ==================== */
.crm-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.crm-modal-backdrop.open {
  display: flex;
  opacity: 1;
}

.crm-modal-panel {
  width: min(850px, 96vw);
  max-height: 90vh;
  background: #0f172a;
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(6, 182, 212, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.25s ease;
}

.crm-modal-backdrop.open .crm-modal-panel {
  transform: translateY(0);
}

.crm-modal-header {
  padding: 22px 26px;
  border-bottom: 1px solid var(--crm-card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.95);
}

.crm-modal-title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.crm-modal-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--crm-card-border);
  color: var(--crm-text-muted);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.crm-modal-close-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.crm-modal-body {
  padding: 24px 26px;
  overflow-y: auto;
  flex: 1;
}

/* Modal Group Quick Stats */
.crm-modal-quick-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.crm-modal-stat-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--crm-card-border);
  border-radius: 12px;
  padding: 12px 14px;
}

.crm-modal-stat-box .lbl {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--crm-text-muted);
  font-weight: 700;
}

.crm-modal-stat-box .val {
  font-size: 1.2rem;
  font-weight: 800;
  color: #ffffff;
  margin-top: 2px;
}

/* Modal Table */
.crm-students-table-wrap {
  border: 1px solid var(--crm-card-border);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
}

.crm-students-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.crm-students-table th {
  background: rgba(255, 255, 255, 0.04);
  padding: 12px 14px;
  font-weight: 700;
  color: var(--crm-text-muted);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--crm-card-border);
}

.crm-students-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--crm-text-main);
  vertical-align: middle;
}

.crm-students-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.crm-student-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(139, 92, 246, 0.2));
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: var(--crm-cyan);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.82rem;
  margin-right: 10px;
}

.btn-send-reminder {
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: var(--crm-rose);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
}

.btn-send-reminder:hover {
  background: var(--crm-rose);
  color: #ffffff;
}

.btn-mark-paid {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: var(--crm-emerald);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 6px;
  transition: all 0.15s;
}

.btn-mark-paid:hover {
  background: var(--crm-emerald);
  color: #ffffff;
}

/* Toast */
.crm-toast-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  border: 1px solid var(--crm-cyan);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(6, 182, 212, 0.3);
  padding: 14px 20px;
  border-radius: 12px;
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.crm-toast-notification.show {
  transform: translateY(0);
  opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .crm-header-banner {
    padding: 20px;
  }
  .crm-title {
    font-size: 1.4rem;
  }
  .crm-kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
  .crm-subjects-grid {
    grid-template-columns: 1fr;
  }
  .crm-controls-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .crm-search-box {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .crm-kpi-grid {
    grid-template-columns: 1fr;
  }
}
