/* ============================================================
   Gestor de Formações — Design System Premium Dark Mode
   Paleta: #0f172a | #1e293b | #3b82f6 | #10b981
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:     #0f172a;
  --bg-card:     #1e293b;
  --bg-card2:    #243447;
  --bg-input:    #0f172a;
  --border:      #334155;
  --border-light:#475569;
  --text-primary:#f1f5f9;
  --text-muted:  #94a3b8;
  --text-dim:    #64748b;
  --accent:      #3b82f6;
  --accent-hover:#2563eb;
  --accent-glow: rgba(59,130,246,0.25);
  --success:     #10b981;
  --success-bg:  rgba(16,185,129,0.12);
  --warning:     #f59e0b;
  --warning-bg:  rgba(245,158,11,0.12);
  --danger:      #ef4444;
  --danger-bg:   rgba(239,68,68,0.12);
  --info:        #06b6d4;
  --info-bg:     rgba(6,182,212,0.12);
  --purple:      #8b5cf6;
  --radius:      12px;
  --radius-sm:   8px;
  --radius-lg:   16px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:   0 8px 40px rgba(0,0,0,0.5);
  --transition:  0.2s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 15px;
}

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.brand-sub { font-size: 11px; color: var(--text-muted); font-weight: 400; }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 24px;
}
.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
  position: relative;
}
.nav-item i { width: 18px; text-align: center; font-size: 15px; }
.nav-item:hover { background: var(--bg-card2); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  border-left: 3px solid var(--accent);
  padding-left: 9px;
}
.nav-item.active i { color: var(--accent); }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-card2);
}
.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.user-role { font-size: 11px; color: var(--text-muted); }

/* ── Main Content ── */
.main {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 64px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}
.topbar-sub { font-size: 13px; color: var(--text-muted); }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.content { padding: 28px 24px; flex: 1; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-glass {
  background: rgba(30,41,59,0.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.07);
}
.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-body { padding: 20px; }

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon.blue  { background: rgba(59,130,246,0.15); color: var(--accent); }
.stat-icon.green { background: rgba(16,185,129,0.15); color: var(--success); }
.stat-icon.amber { background: rgba(245,158,11,0.15); color: var(--warning); }
.stat-icon.purple{ background: rgba(139,92,246,0.15); color: var(--purple); }
.stat-icon.red   { background: rgba(239,68,68,0.15);  color: var(--danger); }
.stat-icon.cyan  { background: rgba(6,182,212,0.15);  color: var(--info); }

.stat-value { font-size: 28px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Formação Cards (Dashboard) ── */
.formacoes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.formacao-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  cursor: pointer;
  text-decoration: none;
  display: block;
}
.formacao-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}

.formacao-capa {
  height: 140px;
  background: linear-gradient(135deg, #1d4ed8 0%, #0ea5e9 50%, #059669 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.formacao-capa img {
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0.8;
}
.formacao-capa-icon {
  font-size: 48px;
  opacity: 0.9;
}
.formacao-badge-obrig {
  position: absolute;
  top: 12px; right: 12px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
}

.formacao-body { padding: 16px; }
.formacao-cat {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 6px;
}
.formacao-titulo {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.3;
}
.formacao-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.formacao-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.formacao-meta i { color: var(--text-muted); }

.progress-bar-wrap {
  background: var(--bg-base);
  border-radius: 20px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 20px;
  transition: width 0.6s ease;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
}

/* ── Vídeo List ── */
.video-list { display: flex; flex-direction: column; gap: 10px; }

.video-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-primary);
  transition: all var(--transition);
}
.video-item:hover {
  border-color: var(--accent);
  background: var(--bg-card2);
  transform: translateX(4px);
}
.video-item.concluido { border-color: rgba(16,185,129,0.4); }

.video-num {
  width: 32px; height: 32px;
  background: var(--bg-base);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}
.video-item.concluido .video-num { background: var(--success-bg); color: var(--success); }

.video-info { flex: 1; }
.video-titulo { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.video-meta { font-size: 12px; color: var(--text-muted); }

.video-actions { display: flex; gap: 8px; }

/* ── Botões ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
  color: #fff;
  box-shadow: 0 0 0 0 var(--accent-glow);
}
.btn-primary:hover {
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, #065f46, #059669);
  color: #fff;
}
.btn-success:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(16,185,129,0.3); }

.btn-danger  { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }

/* ── Formulários ── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-control::placeholder { color: var(--text-dim); }

textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── Tabelas ── */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th {
  background: var(--bg-base);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(51,65,85,0.5);
  font-size: 14px;
  color: var(--text-primary);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-card2); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-secondary { background: rgba(100,116,139,0.2); color: var(--text-muted); }
.badge-primary { background: var(--accent-glow); color: var(--accent); }

/* ── Alertas ── */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
}
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.alert-error   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(239,68,68,0.3); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245,158,11,0.3); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid rgba(6,182,212,0.3); }

/* ── Login Page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 50% at 20% 20%, rgba(59,130,246,0.15), transparent),
    radial-gradient(ellipse 60% 60% at 80% 80%, rgba(16,185,129,0.1), transparent),
    var(--bg-base);
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 420px;
}

.login-header { text-align: center; margin-bottom: 32px; }
.login-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  margin: 0 auto 16px;
  box-shadow: 0 8px 24px rgba(59,130,246,0.4);
}
.login-title { font-size: 26px; font-weight: 800; color: var(--text-primary); }
.login-subtitle { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-lg);
}

.login-btn {
  width: 100%;
  padding: 13px;
  font-size: 15px;
  justify-content: center;
  border-radius: var(--radius-sm);
}

/* ── Rating Stars ── */
.star-rating {
  display: flex;
  gap: 6px;
  flex-direction: row-reverse;
  justify-content: flex-end;
}
.star-rating input { display: none; }
.star-rating label {
  font-size: 28px;
  color: var(--text-dim);
  cursor: pointer;
  transition: color var(--transition);
}
.star-rating label:hover,
.star-rating label:hover ~ label,
.star-rating input:checked ~ label {
  color: var(--warning);
}

/* ── Questionário ── */
.pergunta-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  transition: border-color var(--transition);
}
.pergunta-card:focus-within { border-color: var(--accent); }
.pergunta-num { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; font-weight: 600; }
.pergunta-texto { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-bottom: 14px; }

.opcao-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition);
}
.opcao-item:hover { border-color: var(--accent); background: var(--accent-glow); }
/* Estado selecionado — usando :has() com fallback via classe .selected (JS) */
.opcao-item:has(input[type="radio"]:checked),
.opcao-item.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
  box-shadow: 0 0 0 2px var(--accent);
}
.opcao-item:has(input[type="radio"]:checked) span,
.opcao-item.selected span {
  color: var(--accent);
  font-weight: 700;
}

/* ── Certificado ── */
.cert-page {
  min-height: 100vh;
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.cert-box {
  width: 800px;
  max-width: 100%;
  background: var(--bg-card);
  border: 2px solid var(--success);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 0 60px rgba(16,185,129,0.2);
}

.cert-header {
  background: linear-gradient(135deg, #065f46, #059669, #34d399);
  padding: 40px;
  text-align: center;
}
.cert-body { padding: 40px; text-align: center; }
.cert-titulo { font-size: 32px; font-weight: 800; color: #fff; }
.cert-sub { font-size: 16px; color: rgba(255,255,255,0.8); margin-top: 4px; }
.cert-nome { font-size: 36px; font-weight: 800; color: var(--success); margin: 24px 0 8px; }
.cert-formacao { font-size: 20px; color: var(--text-primary); font-weight: 600; }
.cert-codigo { font-size: 12px; color: var(--text-dim); margin-top: 24px; font-family: monospace; }

/* ── Video Player ── */
.video-player-box {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.video-player-box video,
.video-player-box iframe {
  width: 100%; height: 100%;
}
.video-placeholder {
  text-align: center;
  color: var(--text-dim);
}
.video-placeholder i { font-size: 48px; margin-bottom: 8px; display: block; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
  font-family: inherit;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

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

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; display: block; opacity: 0.5; }
.empty-state h3 { font-size: 18px; color: var(--text-muted); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .content { padding: 16px; }
  .formacoes-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row.cols-2,
  .form-row.cols-3 { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
}

/* ── Utilities ── */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.fw-bold { font-weight: 700; }
.text-center { text-align: center; }

/* ── Animations ── */
@keyframes fadeIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
@keyframes pulse  { 0%,100% { opacity:1; } 50% { opacity:.6; } }
@keyframes spin   { to { transform:rotate(360deg); } }

.animate-fade-in { animation: fadeIn 0.3s ease both; }
.animate-pulse   { animation: pulse 2s ease infinite; }

.loading-spin { animation: spin 1s linear infinite; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ── Print ── */
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .main { margin-left: 0; }
  body { background: #fff; color: #000; }
  .cert-box { border: 3px solid #059669; box-shadow: none; }
}
