/* ========================================================
   aluno-ficha-modal.css — M48.ficha.v3
   Modal central GRANDE pra Ficha Acadêmica 360 do aluno.
   Reusa tokens v2 + segue M50.fix.2 (z-index 9999, max-height vh, scroll interno).
   ========================================================*/

.cf-ficha-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: cf-ficha-fade-in .2s ease;
}

.cf-ficha-modal {
  position: relative;
  background: #fff;
  width: min(1100px, 95vw);
  height: min(820px, 92vh);
  max-height: 92vh;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10000;
  animation: cf-ficha-pop-in .22s cubic-bezier(.16,1,.3,1);
}

@keyframes cf-ficha-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes cf-ficha-pop-in {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* HEADER fixo no topo: hero + ações + tabs */
.cf-ficha-head {
  flex-shrink: 0;
  background: linear-gradient(180deg, #fafbfd, #fff);
  border-bottom: 1px solid #e2e8f0;
  padding: 22px 28px 0 28px;
}

.cf-ficha-close {
  position: absolute;
  top: 14px; right: 16px;
  width: 32px; height: 32px;
  border: none;
  background: rgba(255,255,255,.85);
  border-radius: 8px;
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s;
  z-index: 2;
}
.cf-ficha-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.cf-ficha-hero {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.cf-ficha-avatar {
  width: 64px; height: 64px;
  border-radius: 14px;
  color: #fff;
  font-weight: 700;
  font-size: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'IBM Plex Sans', sans-serif;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.cf-ficha-hero-info {
  flex: 1;
  min-width: 0;
}
.cf-ficha-name {
  font-size: 20px;
  font-weight: 600;
  color: #0f172a;
  margin: 0 0 4px;
  font-family: 'IBM Plex Sans', sans-serif;
  line-height: 1.2;
}
.cf-ficha-name-input {
  font-size: 20px;
  font-weight: 600;
  color: #0f172a;
  border: none;
  background: transparent;
  width: 100%;
  margin: 0 0 4px;
  font-family: 'IBM Plex Sans', sans-serif;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background .15s;
}
.cf-ficha-name-input:hover,
.cf-ficha-name-input:focus {
  background: #f8fafc;
  outline: none;
}

.cf-ficha-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 0;
}
.cf-ficha-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

.cf-ficha-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #64748b;
  margin-top: 8px;
}
.cf-ficha-meta strong {
  color: #0f172a;
}

/* KPIs em linha */
.cf-ficha-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 18px 0 16px;
}
.cf-ficha-kpi {
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px 14px;
}
.cf-ficha-kpi strong {
  display: block;
  font-size: 18px;
  color: #0f172a;
  font-family: 'IBM Plex Sans', sans-serif;
  margin-bottom: 2px;
}
.cf-ficha-kpi small {
  font-size: 11px;
  color: #64748b;
}

/* Ações rápidas (5+ botões coloridos) */
.cf-ficha-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.cf-ficha-act-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s, transform .08s;
}
.cf-ficha-act-btn:hover { filter: brightness(.96); }
.cf-ficha-act-btn:active { transform: scale(.97); }
.cf-ficha-act-btn[disabled] { opacity: .55; cursor: not-allowed; }

/* Tabs */
.cf-ficha-tabs {
  display: flex;
  gap: 4px;
  margin: 8px -28px 0;
  padding: 0 28px;
  border-bottom: 1px solid #e2e8f0;
  overflow-x: auto;
  scrollbar-width: none;
}
.cf-ficha-tabs::-webkit-scrollbar { display: none; }
.cf-ficha-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px 12px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.cf-ficha-tab:hover { color: #0f172a; }
.cf-ficha-tab.is-active {
  color: #1E5BAA;
  border-bottom-color: #1E5BAA;
  font-weight: 600;
}
.cf-ficha-tab-count {
  background: #e2e8f0;
  color: #475569;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
}
.cf-ficha-tab.is-active .cf-ficha-tab-count {
  background: #dbeafe;
  color: #1e40af;
}

/* BODY com scroll interno */
.cf-ficha-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px 28px 28px;
  background: #fafbfd;
}

.cf-ficha-panel { display: none; }
.cf-ficha-panel.is-active { display: block; }

.cf-ficha-section {
  background: #fff;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.cf-ficha-section h4 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  font-family: 'IBM Plex Sans', sans-serif;
}
.cf-ficha-section h4 .cf-ficha-section-hint {
  font-weight: 400;
  font-size: 11px;
  color: #94a3b8;
  margin-left: 6px;
}

.cf-ficha-card {
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.cf-ficha-card:last-child { margin-bottom: 0; }
.cf-ficha-card.is-warn { background: #fff7ed; border-left: 3px solid #ea580c; }
.cf-ficha-card.is-success { background: #f0fdf4; border-left: 3px solid #16a34a; }
.cf-ficha-card.is-info { background: #eff6ff; border-left: 3px solid #2563eb; }
.cf-ficha-card.is-danger { background: #fef2f2; border-left: 3px solid #dc2626; }
.cf-ficha-card.is-muted { background: #f1f5f9; }

.cf-ficha-card .left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.cf-ficha-card .left .label {
  font-size: 12.5px;
  font-weight: 600;
  color: #0f172a;
}
.cf-ficha-card .left .sub {
  display: block;
  font-size: 11.5px;
  color: #64748b;
  margin-top: 2px;
}

.cf-ficha-empty {
  text-align: center;
  padding: 24px 12px;
  color: #94a3b8;
  font-size: 12px;
}
.cf-ficha-empty i {
  display: block;
  margin: 0 auto 8px;
}

/* Form de Dados (aba acadêmico/comercial — campos editáveis) */
.cf-ficha-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}
.cf-ficha-field label {
  display: block;
  font-size: 11px;
  color: #64748b;
  font-weight: 500;
  margin-bottom: 3px;
}
.cf-ficha-field input,
.cf-ficha-field textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 12.5px;
  color: #0f172a;
  background: #fff;
}
.cf-ficha-field input:focus,
.cf-ficha-field textarea:focus {
  outline: none;
  border-color: #1E5BAA;
  box-shadow: 0 0 0 3px rgba(30,91,170,.08);
}

/* Timeline */
.cf-ficha-tl {
  position: relative;
  padding-left: 24px;
}
.cf-ficha-tl::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: #e2e8f0;
}
.cf-ficha-tl-item {
  position: relative;
  margin-bottom: 14px;
}
.cf-ficha-tl-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #94a3b8;
}
.cf-ficha-tl-item.is-success::before { border-color: #16a34a; }
.cf-ficha-tl-item.is-warn::before { border-color: #ea580c; }
.cf-ficha-tl-item.is-info::before { border-color: #2563eb; }
.cf-ficha-tl-item.is-danger::before { border-color: #dc2626; }
.cf-ficha-tl-item .tl-head {
  font-size: 12px;
  color: #0f172a;
  font-weight: 600;
  margin-bottom: 2px;
}
.cf-ficha-tl-item .tl-sub {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 2px;
}
.cf-ficha-tl-item .tl-desc {
  font-size: 12px;
  color: #475569;
  margin-top: 4px;
  line-height: 1.45;
}
.cf-ficha-tl-item details {
  margin-top: 4px;
}
.cf-ficha-tl-item details summary {
  font-size: 11px;
  color: #94a3b8;
  cursor: pointer;
}
.cf-ficha-tl-item details pre {
  font-size: 10.5px;
  background: #f8fafc;
  padding: 8px;
  border-radius: 6px;
  margin-top: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #475569;
  font-family: 'IBM Plex Mono', monospace;
}

/* Footer fixo */
.cf-ficha-foot {
  flex-shrink: 0;
  border-top: 1px solid #e2e8f0;
  padding: 12px 28px;
  background: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.cf-ficha-saved-msg {
  font-size: 11px;
  color: #10b981;
  opacity: 0;
  transition: opacity .25s;
}
.cf-ficha-saved-msg.is-visible { opacity: 1; }

/* Estado: acesso negado pós-RLS */
.cf-ficha-denied {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
}
.cf-ficha-denied i {
  width: 48px;
  height: 48px;
  color: #cbd5e1;
  margin-bottom: 14px;
}
.cf-ficha-denied strong {
  display: block;
  font-size: 16px;
  color: #0f172a;
  margin-bottom: 6px;
}
.cf-ficha-denied small {
  display: block;
  color: #64748b;
  max-width: 380px;
  line-height: 1.5;
  font-size: 12.5px;
}

/* Responsivo: telas pequenas */
@media (max-width: 720px) {
  .cf-ficha-modal { width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
  .cf-ficha-kpis { grid-template-columns: repeat(2, 1fr); }
  .cf-ficha-fields { grid-template-columns: 1fr; }
}
