/**
 * Nanban Student Profile — world-class CRM drawer
 */

#profileModal.modal-overlay {
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: max(10px, env(safe-area-inset-top)) 10px 20px;
  background: rgba(28, 25, 23, 0.45) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.22s ease;
}

#profileModal.modal-overlay.nb-modal-visible {
  opacity: 1;
}

#profileModal .modal-content {
  width: min(96vw, 720px);
  max-height: min(94vh, 900px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #f3f0eb !important;
  border: 1px solid rgba(28, 25, 23, 0.1) !important;
  border-radius: 22px !important;
  box-shadow: 0 32px 88px rgba(28, 25, 23, 0.2) !important;
  transform: translateY(24px) scale(0.98);
  opacity: 0;
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease;
}

#profileModal.nb-modal-visible .modal-content {
  transform: translateY(0) scale(1);
  opacity: 1;
}

#profileModal .nb-prof-scroll {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  padding: 20px 20px 24px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Header ── */
#profileModal .nb-prof-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 18px 16px;
  margin: -20px -20px 0;
  background: #ffffff;
  border-bottom: 1px solid rgba(28, 25, 23, 0.08);
  border-radius: 22px 22px 0 0;
  position: sticky;
  top: -20px;
  z-index: 2;
}

#profileModal #profName {
  font-family: "Plus Jakarta Sans", "Noto Sans Tamil", sans-serif !important;
  font-size: clamp(1.25rem, 3.5vw, 1.5rem) !important;
  font-weight: 800 !important;
  color: #0c0a09 !important;
  letter-spacing: -0.03em !important;
  margin: 0 !important;
  line-height: 1.2 !important;
}

#profileModal .nb-prof-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  color: #57534e !important;
  font-weight: 600 !important;
  font-size: 0.8125rem !important;
  margin-top: 6px !important;
}

#profileModal .nb-prof-meta a {
  color: #57534e !important;
  text-decoration: none !important;
}

#profileModal .nb-prof-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

#profileModal .nb-prof-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: #f5f5f4;
  color: #57534e;
  border: 1px solid rgba(28, 25, 23, 0.08);
}

#profileModal .nb-prof-chip--marks {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

#profileModal .nb-prof-chip--status {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

#profileModal .nb-prof-header__actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

#profileModal .nb-prof-icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(28, 25, 23, 0.1);
  border-radius: 12px;
  background: #ffffff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.15s ease;
}

#profileModal .nb-prof-icon-btn:hover {
  background: #fafaf9;
  transform: scale(1.04);
}

#profileModal .nb-prof-icon-btn--close {
  font-size: 1.35rem;
  font-weight: 400;
  color: #78716c;
}

/* ── Cards ── */
#profileModal .nb-prof-card {
  background: #ffffff;
  border: 1px solid rgba(28, 25, 23, 0.08);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: 0 2px 12px rgba(28, 25, 23, 0.04);
}

#profileModal .nb-prof-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

#profileModal .nb-prof-card h3 {
  margin: 0 0 12px !important;
  font-size: 0.9375rem !important;
  font-weight: 800 !important;
  color: #0c0a09 !important;
  letter-spacing: -0.02em !important;
}

#profileModal .nb-prof-card__head h3 {
  margin: 0 !important;
}

#profileModal .nb-prof-hint {
  font-size: 0.75rem;
  color: #78716c;
  margin: -6px 0 12px;
  line-height: 1.45;
}

#profileModal .nb-prof-badge {
  font-size: 0.6875rem;
  font-weight: 800;
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

#profileModal .nb-prof-badge--paid {
  background: #dc2626;
  color: #ffffff;
}

#profileModal .nb-prof-link-btn {
  border: none;
  background: transparent;
  font-size: 0.75rem;
  font-weight: 700;
  color: #78716c;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}

#profileModal .nb-prof-link-btn:hover {
  background: #f5f5f4;
  color: #0c0a09;
}

/* ── Finance ── */
#profileModal .nb-prof-finance-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

#profileModal .nb-prof-stat {
  text-align: center;
  padding: 10px 6px;
  border-radius: 12px;
  background: #fafaf9;
  border: 1px solid rgba(28, 25, 23, 0.06);
}

#profileModal .nb-prof-stat span {
  display: block;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #78716c;
  margin-bottom: 4px;
}

#profileModal .nb-prof-stat strong {
  font-size: 0.9375rem;
  font-weight: 800;
  color: #0c0a09;
}

#profileModal .nb-prof-stat--danger {
  background: #fef2f2;
  border-color: #fecaca;
}

#profileModal .nb-prof-stat--danger strong {
  color: #dc2626;
}

#profileModal .nb-prof-balance {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, #fef2f2 0%, #fff1f2 100%);
  border: 1px solid #fecaca;
}

#profileModal .nb-prof-balance span {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #991b1b;
}

#profileModal .nb-prof-balance strong {
  font-size: 1.25rem;
  font-weight: 900;
  color: #dc2626;
  letter-spacing: -0.02em;
}

/* ── Journey ── */
#profileModal #profRtoTrackerBody {
  font-size: 0.8125rem;
  line-height: 1.45;
  margin-bottom: 14px;
}

#profileModal .nb-prof-llr-block label,
#profileModal .nb-prof-card label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #57534e;
  margin-bottom: 6px;
}

#profileModal .nb-prof-llr-pipeline {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(28, 25, 23, 0.1);
}

#profileModal .nb-prof-llr-pipeline select,
#profileModal .nb-prof-llr-pipeline input {
  width: 100%;
  margin-bottom: 10px;
  box-sizing: border-box;
}

#profileModal .nb-prof-test-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed rgba(28, 25, 23, 0.1);
}

#profileModal #profTestResultBox {
  display: none;
  gap: 8px;
  margin-top: 10px;
}

#profileModal #profTestResultBox[style*="flex"] {
  display: flex !important;
}

#profileModal .nb-prof-retest {
  margin-top: 14px;
  padding: 14px;
  border-radius: 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
}

#profileModal .nb-prof-retest h4 {
  margin: 0 0 10px !important;
  color: #b45309 !important;
  font-size: 0.875rem !important;
}

/* ── Checklist ── */
#profileModal .nb-prof-progress {
  height: 6px;
  background: #e7e5e4;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}

#profileModal #rtoChkProgressBar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #10b981, #22c55e);
  transition: width 0.35s ease;
  border-radius: 999px;
}

#profileModal #profRtoChecklistMount {
  max-height: min(40vh, 320px);
  overflow-y: auto;
  padding-right: 4px;
}

#profileModal #profRtoChecklistMount label {
  display: flex !important;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 8px !important;
  border-bottom: 1px solid #f5f5f4 !important;
  border-radius: 8px !important;
  margin-bottom: 2px !important;
  cursor: pointer;
  font-weight: 600 !important;
  font-size: 0.8125rem !important;
}

/* ── WhatsApp grid ── */
#profileModal .nb-prof-comms-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

#profileModal .nb-prof-comms-grid .btn {
  min-height: 48px !important;
  padding: 10px 12px !important;
  font-size: 0.75rem !important;
  font-weight: 700 !important;
  border-radius: 12px !important;
  text-align: left !important;
  justify-content: flex-start !important;
  color: #0c0a09 !important;
  background: #fafaf9 !important;
  border: 1px solid rgba(28, 25, 23, 0.1) !important;
}

#profileModal .nb-prof-comms-grid .btn:hover:not(:disabled) {
  background: #f5f5f4 !important;
  border-color: rgba(28, 25, 23, 0.14) !important;
}

#profileModal .nb-prof-comms-grid .btn:disabled {
  opacity: 0.45;
}

#profileModal .nb-prof-comms-grid .nb-prof-comms-enq {
  background: #fffbeb !important;
  border-color: #fde68a !important;
  color: #92400e !important;
}

/* ── Training tags ── */
#profileModal .nb-prof-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

#profileModal .nb-prof-tags .tag {
  font-size: 0.6875rem !important;
  padding: 6px 10px !important;
  border-radius: 999px !important;
}

#profileModal .nb-prof-quiz-hints {
  font-size: 0.75rem;
  line-height: 1.45;
}

/* ── History ── */
#profileModal .nb-prof-history-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

#profileModal .nb-prof-history-grid h4 {
  margin: 0 0 8px !important;
  font-size: 0.6875rem !important;
  font-weight: 800 !important;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #78716c !important;
}

#profileModal #profHistoryList,
#profileModal #profPayList {
  max-height: 100px;
  overflow-y: auto;
  padding: 10px;
  border-radius: 10px;
  background: #fafaf9;
  border: 1px solid rgba(28, 25, 23, 0.06);
  font-size: 0.75rem;
  font-weight: 600;
  color: #57534e;
}

/* ── Remarks ── */
#profileModal .nb-prof-remark-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

#profileModal .nb-prof-remark-row input {
  flex: 1;
  margin: 0 !important;
}

#profileModal .nb-prof-remark-row .btn {
  flex-shrink: 0;
  padding: 10px 16px !important;
}

#profileModal .nb-prof-remarks {
  max-height: 88px;
  overflow-y: auto;
  padding: 10px;
  border-radius: 10px;
  background: #fafaf9;
  border: 1px solid rgba(28, 25, 23, 0.06);
  font-size: 0.75rem;
}

/* ── Actions footer ── */
#profileModal .nb-prof-card--actions {
  background: #ffffff;
  border: 2px solid rgba(220, 38, 38, 0.12);
  margin-bottom: 4px;
}

#profileModal .nb-prof-pay-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.8fr;
  gap: 8px;
  margin-bottom: 12px;
}

#profileModal .nb-prof-pay-row input {
  font-size: 1.125rem !important;
  font-weight: 800 !important;
  color: #15803d !important;
  background: #f0fdf4 !important;
  border-color: #86efac !important;
  margin: 0 !important;
}

#profileModal .nb-prof-pay-row select {
  margin: 0 !important;
}

#profileModal .nb-prof-action-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#profileModal .nb-prof-action-btns .btn-nanban {
  flex: 2;
  min-width: 140px;
}

#profileModal .nb-prof-action-btns .btn-danger-outline {
  flex: 0 0 auto;
  background: #fef2f2 !important;
  color: #dc2626 !important;
  border: 1px solid #fecaca !important;
}

#profileModal input,
#profileModal select,
#profileModal textarea {
  min-height: 42px;
  font-size: 0.875rem !important;
  border-radius: 10px !important;
  border: 1px solid rgba(28, 25, 23, 0.12) !important;
  background: #ffffff !important;
  color: #0c0a09 !important;
  width: 100%;
  box-sizing: border-box;
}

#profileModal .nb-prof-defer {
  content-visibility: auto;
  contain-intrinsic-size: 200px;
}

#profileModal.nb-prof-loading .nb-prof-defer {
  opacity: 0.5;
  pointer-events: none;
}

#profileModal .nb-prof-skeleton {
  display: none;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #e7e5e4 25%, #d6d3d1 50%, #e7e5e4 75%);
  background-size: 200% 100%;
  animation: nbProfSkel 1s ease-in-out infinite;
}

#profileModal.nb-prof-loading .nb-prof-skeleton {
  display: block;
}

@keyframes nbProfSkel {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (max-width: 560px) {
  #profileModal .nb-prof-finance-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  #profileModal .nb-prof-comms-grid {
    grid-template-columns: 1fr;
  }

  #profileModal .nb-prof-history-grid {
    grid-template-columns: 1fr;
  }

  #profileModal .nb-prof-pay-row {
    grid-template-columns: 1fr;
  }

  #profileModal .nb-prof-action-btns .btn {
    width: 100%;
    flex: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  #profileModal.modal-overlay,
  #profileModal .modal-content {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}
