:root {
  --tbp-primary: #1e3a8a;
  --tbp-secondary: #3b82f6;
  --tbp-light: #dbeafe;
  --tbp-success: #16a34a;
  --tbp-warning: #f59e0b;
  --tbp-danger: #dc2626;
}

body {
  background: #f3f4f6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1f2937;
}

/* ==================== NAVBAR ==================== */
.tbp-navbar {
  background: var(--tbp-primary) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.tbp-navbar .navbar-brand strong { font-size: 1.1rem; letter-spacing: 0.3px; }
.tbp-navbar .nav-link { color: rgba(255,255,255,0.85) !important; transition: all .15s; }
.tbp-navbar .nav-link:hover, .tbp-navbar .nav-link.active { color: #fff !important; }
.avatar-iniciales {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,0.2); color: #fff; font-weight: 600; font-size: 0.8rem;
}
.dropdown-menu { box-shadow: 0 4px 12px rgba(0,0,0,0.1); border: 1px solid #e5e7eb; }

/* ==================== LOGIN ==================== */
.login-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--tbp-primary) 0%, var(--tbp-secondary) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 12px; padding: 40px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  max-width: 420px; width: 100%;
}
.login-card .logo-area { text-align: center; margin-bottom: 24px; }
.login-card h1 { color: var(--tbp-primary); font-size: 1.5rem; font-weight: 700; }

/* ==================== CARDS / DASHBOARD ==================== */
.tbp-card { background: #fff; border-radius: 8px; border: 1px solid #e5e7eb; padding: 20px; margin-bottom: 20px; }
.stat-card {
  background: #fff; border-radius: 8px; padding: 20px;
  border-left: 4px solid var(--tbp-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stat-card .stat-label { font-size: .8rem; color: #6b7280; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--tbp-primary); }
.stat-card.success { border-left-color: var(--tbp-success); }
.stat-card.success .stat-value { color: var(--tbp-success); }
.stat-card.warning { border-left-color: var(--tbp-warning); }
.stat-card.warning .stat-value { color: var(--tbp-warning); }
.stat-card.danger { border-left-color: var(--tbp-danger); }
.stat-card.danger .stat-value { color: var(--tbp-danger); }

/* ==================== CURSOS ==================== */
.curso-card {
  background: #fff; border-radius: 8px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05); transition: all .2s;
  height: 100%; display: flex; flex-direction: column;
}
.curso-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.12); transform: translateY(-2px); }
.curso-card .curso-img {
  height: 160px; background: linear-gradient(135deg, var(--tbp-primary), var(--tbp-secondary));
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.curso-card .curso-img i { font-size: 3rem; }
.curso-card .curso-img img { width: 100%; height: 100%; object-fit: cover; }
.curso-card .curso-body { padding: 16px; flex: 1; display: flex; flex-direction: column; }
.curso-card h5 { color: var(--tbp-primary); font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
.curso-card .meta { font-size: .85rem; color: #6b7280; margin-bottom: 12px; }
.curso-card .descripcion { font-size: .85rem; color: #4b5563; flex: 1; margin-bottom: 12px; }
.curso-card .progress { height: 6px; }

/* ==================== BADGES / ROLES ==================== */
.badge-rol-admin { background: #dc2626; }
.badge-rol-profesor { background: var(--tbp-secondary); }
.badge-rol-alumno { background: var(--tbp-success); }
.badge-estado-publicado { background: var(--tbp-success); }
.badge-estado-borrador { background: #6b7280; }
.badge-estado-archivado { background: #4b5563; }
.badge-estado-activo { background: var(--tbp-secondary); }
.badge-estado-completado { background: var(--tbp-success); }
.badge-estado-vencido { background: var(--tbp-danger); }
.badge-estado-retirado { background: #6b7280; }

/* ==================== LECCIONES ==================== */
.lista-modulos { background: #fff; border-radius: 8px; padding: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); position: sticky; top: 16px; }
.lista-modulos .modulo-titulo { font-weight: 700; color: var(--tbp-primary); padding: 8px 12px; font-size: .9rem; border-top: 1px solid #f3f4f6; }
.lista-modulos .modulo-titulo:first-child { border-top: none; }
.lista-modulos .leccion-item { padding: 8px 12px; cursor: pointer; border-radius: 4px; font-size: .9rem; display: flex; align-items: center; gap: 8px; }
.lista-modulos .leccion-item:hover { background: #f3f4f6; }
.lista-modulos .leccion-item.activa { background: var(--tbp-light); color: var(--tbp-primary); font-weight: 600; }
.lista-modulos .leccion-item.completada { color: var(--tbp-success); }
.lista-modulos .leccion-item.bloqueada { cursor: not-allowed; opacity: 0.6; background: #f9fafb; }
.lista-modulos .leccion-item.bloqueada:hover { background: #f9fafb; }
.lista-modulos .leccion-item .check { width: 18px; flex-shrink: 0; }

/* ==================== CHAT ==================== */
.chat-layout { display: grid; grid-template-columns: 280px 1fr; gap: 16px; height: calc(100vh - 120px); }
@media (max-width: 768px) { .chat-layout { grid-template-columns: 1fr; height: auto; } }
.chat-sidebar { background: #fff; border-radius: 8px; overflow-y: auto; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.chat-conversaciones { list-style: none; padding: 0; margin: 0; }
.chat-conversaciones li {
  padding: 12px; border-bottom: 1px solid #f3f4f6; cursor: pointer;
  display: flex; align-items: center; gap: 10px; transition: background .15s;
}
.chat-conversaciones li:hover { background: #f9fafb; }
.chat-conversaciones li.activa { background: var(--tbp-light); }
.chat-conv-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--tbp-secondary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: .85rem; flex-shrink: 0;
}
.chat-conv-info { flex: 1; min-width: 0; }
.chat-conv-info .nombre { font-weight: 600; font-size: .9rem; color: #1f2937; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-conv-info .ultimo { font-size: .8rem; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-conv-badge { background: var(--tbp-danger); color: #fff; font-size: .7rem; padding: 2px 7px; border-radius: 10px; min-width: 20px; text-align: center; }

.chat-main { background: #fff; border-radius: 8px; display: flex; flex-direction: column; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.chat-header { padding: 14px 18px; border-bottom: 1px solid #e5e7eb; font-weight: 600; }
.chat-mensajes { flex: 1; overflow-y: auto; padding: 16px; background: #f9fafb; min-height: 400px; }
.chat-msg { margin-bottom: 12px; max-width: 70%; clear: both; }
.chat-msg .burbuja { padding: 10px 14px; border-radius: 12px; font-size: .9rem; line-height: 1.4; word-wrap: break-word; }
.chat-msg .meta { font-size: .7rem; color: #9ca3af; margin-top: 4px; }
.chat-msg.recibido { float: left; }
.chat-msg.recibido .burbuja { background: #fff; color: #1f2937; border: 1px solid #e5e7eb; }
.chat-msg.enviado { float: right; }
.chat-msg.enviado .burbuja { background: var(--tbp-primary); color: #fff; }
.chat-msg.enviado .meta { text-align: right; }
.chat-msg.masivo .burbuja { border-left: 3px solid var(--tbp-warning); }
.chat-msg.prioritario .burbuja { border: 2px solid var(--tbp-danger); }
.chat-input { padding: 12px; border-top: 1px solid #e5e7eb; display: flex; gap: 8px; }
.chat-input textarea { resize: none; }

/* ==================== ALERTAS PENDIENTES ==================== */
.alerta-pendiente {
  background: linear-gradient(90deg, #fef3c7, #fffbeb);
  border-left: 4px solid var(--tbp-warning); padding: 14px 18px;
  border-radius: 6px; margin-bottom: 12px;
}
.alerta-pendiente.urgente { background: linear-gradient(90deg, #fee2e2, #fef2f2); border-left-color: var(--tbp-danger); }
.alerta-pendiente .titulo { font-weight: 600; color: #1f2937; }
.alerta-pendiente .meta { font-size: .85rem; color: #6b7280; }

/* ==================== TABLAS ==================== */
.table-tbp { background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.table-tbp thead { background: #f9fafb; }
.table-tbp thead th { font-weight: 600; color: #374151; font-size: .85rem; text-transform: uppercase; letter-spacing: 0.3px; border-bottom: 2px solid #e5e7eb; }
.table-tbp tbody tr:hover { background: #f9fafb; }

@media (max-width: 768px) {
  .table-stack thead { display: none; }
  .table-stack tr { display: block; border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px; margin-bottom: 12px; background: #fff; }
  .table-stack td { display: block; border: none !important; padding: 4px 0; }
  .table-stack td::before { content: attr(data-label) ": "; font-weight: 600; color: #374151; }
}

/* ==================== EVALUACIONES ==================== */
.pregunta-card { background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 16px; border-left: 4px solid var(--tbp-secondary); }
.opcion-eval { display: block; padding: 10px 14px; border: 1px solid #e5e7eb; border-radius: 6px; margin-bottom: 8px; cursor: pointer; transition: all .15s; }
.opcion-eval:hover { background: #f9fafb; border-color: var(--tbp-secondary); }
.opcion-eval input { margin-right: 10px; }
.opcion-eval.seleccionada { background: var(--tbp-light); border-color: var(--tbp-primary); }
.opcion-eval.correcta { background: #dcfce7; border-color: var(--tbp-success); }
.opcion-eval.incorrecta { background: #fee2e2; border-color: var(--tbp-danger); }

.timer-eval { position: sticky; top: 16px; background: #fff; padding: 12px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); text-align: center; }
.timer-eval .tiempo { font-size: 1.5rem; font-weight: 700; color: var(--tbp-primary); font-family: monospace; }
.timer-eval.warning .tiempo { color: var(--tbp-warning); }
.timer-eval.danger .tiempo { color: var(--tbp-danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .5; } }

/* ==================== CERTIFICADO EDITOR ==================== */
.cert-canvas { position: relative; border: 2px dashed #d1d5db; background: #fff; margin: 0 auto; overflow: hidden; }
.cert-canvas img.fondo { width: 100%; height: 100%; object-fit: cover; }
.cert-elemento {
  position: absolute; cursor: move; padding: 4px 8px;
  background: rgba(30,58,138,0.1); border: 2px solid var(--tbp-primary);
  border-radius: 4px; font-weight: 600; user-select: none;
}
.cert-elemento.qr { background: rgba(0,0,0,0.05); }

/* ==================== UTILIDADES ==================== */
.text-tbp { color: var(--tbp-primary) !important; }
.bg-tbp { background-color: var(--tbp-primary) !important; }
.btn-tbp { background-color: var(--tbp-primary); color: #fff; border: none; }
.btn-tbp:hover { background-color: #1e40af; color: #fff; }

.no-data { text-align: center; padding: 40px 20px; color: #9ca3af; }
.no-data i { font-size: 3rem; margin-bottom: 12px; opacity: .5; }
