/* Campus Virtual — sistema visual propio, inspirado en la paleta del logo TuniverS */

:root {
  --wine: #7a1642;
  --wine-dark: #4f0d2b;
  --wine-light: #a6416e;
  --gold: #d9a84e;
  --gold-dark: #b8863a;
  --sage: #7fa35c;
  --sage-dark: #5f7f41;
  --bg: #f6f3f1;
  --surface: #ffffff;
  --surface-2: #fbf8f5;
  --text: #2a1f27;
  --text-muted: #8a7b84;
  --border: #ece3e0;
  --shadow-sm: 0 1px 3px rgba(74, 20, 47, 0.08);
  --shadow-md: 0 8px 24px rgba(74, 20, 47, 0.1);
  --shadow-lg: 0 16px 40px rgba(74, 20, 47, 0.16);
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  min-height: 100%;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

a { color: var(--wine); text-decoration: none; }
a:hover { color: var(--wine-dark); }

::selection { background: var(--gold); color: var(--wine-dark); }

/* ---------- Navbar ---------- */
.cv-navbar {
  background: linear-gradient(100deg, var(--wine-dark) 0%, var(--wine) 55%, var(--wine-light) 100%);
  box-shadow: var(--shadow-md);
  padding: .65rem 0;
  position: sticky;
  top: 0;
  z-index: 1030;
}
.cv-navbar .navbar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 800;
  font-size: 1.15rem;
  color: #fff !important;
  letter-spacing: -.01em;
}
.cv-navbar .brand-logo {
  height: 40px;
  width: 40px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.55);
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.cv-navbar .brand-sub {
  display: block;
  font-size: .68rem;
  font-weight: 500;
  color: rgba(255,255,255,.7);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-top: -2px;
}
.cv-navbar .nav-link {
  color: rgba(255,255,255,.85) !important;
  font-weight: 600;
  font-size: .92rem;
  padding: .5rem .9rem !important;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: .45rem;
  transition: background .15s ease, color .15s ease;
}
.cv-navbar .nav-link i { font-size: 1rem; }
.cv-navbar .nav-link:hover,
.cv-navbar .nav-link.active {
  background: rgba(255,255,255,.14);
  color: #fff !important;
}
.cv-navbar .navbar-toggler {
  border-color: rgba(255,255,255,.4);
}
.cv-navbar .navbar-toggler-icon {
  filter: invert(1) grayscale(100%) brightness(200%);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: .55rem;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  padding: .3rem .8rem .3rem .35rem;
  color: #fff;
}
.user-chip .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--wine-dark);
  font-weight: 800;
  font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
}
.user-chip .role-pill {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: rgba(255,255,255,.75);
}
.btn-logout {
  border: 1px solid rgba(255,255,255,.5);
  color: #fff;
  background: transparent;
  border-radius: 999px;
  padding: .35rem .95rem;
  font-size: .85rem;
  font-weight: 600;
  transition: all .15s ease;
}
.btn-logout:hover { background: rgba(255,255,255,.15); color: #fff; }

/* ---------- Layout helpers ---------- */
.cv-page { padding-bottom: 3.5rem; }
.cv-hero {
  margin-bottom: 1.75rem;
}
.cv-hero h1 { font-size: 1.7rem; margin-bottom: .15rem; }
.cv-hero .cv-hero-sub { color: var(--text-muted); font-size: .95rem; }

.breadcrumb { background: transparent; padding: 0 0 1.1rem; margin-bottom: 0; font-size: .87rem; }
.breadcrumb-item a { color: var(--text-muted); font-weight: 600; }
.breadcrumb-item a:hover { color: var(--wine); }
.breadcrumb-item.active { color: var(--wine); font-weight: 700; }
.breadcrumb-item + .breadcrumb-item::before { content: "\f285"; font-family: "bootstrap-icons"; font-size: .65rem; color: var(--text-muted); }

/* ---------- Cards ---------- */
.card, .surface-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.surface-card.pad { padding: 1.5rem; }
.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.1rem;
}
.card-title-row h5 { margin: 0; font-size: 1.05rem; }

.clickable-card {
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  display: block;
}
.clickable-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--wine-light);
}

/* Stat tiles */
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: .85rem;
  height: 100%;
}
.stat-tile .stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  color: #fff;
  flex-shrink: 0;
}
.stat-tile .stat-value { font-size: 1.55rem; font-weight: 800; line-height: 1; }
.stat-tile .stat-label { color: var(--text-muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; margin-top: .2rem; }
.stat-icon.bg-wine { background: linear-gradient(135deg, var(--wine), var(--wine-light)); }
.stat-icon.bg-gold { background: linear-gradient(135deg, var(--gold-dark), var(--gold)); }
.stat-icon.bg-sage { background: linear-gradient(135deg, var(--sage-dark), var(--sage)); }
.stat-icon.bg-plum { background: linear-gradient(135deg, #5b4a86, #8a75c2); }
.stat-icon.bg-slate { background: linear-gradient(135deg, #4a5568, #718096); }

/* ---------- Tables ---------- */
.table-clean {
  margin-bottom: 0;
  border-collapse: separate;
  border-spacing: 0;
}
.table-clean thead th {
  border: none;
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding-bottom: .75rem;
}
.table-clean tbody tr { transition: background .12s ease; }
.table-clean tbody tr:hover { background: var(--surface-2); }
.table-clean tbody td { border-top: 1px solid var(--border); padding: .8rem .5rem; vertical-align: middle; }
.table-clean tbody tr:first-child td { border-top: none; }
.table-clean a.row-link { font-weight: 700; color: var(--text); }
.table-clean a.row-link:hover { color: var(--wine); }

/* ---------- Buttons ---------- */
.btn { border-radius: 999px; font-weight: 600; letter-spacing: .01em; }
.btn-primary {
  background: linear-gradient(120deg, var(--wine), var(--wine-light));
  border: none;
  box-shadow: 0 4px 14px rgba(122, 22, 66, .28);
}
.btn-primary:hover { background: linear-gradient(120deg, var(--wine-dark), var(--wine)); box-shadow: 0 6px 18px rgba(122, 22, 66, .35); }
.btn-outline-secondary { border-color: var(--border); color: var(--text-muted); }
.btn-outline-secondary:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-outline-danger { border-color: #e7c2ce; color: #b0335a; }
.btn-outline-danger:hover { background: #b0335a; border-color: #b0335a; }
.btn-success { background: linear-gradient(120deg, var(--sage-dark), var(--sage)); border: none; }
.btn-outline-primary { border-color: var(--wine-light); color: var(--wine); }
.btn-outline-primary:hover { background: var(--wine); border-color: var(--wine); }
.btn-sm { font-size: .8rem; }

/* ---------- Badges / pills ---------- */
.badge { font-weight: 600; letter-spacing: .01em; border-radius: 999px; padding: .4em .75em; }
.badge.bg-success { background: var(--sage) !important; }
.badge.bg-secondary { background: #cbb9c3 !important; color: var(--wine-dark); }
.badge.bg-info { background: #ede2d8 !important; color: var(--gold-dark); }

/* ---------- Progress ---------- */
.progress { height: .6rem; border-radius: 999px; background: var(--border); overflow: hidden; }
.progress-bar { background: linear-gradient(90deg, var(--sage-dark), var(--sage)); }
.progress-lg { height: 1.4rem; font-size: .72rem; font-weight: 700; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: .85rem; color: var(--text); margin-bottom: .3rem; }
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: .55rem .8rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--wine-light);
  box-shadow: 0 0 0 .2rem rgba(122, 22, 66, .12);
}

/* ---------- Empty states ---------- */
.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
}
.empty-state i { font-size: 2rem; color: var(--wine-light); margin-bottom: .6rem; display: block; }
.empty-state a { font-weight: 700; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius-sm); border: none; }
.alert-info { background: #f2e9f6; color: #5b3a6e; }
.alert-warning { background: #fbf0dc; color: #8a5e14; }
.alert-danger { background: #fbe4ea; color: #a12a52; }
.alert-success { background: #e9f2e0; color: var(--sage-dark); }

/* ---------- Video ---------- */
.video-shell {
  background: #14090f;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-shell video { width: 100%; height: 100%; object-fit: contain; background: #000; }

/* ---------- Login ---------- */
@keyframes cvFadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.login-wrap {
  min-height: calc(100vh - 0px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  padding: 2.5rem 1rem;
  background:
    radial-gradient(1200px 600px at 12% -15%, rgba(217,168,78,.16), transparent 55%),
    radial-gradient(1000px 600px at 108% 115%, rgba(122,22,66,.14), transparent 55%),
    radial-gradient(700px 500px at 50% 50%, rgba(127,163,92,.06), transparent 60%),
    var(--bg);
}

.login-shell {
  width: 100%;
  max-width: 880px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: cvFadeUp .5s ease both;
}

.login-visual {
  position: relative;
  padding: 2.6rem 2.2rem;
  display: flex;
  align-items: center;
  background: linear-gradient(155deg, var(--wine-dark) 0%, var(--wine) 55%, var(--wine-light) 100%);
  color: #fff;
  overflow: hidden;
}
.login-visual-pattern {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.10) 0, transparent 42%),
    radial-gradient(circle at 85% 15%, rgba(217,168,78,.35) 0, transparent 38%),
    radial-gradient(circle at 90% 85%, rgba(255,255,255,.08) 0, transparent 40%);
  pointer-events: none;
}
.login-visual-content { position: relative; z-index: 1; }
.login-visual .login-logo-ring {
  margin: 0 0 1.4rem;
  background: linear-gradient(135deg, var(--gold), #fff);
  box-shadow: 0 8px 22px rgba(0,0,0,.25);
}
.login-visual h2 { color: #fff; font-size: 1.6rem; margin-bottom: .6rem; }
.login-visual p { color: rgba(255,255,255,.82); font-size: .92rem; line-height: 1.5; margin-bottom: 1.5rem; }
.login-visual-points { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .7rem; }
.login-visual-points li { display: flex; align-items: center; gap: .65rem; font-size: .88rem; font-weight: 600; color: #fff; }
.login-visual-points i { color: var(--gold); font-size: 1.05rem; flex-shrink: 0; }

.login-form-panel {
  padding: 2.6rem 2.4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-form-panel h4 { text-align: left; margin-bottom: .25rem; font-size: 1.35rem; }
.login-form-panel .login-sub { text-align: left; color: var(--text-muted); font-size: .85rem; margin-bottom: 1.5rem; }
.login-form-panel .btn-primary { width: 100%; padding: .68rem; }

.input-icon-wrap { position: relative; display: flex; align-items: center; }
.input-icon-wrap > i:first-child {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 1rem; pointer-events: none;
  transition: color .15s ease;
}
.input-icon-wrap input.form-control {
  width: 100%;
  height: 48px;
  padding-left: 2.7rem;
  padding-right: 1rem;
  font-size: .95rem;
  line-height: 1.3;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input-icon-wrap input.form-control::placeholder { color: var(--text-muted); opacity: .65; }
.input-icon-wrap:has(.input-icon-toggle) input.form-control { padding-right: 2.7rem; }
.input-icon-wrap input.form-control:focus {
  border-color: var(--wine-light);
  box-shadow: 0 0 0 .2rem rgba(122, 22, 66, .13);
}
.input-icon-wrap input.form-control:focus ~ i:first-child,
.input-icon-wrap:focus-within > i:first-child { color: var(--wine); }
.input-icon-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border: none; background: transparent; color: var(--text-muted);
  padding: 0; border-radius: 8px; line-height: 1; font-size: 1rem;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.input-icon-toggle:hover { color: var(--wine); background: var(--surface-2); }
.input-icon-toggle:focus-visible { outline: 2px solid var(--wine-light); outline-offset: 1px; }

.quick-login-card {
  max-width: 880px;
  width: 100%;
  padding: 1.6rem 1.8rem;
  animation: cvFadeUp .5s ease .1s both;
}
.quick-login-card .accordion-item {
  background: transparent;
  border-color: var(--border);
}
.quick-login-card .accordion-button {
  background: transparent;
  box-shadow: none;
  font-weight: 600;
}
.quick-login-card .accordion-button:not(.collapsed) {
  background: var(--bg);
  color: var(--wine);
}
.ql-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .6rem;
}
.ql-chip-form { display: contents; }
.ql-chip {
  display: flex; align-items: center; gap: .6rem;
  width: 100%;
  padding: .5rem .65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-align: left;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.ql-chip:hover { border-color: var(--wine-light); background: var(--surface); transform: translateY(-1px); }
.ql-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; color: #fff; flex-shrink: 0;
  background: linear-gradient(135deg, var(--wine), var(--wine-light));
}
.ql-chip-text { display: flex; flex-direction: column; min-width: 0; }
.ql-chip-name { font-weight: 700; font-size: .82rem; color: var(--text); }
.ql-chip-full { font-size: .72rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 2.4rem 2.1rem;
  border: 1px solid var(--border);
}
.login-logo-ring {
  width: 84px; height: 84px;
  border-radius: 50%;
  margin: 0 auto 1rem;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--wine), var(--gold));
  padding: 3px;
}
.login-logo-ring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 3px solid var(--surface); }
.login-card h4 { text-align: center; margin-top: .25rem; }
.login-card .login-sub { text-align: center; color: var(--text-muted); font-size: .85rem; margin-bottom: 1.6rem; }
.login-card .btn-primary { width: 100%; padding: .65rem; }
.login-foot { text-align: center; margin-top: 1.4rem; font-size: .78rem; color: var(--text-muted); }

@media (max-width: 860px) {
  .login-shell { grid-template-columns: 1fr; max-width: 440px; }
  .login-visual { padding: 2rem 1.8rem 1.6rem; }
  .login-visual-points { display: none; }
  .login-form-panel { padding: 2rem 1.8rem; }
}

/* ---------- Course cards (mis cursos) ---------- */
.course-card { padding: 1.4rem; margin-bottom: 1.2rem; }
.course-card .course-head { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.course-card .course-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--wine), var(--wine-light));
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.05rem; flex-shrink: 0;
}
.subject-row {
  display: flex; flex-direction: column; gap: .35rem;
  padding: .85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: background .15s ease, border-color .15s ease;
}
.subject-row + .subject-row { margin-top: .55rem; }
.subject-row:hover { background: var(--surface-2); border-color: var(--wine-light); }
.subject-row .subject-top { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }

/* ---------- Subject / topic cards (mis cursos, temas) ---------- */
.subject-card {
  padding: 1.3rem;
  display: flex;
  flex-direction: column;
  color: var(--text);
}
.subject-card-icon {
  width: 42px; height: 42px; border-radius: 11px;
  background: linear-gradient(135deg, var(--wine), var(--wine-light));
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
  margin-bottom: .85rem; flex-shrink: 0;
}
.subject-card h6 { font-weight: 700; }

.lesson-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: .65rem .2rem;
}
.lesson-item .lesson-name { display: flex; align-items: center; gap: .55rem; font-weight: 600; }
.lesson-item .lesson-name i { color: var(--wine-light); }
.lesson-item.done .lesson-name i { color: var(--sage-dark); }

/* ---------- Misc ---------- */
.section-icon-title { display: flex; align-items: center; gap: .55rem; }
.section-icon-title i { color: var(--wine); font-size: 1.15rem; }

@media (max-width: 767.98px) {
  .cv-navbar .navbar-collapse { margin-top: .75rem; }
  .user-chip { margin: .6rem 0; }
  .login-card { padding: 1.8rem 1.4rem; }
  .stat-tile { margin-bottom: .1rem; }
}

/* Evita que los botones de accion de las tablas se apilen verticalmente */
.table-clean td:last-child { white-space: nowrap; }
.table-clean td:last-child .btn + .btn,
.table-clean td:last-child form + .btn,
.table-clean td:last-child .btn + form { margin-left: .25rem; }

/* Selector de docentes (checkboxes) en el formulario de Asignatura */

/* Selector de asignaturas (checkboxes) al crear un alumno */
#id_asignaturas {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  max-height: 220px;
  overflow-y: auto;
  padding: .25rem 0;
}
#id_asignaturas > div {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .35rem .8rem;
  transition: border-color .15s, background .15s;
}
#id_asignaturas > div:has(input:checked) {
  border-color: var(--wine-light);
  background: rgba(122, 22, 66, .08);
}
#id_asignaturas label {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin: 0;
  font-weight: 500;
  cursor: pointer;
  font-size: .92rem;
}

#id_docentes {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  max-height: 220px;
  overflow-y: auto;
  padding: .25rem 0;
}
#id_docentes > div {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .35rem .8rem;
  transition: border-color .15s, background .15s;
}
#id_docentes > div:has(input:checked) {
  border-color: var(--wine-light);
  background: rgba(122, 22, 66, .08);
}
#id_docentes label {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin: 0;
  font-weight: 500;
  cursor: pointer;
  font-size: .92rem;
}
#id_docentes .helptext,
.docentes-help {
  display: block;
  width: 100%;
  font-size: .8rem;
  color: var(--text-muted, #7a7570);
  margin-top: .35rem;
}

/* ---- chat ---- */
.btn-chat-header {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  padding: .4rem .9rem;
  color: #fff;
  font-weight: 600;
  font-size: .85rem;
  text-decoration: none;
}
.btn-chat-header:hover { background: rgba(255,255,255,.22); color: #fff; }
.chat-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #dc3545;
  color: #fff;
  border-radius: 999px;
  font-size: .65rem;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 0 0 2px var(--wine-dark);
}
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--wine-dark);
  font-weight: 800;
  font-size: .9rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.avatar.avatar-sm { width: 30px; height: 30px; font-size: .78rem; }
@media (max-width: 991px) {
  .btn-chat-header span:not(.chat-badge) { display: none; }
}

/* ---- chat: página a pantalla completa ---- */
:root { --cv-navbar-h: 76px; }
.cv-page.cv-page-full {
  max-width: 100%;
  padding-left: 1rem;
  padding-right: 1rem;
}
@media (min-width: 1200px) {
  .cv-page.cv-page-full { padding-left: 2rem; padding-right: 2rem; }
}
body.chat-body { overflow: hidden; }
body.chat-body .cv-page.cv-page-full {
  padding-bottom: 1rem;
  height: calc(100vh - var(--cv-navbar-h));
  display: flex;
  flex-direction: column;
}
body.chat-body .cv-hero { flex: 0 0 auto; margin-bottom: 1rem; }

.chat-shell {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.1rem;
  flex: 1 1 auto;
  min-height: 0;
}
.chat-shell-thread { height: 100%; }
.chat-sidebar-col, .chat-main-col {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---- chat: sidebar de conversaciones ---- */
.chat-sidebar {
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 16px;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.06));
  padding: .9rem;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .9rem;
}
.chat-search-box {
  position: relative;
  flex: 0 0 auto;
}
.chat-search-box i {
  position: absolute;
  left: .8rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted, #948f8b);
  font-size: .9rem;
}
.chat-search-input {
  width: 100%;
  border: 1px solid rgba(0,0,0,.1);
  border-radius: 999px;
  padding: .5rem .9rem .5rem 2.2rem;
  font-size: .87rem;
  background: var(--bg);
}
.chat-search-input:focus { outline: none; border-color: var(--wine); box-shadow: 0 0 0 3px rgba(123,17,45,.12); }
.chat-list { display: flex; flex-direction: column; gap: .3rem; flex: 0 0 auto; }
.chat-list-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem .6rem;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: background .12s ease;
}
.chat-list-item:hover { background: var(--bg); }
.chat-list-item.active { background: rgba(123,17,45,.08); }
.chat-list-item-body { flex: 1 1 auto; min-width: 0; }
.chat-list-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.chat-list-item-top strong { font-size: .92rem; }
.chat-list-item-sub { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: .1rem; }
.chat-list-preview {
  color: var(--text-muted, #948f8b);
  font-size: .82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}
.chat-unread-pill { flex-shrink: 0; }
.role-pill-xs { font-size: .62rem; padding: .12rem .5rem; flex-shrink: 0; }
.chat-new-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted, #948f8b);
  display: flex; align-items: center; gap: .4rem;
  padding-top: .3rem;
  border-top: 1px solid rgba(0,0,0,.06);
}
.chat-new-accordion .accordion-button { font-size: .87rem; padding: .6rem .8rem; }
.chat-newuser-item { display: flex; align-items: center; gap: .6rem; font-size: .87rem; }
.empty-state-sm { padding: 1.2rem .5rem; font-size: .85rem; }

/* ---- chat: hilo ---- */
.chat-thread-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  color: var(--wine);
  background: var(--bg);
  flex-shrink: 0;
}
.chat-placeholder {
  height: 100%;
  border: 1px dashed rgba(0,0,0,.14);
  border-radius: 16px;
  background: #fff;
  color: var(--text-muted, #948f8b);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: .75rem;
  text-align: center;
  padding: 2rem;
}
.chat-placeholder i { font-size: 2.75rem; opacity: .35; }
.chat-thread {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  background: var(--bg);
}
.chat-date-sep { display: flex; justify-content: center; margin: .6rem 0; }
.chat-date-sep span {
  background: rgba(0,0,0,.06);
  color: var(--text-muted, #6f6a66);
  font-size: .72rem;
  font-weight: 700;
  padding: .25rem .8rem;
  border-radius: 999px;
}
.chat-sender-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted, #948f8b);
  margin: .5rem .2rem 0;
  min-height: 1em;
}
.chat-sender-label.mine { text-align: right; }
.chat-bubble-row { display: flex; margin-top: .12rem; }
.chat-bubble-row.mine { justify-content: flex-end; }
.chat-bubble {
  max-width: 68%;
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 14px;
  padding: .55rem .85rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.chat-bubble-row.mine .chat-bubble {
  background: var(--wine);
  color: #fff;
}
.chat-text { white-space: pre-wrap; word-break: break-word; font-size: .92rem; }
.chat-attachment-card {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: rgba(0,0,0,.04);
  border-radius: 10px;
  padding: .5rem .65rem;
  margin-top: .3rem;
  text-decoration: none;
  color: inherit;
  min-width: 12rem;
}
.chat-bubble-row.mine .chat-attachment-card { background: rgba(255,255,255,.16); color: #fff; }
.chat-attachment-icon { font-size: 1.5rem; flex-shrink: 0; }
.chat-attachment-info { flex: 1 1 auto; min-width: 0; }
.chat-attachment-name { display: block; font-weight: 700; font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-attachment-meta { display: block; font-size: .7rem; opacity: .75; }
.chat-attachment-dl { flex-shrink: 0; opacity: .7; }
.chat-meta {
  font-size: .68rem;
  color: #948f8b;
  margin-top: .3rem;
  text-align: right;
}
.chat-bubble-row.mine .chat-meta { color: rgba(255,255,255,.75); }

/* ---- chat: composer ---- */
.chat-composer { flex: 0 0 auto; background: #fff; }
.chat-composer-row { display: flex; align-items: flex-end; gap: .55rem; }
.chat-attach-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--wine);
  cursor: pointer;
  flex-shrink: 0;
}
.chat-attach-btn input[type="file"] { display: none; }
.chat-textarea-auto {
  resize: none;
  max-height: 140px;
  overflow-y: auto;
  border-radius: 18px !important;
}
.btn-chat-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--wine);
  color: #fff;
  flex-shrink: 0;
}
.btn-chat-send:hover { background: var(--wine-dark); }
.chat-file-preview {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  color: var(--text-muted, #948f8b);
  margin-top: .4rem;
}
.chat-file-preview-clear {
  border: none;
  background: none;
  color: #dc3545;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 .3rem;
}

@media (max-width: 767.98px) {
  .chat-shell { display: block; height: 100%; }
  .chat-shell .chat-hide-mobile { display: none !important; }
  .chat-sidebar-col, .chat-main-col { height: 100%; }
  .chat-bubble { max-width: 84%; }
}
@media (min-width: 768px) and (max-width: 991.98px) {
  .chat-shell { grid-template-columns: 260px 1fr; }
}

/* Acordeón de temas dentro de una asignatura (vista alumno) */
.tema-accordion { border-radius: var(--radius, .75rem); overflow: hidden; }
.tema-accordion .accordion-item {
  border-color: var(--border);
  border-radius: .75rem !important;
  overflow: hidden;
  margin-bottom: .75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.tema-accordion .accordion-item:last-child { margin-bottom: 0; }
.tema-accordion .accordion-button {
  background: var(--surface);
  font-weight: 700;
  box-shadow: none;
}
.tema-accordion .accordion-button:not(.collapsed) {
  background: var(--surface-2);
  color: var(--wine);
}
.tema-accordion .accordion-button:focus { box-shadow: none; }
.tema-accordion .accordion-body { background: var(--surface); }
.tema-accordion .lesson-item:last-child { border-bottom: none !important; }

/* Tablón de anuncios: cada anuncio se pliega/despliega, los fijados destacan */
.anuncio-item { transition: background-color .15s ease; }
.anuncio-item.anuncio-fijado { background: #fbf3e2; border-color: var(--gold) !important; }
.anuncio-toggle {
  color: var(--text);
  text-decoration: none;
  border: none;
  background: transparent;
}
.anuncio-toggle:hover, .anuncio-toggle:focus { color: var(--wine); text-decoration: none; }
.anuncio-toggle:focus { box-shadow: none; outline: none; }
.anuncio-chevron { display: inline-block; transition: transform .18s ease; color: var(--wine-light); font-size: .8em; }
.anuncio-toggle:not(.collapsed) .anuncio-chevron { transform: rotate(90deg); color: var(--wine); }

.profile-photo {
  width: 72px; height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--gold);
  flex-shrink: 0;
}
.profile-avatar-fallback {
  width: 72px; height: 72px;
  font-size: 1.6rem;
}
.user-chip-link {
  text-decoration: none;
  color: inherit;
}
.user-chip-link:hover .user-chip {
  filter: brightness(1.05);
}
.user-chip .avatar-photo {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.chat-partner-link {
  color: inherit;
  text-decoration: none;
}
.chat-partner-link:hover {
  text-decoration: underline;
}
