/* ============================================================
   MENSAJERÍA ESCOLAR — app.css
   Fuente: Nunito (Google Fonts)
   Paleta: Azul institucional + acentos cálidos
   ============================================================ */

/* ── Variables ────────────────────────────────────────────── */
:root {
  --blue-50:  #eff6ff;  --blue-100: #dbeafe;
  --blue-500: #3b82f6;  --blue-600: #1a56db;
  --blue-700: #1d4ed8;  --blue-900: #1e3a8a;
  --sky-400:  #38bdf8;  --sky-500:  #0ea5e9;
  --amber-400:#fbbf24;  --amber-500:#f59e0b;
  --red-500:  #ef4444;  --green-500:#10b981;
  --teal-500: #14b8a6;

  /* Light theme */
  --bg:          #f0f4ff;
  --bg-2:        #ffffff;
  --surface:     #ffffff;
  --surface-2:   #f3f6fd;
  --surface-3:   #e8edf8;
  --border:      #d1daf0;
  --text:        #0f172a;
  --text-2:      #334155;
  --text-muted:  #64748b;
  --primary:     #1a56db;
  --primary-h:   #1d4ed8;
  --primary-fg:  #ffffff;
  --accent:      #f59e0b;
  --danger:      #ef4444;
  --success:     #10b981;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow:      0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.14);
  --radius:      12px;
  --radius-sm:   8px;
  --radius-lg:   20px;
  --sidebar-w:   260px;
  --topbar-h:    60px;
  --font:        'Nunito', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', monospace;
}

[data-theme="dark"] {
  --bg:          #0d1117;
  --bg-2:        #161b22;
  --surface:     #1c2333;
  --surface-2:   #212a3e;
  --surface-3:   #2a3650;
  --border:      #2d3a50;
  --text:        #e6edf3;
  --text-2:      #b0bec5;
  --text-muted:  #8899aa;
  --primary:     #3b82f6;
  --primary-h:   #60a5fa;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.3);
  --shadow:      0 4px 16px rgba(0,0,0,.4);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.5);
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text);
       line-height: 1.6; min-height: 100vh; overflow-x: hidden; }
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; height: auto; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
svg { display: block; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* ── Layout ───────────────────────────────────────────────── */
.sidebar {
  position: fixed; left: 0; top: 0; height: 100vh; width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 300;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.page-body { flex: 1; padding: 24px; overflow-y: auto; }

/* ── Sidebar Header ───────────────────────────────────────── */
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 16px; border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 36px; height: 36px; flex-shrink: 0; }
.brand-icon svg { width: 36px; height: 36px; }
.brand-name { font-size: 1rem; font-weight: 800; color: var(--text); letter-spacing: -.3px; }
.brand-logo {
  height: 32px; max-width: 140px; object-fit: contain;
  border-radius: 6px; flex-shrink: 0;
}
.sidebar-close { display: none; }

/* ── User Card ────────────────────────────────────────────── */
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--surface-2);
  margin: 12px; border-radius: var(--radius); flex-shrink: 0;
}
.avatar-wrap { position: relative; cursor: pointer; flex-shrink: 0; }
.avatar, .avatar-initials {
  width: 40px; height: 40px; border-radius: 50%;
  object-fit: cover; display: flex; align-items: center; justify-content: center;
}
.avatar-initials {
  background: linear-gradient(135deg, var(--primary), var(--sky-500));
  color: #fff; font-weight: 700; font-size: 1rem;
}
.avatar-dot {
  position: absolute; bottom: 1px; right: 1px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--green-500); border: 2px solid var(--surface-2);
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 700; font-size: .88rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Role Badges ──────────────────────────────────────────── */
.role-badge { display: inline-block; font-size: .7rem; font-weight: 700; padding: 2px 8px;
              border-radius: 20px; text-transform: uppercase; letter-spacing: .5px; }
.role-admin   { background: #fef3c7; color: #92400e; }
.role-plus    { background: #ede9fe; color: #5b21b6; }
.role-teacher { background: #d1fae5; color: #065f46; }
.role-parent  { background: #dbeafe; color: #1e40af; }
.role-student { background: #fce7f3; color: #9d174d; }

.status-badge { font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.status-active   { background: #d1fae5; color: #065f46; }
.status-inactive { background: var(--surface-3); color: var(--text-muted); }
.status-blocked  { background: #fee2e2; color: #991b1b; }

/* ── Nav ──────────────────────────────────────────────────── */
.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; color: var(--text-2); font-weight: 600; font-size: .9rem;
  border-radius: var(--radius-sm); margin: 2px 10px;
  transition: background .15s, color .15s; position: relative;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--blue-50); color: var(--primary); }
[data-theme="dark"] .nav-item.active { background: rgba(59,130,246,.15); }
.nav-section-label {
  font-size: .68rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .8px; color: var(--text-muted); padding: 12px 16px 4px;
}
.nav-logout { color: var(--danger); }
.nav-logout:hover { background: #fee2e2; }
.sidebar-footer { padding: 12px 0 16px; border-top: 1px solid var(--border); }
.badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: .7rem; font-weight: 700; min-width: 18px; height: 18px;
  border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px;
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 14px;
  padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100; flex-shrink: 0;
}
.topbar-title { font-size: 1.1rem; font-weight: 800; flex: 1; color: var(--text); }
.topbar-actions { display: flex; gap: 8px; }
.hamburger { display: none; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm); border: none;
  background: transparent; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; position: relative;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.danger:hover { background: #fee2e2; color: var(--danger); }
.icon-sun, .icon-moon { transition: opacity .2s; }
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"]  .icon-sun  { display: none; }
.notif-dot {
  position: absolute; top: 6px; right: 6px; width: 8px; height: 8px;
  background: var(--danger); border-radius: 50%; border: 2px solid var(--surface);
}

/* ── Notification Panel ──────────────────────────────────── */
.notif-panel {
  position: fixed; top: var(--topbar-h); right: 0; width: 340px;
  background: var(--surface); border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border); border-radius: 0 0 0 var(--radius);
  box-shadow: var(--shadow-lg); z-index: 200; max-height: 480px;
  display: flex; flex-direction: column;
}
.notif-panel.hidden { display: none; }
.notif-header { display: flex; align-items: center; justify-content: space-between;
                padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 700; }
.notif-list { overflow-y: auto; flex: 1; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--blue-50); }
[data-theme="dark"] .notif-item.unread { background: rgba(59,130,246,.08); }
.notif-item-title { font-weight: 700; font-size: .85rem; }
.notif-item-body  { font-size: .8rem; color: var(--text-muted); }
.notif-item-time  { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.text-btn { background: none; border: none; color: var(--primary); font-size: .8rem; font-weight: 600; cursor: pointer; }

/* ── Sidebar Overlay ──────────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 250; backdrop-filter: blur(2px);
}

/* ── AUTH ─────────────────────────────────────────────────── */
.auth-body { background: linear-gradient(135deg, #0f1f5c 0%, #1a3fa8 50%, #0ea5e9 100%);
             display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-container { position: relative; width: 100%; display: flex; justify-content: center; align-items: center; }
.auth-bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.auth-blob { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .35; }
.blob-1 { width: 400px; height: 400px; background: #3b82f6; top: -100px; left: -100px; animation: blob 8s infinite ease-in-out; }
.blob-2 { width: 350px; height: 350px; background: #0ea5e9; bottom: -80px; right: -80px; animation: blob 10s infinite ease-in-out reverse; }
.blob-3 { width: 300px; height: 300px; background: #6366f1; top: 40%; left: 30%; animation: blob 12s infinite ease-in-out; }
@keyframes blob { 0%,100%{transform:translate(0,0) scale(1)} 33%{transform:translate(20px,-20px) scale(1.05)} 66%{transform:translate(-15px,15px) scale(.95)} }

.auth-card {
  position: relative; z-index: 1; background: rgba(255,255,255,.95);
  backdrop-filter: blur(20px); border-radius: 24px;
  padding: 40px 36px; width: 100%; max-width: 420px;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
  animation: slideUp .5s ease-out;
}
[data-theme="dark"] .auth-card { background: rgba(28,35,51,.95); }
@keyframes slideUp { from{opacity:0;transform:translateY(24px)} to{opacity:1;transform:none} }

.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 12px; }
.auth-logo svg { width: 64px; height: 64px; }
.auth-title { font-size: 1.6rem; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.auth-subtitle { color: var(--text-muted); font-size: .9rem; }
.auth-footer { text-align: center; margin-top: 24px; font-size: .78rem; color: var(--text-muted); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 700; font-size: .85rem; color: var(--text-2); margin-bottom: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input-wrap { position: relative; }
.input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-muted); pointer-events: none; }
.form-input {
  width: 100%; padding: 10px 14px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font-size: .9rem; transition: border-color .2s, box-shadow .2s;
}
.input-wrap .form-input { padding-left: 40px; }
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
textarea.form-input { resize: vertical; min-height: 80px; }
select.form-input { appearance: none; cursor: pointer; }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.eye-btn { position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
           background: none; border: none; color: var(--text-muted); padding: 4px; }
.eye-btn svg { width: 18px; height: 18px; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm); border: none;
  font-size: .9rem; font-weight: 700; font-family: var(--font);
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-ghost { background: transparent; color: var(--text-2); border: 2px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: .82rem; }
.btn svg { width: 18px; height: 18px; }
.btn-spinner { display: inline-flex; align-items: center; }
.btn-spinner .spin { width: 18px; height: 18px; animation: spin .8s linear infinite; }
@keyframes spin { to { stroke-dashoffset: -40; transform: rotate(360deg); } }

/* ── Alerts ───────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: .85rem; font-weight: 600; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }

/* ── Dashboard ────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 16px;
  border: 1px solid var(--border);
}
.stat-card.loading { min-height: 90px; animation: shimmer 1.5s infinite; }
@keyframes shimmer { 0%,100%{opacity:.6} 50%{opacity:.3} }
.stat-icon { font-size: 2rem; flex-shrink: 0; }
.stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1; display: block; }
.stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 600; }
.stat-blue   { border-left: 4px solid var(--primary); }
.stat-green  { border-left: 4px solid var(--green-500); }
.stat-teal   { border-left: 4px solid var(--teal-500); }
.stat-amber  { border-left: 4px solid var(--amber-500); }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-card { background: var(--surface); border-radius: var(--radius); padding: 20px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.card-title { font-size: 1rem; font-weight: 800; margin-bottom: 16px; color: var(--text); }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action-btn {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 8px; border-radius: var(--radius-sm); border: 2px solid var(--border);
  background: var(--surface-2); color: var(--text-2); font-weight: 700; font-size: .82rem;
  cursor: pointer; transition: all .2s; text-align: center;
}
.action-btn:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.action-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.action-icon svg { width: 22px; height: 22px; color: #fff; }
.action-icon.msg   { background: linear-gradient(135deg, var(--primary), var(--sky-500)); }
.action-icon.bcast { background: linear-gradient(135deg, var(--amber-400), #f97316); }
.action-icon.grp   { background: linear-gradient(135deg, var(--green-500), var(--teal-500)); }
.action-icon.usr   { background: linear-gradient(135deg, #8b5cf6, #ec4899); }

.activity-list { display: flex; flex-direction: column; gap: 12px; }
.activity-item { display: flex; gap: 12px; align-items: flex-start; }
.activity-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--sky-500));
                   color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.activity-text { font-size: .85rem; color: var(--text); margin: 0; }
.activity-meta { font-size: .75rem; color: var(--text-muted); }

.skeleton-row { height: 56px; border-radius: var(--radius-sm); background: var(--surface-2); margin-bottom: 8px; animation: shimmer 1.5s infinite; }

/* ── Chat ─────────────────────────────────────────────────── */
.page-body:has(.chat-shell) { padding: 0; overflow: hidden; }
.chat-shell { display: flex; height: calc(100vh - var(--topbar-h)); }
.conv-panel { width: 220px !important; min-width: 220px !important; max-width: 220px !important;
              flex-shrink: 0 !important; border-right: 1px solid var(--border);
              display: flex; flex-direction: column; background: var(--surface); overflow: hidden; }
.chat-area { flex: 1 !important; min-width: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.conv-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.conv-header h2 { font-size: 1.1rem; font-weight: 800; }
.conv-search { display: flex; align-items: center; gap: 8px; padding: 10px 12px;
               border-bottom: 1px solid var(--border); background: var(--surface-2); }
.conv-search svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.conv-search input { flex: 1; border: none; background: transparent; color: var(--text);
                      font-size: .88rem; outline: none; }
.conv-tabs { display: flex; border-bottom: 1px solid var(--border); }
.conv-tab { flex: 1; padding: 10px; border: none; background: transparent; color: var(--text-muted);
            font-weight: 700; font-size: .82rem; cursor: pointer; border-bottom: 2px solid transparent; }
.conv-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--surface-2); }
.conv-list { flex: 1; overflow-y: auto; }

.conv-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px;
             cursor: pointer; border-bottom: 1px solid var(--border); transition: background .15s; }
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--blue-50); }
[data-theme="dark"] .conv-item.active { background: rgba(59,130,246,.12); }
.conv-item.unread .conv-name { font-weight: 800; color: var(--text); }
.conv-avatar { width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--sky-500));
               color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center;
               flex-shrink: 0; overflow: hidden; font-size: 1.1rem; }
.conv-avatar img { width: 100%; height: 100%; object-fit: cover; }
.group-av { background: linear-gradient(135deg, var(--group-color, #1a56db), color-mix(in srgb, var(--group-color,#1a56db) 70%, white)); }
.conv-info { flex: 1; min-width: 0; }
.conv-name { font-weight: 700; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-preview { font-size: .78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.conv-time { font-size: .72rem; color: var(--text-muted); }
.conv-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.skeleton-conv { height: 68px; border-bottom: 1px solid var(--border); background: var(--surface-2); animation: shimmer 1.5s infinite; }

/* ── Chat Area ────────────────────────────────────────────── */
.chat-area { flex: 1; width: 90%; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
              gap: 12px; color: var(--text-muted); text-align: center; padding: 40px; }
.chat-empty-icon svg { width: 80px; height: 80px; }
.chat-empty h3 { font-size: 1.2rem; font-weight: 800; color: var(--text); }
.chat-view { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.chat-header { display: flex; align-items: center; gap: 12px; padding: 12px 16px;
               background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chat-header-info { flex: 1; display: flex; align-items: center; gap: 12px; }
.chat-avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--sky-500));
               color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chat-name { font-weight: 800; font-size: .95rem; }
.chat-status { font-size: .75rem; color: var(--text-muted); }
.back-btn { display: none; }

.messages-wrap { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; }
.messages-list { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.msg-loader { display: flex; justify-content: center; padding: 10px; }

.msg-wrap { display: flex; flex-direction: column; max-width: 72%; }
.msg-wrap.mine { align-self: flex-end; align-items: flex-end; }
.msg-wrap.theirs { align-self: flex-start; align-items: flex-start; }
.msg-sender { font-size: .72rem; font-weight: 700; color: var(--primary); margin-bottom: 2px; padding-left: 4px; }
.msg-bubble {
  background: var(--surface); border-radius: 18px; padding: 10px 14px;
  box-shadow: var(--shadow-sm); max-width: 100%;
  border: 1px solid var(--border);
}
.msg-wrap.mine .msg-bubble { background: var(--primary); color: #fff; border-color: transparent; border-radius: 18px 18px 4px 18px; }
.msg-wrap.theirs .msg-bubble { border-radius: 18px 18px 18px 4px; }
.msg-bubble.priority { border: 2px solid var(--amber-500); }
.msg-text { font-size: .9rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg-img { border-radius: 12px; max-width: 240px; max-height: 200px; object-fit: cover; cursor: pointer; margin-bottom: 6px; }
.msg-file { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; text-decoration: underline; }
.msg-wrap.mine .msg-file { color: rgba(255,255,255,.9); }
.msg-footer { display: flex; align-items: center; gap: 8px; margin-top: 4px; justify-content: flex-end; }
.msg-time { font-size: .7rem; opacity: .6; }
.msg-status { font-size: .75rem; opacity: .8; }
.ack-btn { font-size: .72rem; background: var(--amber-500); color: #fff; border: none;
           padding: 3px 10px; border-radius: 20px; font-weight: 700; cursor: pointer; }

/* ── Composer ─────────────────────────────────────────────── */
.composer { background: var(--surface); border-top: 1px solid var(--border); padding: 10px 12px; flex-shrink: 0; }
.composer-attachments { display: flex; align-items: center; gap: 8px; padding: 6px 0; flex-wrap: wrap; }
.composer-attachments.hidden { display: none !important; }
.attach-item { font-size: .82rem; }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer-attach { position: relative; }
.attach-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px; min-width: 140px; z-index: 50;
}
.attach-menu.hidden { display: none !important; }

.attach-opt { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer;
              border-radius: var(--radius-sm); font-size: .85rem; font-weight: 600; color: var(--text-2); }
.attach-opt:hover { background: var(--surface-2); }
.attach-opt svg { width: 18px; height: 18px; }
.composer-input {
  flex: 1; padding: 10px 14px; border: 2px solid var(--border);
  border-radius: 22px; background: var(--surface-2); color: var(--text);
  font-size: .9rem; resize: none; line-height: 1.4; max-height: 120px;
  transition: border-color .2s;
}
.composer-input:focus { outline: none; border-color: var(--primary); }
.send-btn {
  width: 42px; height: 42px; border-radius: 50%; border: none; flex-shrink: 0;
  background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center;
  transition: transform .15s, box-shadow .15s;
}
.send-btn svg { width: 18px; height: 18px; }
.send-btn:hover { transform: scale(1.08); box-shadow: var(--shadow); }

/* ── User Search Results ──────────────────────────────────── */
.user-results { max-height: 260px; overflow-y: auto; margin-top: 4px; }
.user-result { display: flex; align-items: center; gap: 10px; padding: 10px;
               cursor: pointer; border-radius: var(--radius-sm); }
.user-result:hover { background: var(--surface-2); }
.selected-user { background: var(--blue-50); border-radius: var(--radius-sm); }
[data-theme="dark"] .selected-user { background: rgba(59,130,246,.12); }

/* ── Priority Modal ──────────────────────────────────────── */
.priority-modal .priority-overlay { position: fixed; inset: 0; background: rgba(0,0,20,.85); z-index: 500; backdrop-filter: blur(4px); }
.priority-box {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: var(--surface); border-radius: 20px; padding: 32px;
  max-width: 420px; width: 90%; z-index: 501; text-align: center;
  border: 3px solid var(--amber-500); box-shadow: 0 0 60px rgba(245,158,11,.4);
}
.priority-header { margin-bottom: 16px; }
.priority-badge { background: var(--amber-500); color: #fff; padding: 6px 16px; border-radius: 20px; font-weight: 800; font-size: .9rem; }
.priority-body { font-size: 1rem; line-height: 1.6; margin: 16px 0; color: var(--text); }

/* ── Groups ───────────────────────────────────────────────── */
.groups-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.group-card {
  background: var(--surface); border-radius: var(--radius); padding: 20px;
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  border-top: 4px solid var(--gc, var(--primary));
  transition: transform .2s, box-shadow .2s;
}
.group-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.group-card.loading { min-height: 160px; animation: shimmer 1.5s infinite; }
.group-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.group-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--gc, var(--primary));
               color: #fff; font-weight: 800; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; }
.group-card-actions { display: flex; gap: 4px; }
.icon-btn.light { color: var(--text-muted); }
.group-name { font-size: 1rem; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.group-grade { font-size: .78rem; color: var(--primary); font-weight: 700; margin-bottom: 6px; }
.group-desc { font-size: .82rem; color: var(--text-muted); margin-bottom: 16px; }
.group-footer { display: flex; justify-content: space-between; align-items: center; font-size: .78rem; color: var(--text-muted); padding-top: 12px; border-top: 1px solid var(--border); }
.group-count { cursor: pointer; color: var(--primary); font-weight: 700; }
.members-list { display: flex; flex-direction: column; gap: 8px; }
.member-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); background: var(--surface-2); }
.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-opt { cursor: pointer; }
.color-opt input { display: none; }
.color-opt span { display: block; width: 28px; height: 28px; border-radius: 50%; transition: transform .15s, box-shadow .15s; }
.color-opt input:checked + span { transform: scale(1.2); box-shadow: 0 0 0 3px white, 0 0 0 5px var(--primary); }
.color-opt span:hover { transform: scale(1.1); }

/* ── Tables ───────────────────────────────────────────────── */
.admin-page { max-width: 1100px; margin: 0 auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px;
               margin-bottom: 20px; flex-wrap: wrap; }
.page-header h2 { font-size: 1.3rem; font-weight: 800; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); }
.search-wrap input { padding-left: 34px; }
.table-wrap { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; box-shadow: var(--shadow-sm); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 12px 14px; text-align: left; font-size: .78rem; font-weight: 800; text-transform: uppercase;
                  letter-spacing: .5px; color: var(--text-muted); background: var(--surface-2);
                  border-bottom: 1px solid var(--border); }
.data-table td { padding: 12px 14px; font-size: .88rem; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-2); }
.table-loading { text-align: center; color: var(--text-muted); padding: 32px; }
.table-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.table-avatar-initials { width: 34px; height: 34px; border-radius: 50%;
                          background: linear-gradient(135deg, var(--primary), var(--sky-500));
                          color: #fff; font-weight: 700; font-size: .85rem;
                          display: flex; align-items: center; justify-content: center; }
.user-cell { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.table-actions { display: flex; gap: 4px; }
.pagination { display: flex; gap: 6px; padding: 12px 14px; flex-wrap: wrap; }
.page-btn { padding: 6px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
            background: var(--surface-2); color: var(--text-2); font-weight: 700; font-size: .82rem; cursor: pointer; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Modals ───────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 400; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal.hidden { display: none; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(2px); }
.modal-box { position: relative; background: var(--surface); border-radius: var(--radius-lg);
              width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto;
              box-shadow: var(--shadow-lg); animation: modalIn .2s ease-out; }
@keyframes modalIn { from{opacity:0;transform:scale(.96)} to{opacity:1;transform:none} }
.modal-header { display: flex; align-items: center; justify-content: space-between;
                padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 1rem; font-weight: 800; }
.modal-body { padding: 20px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ── Profile ──────────────────────────────────────────────── */
.profile-avatar-wrap { position: relative; width: fit-content; margin: 0 auto 16px; }
.profile-avatar { width: 80px; height: 80px; border-radius: 50%; overflow: hidden; border: 3px solid var(--border); }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-initials.large { font-size: 1.8rem; }
.avatar-upload-btn { position: absolute; bottom: 0; right: -8px; width: 28px; height: 28px; border-radius: 50%;
                      background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.avatar-upload-btn svg { width: 14px; height: 14px; }
.profile-info { text-align: center; margin-bottom: 16px; }
.profile-name { font-size: 1.1rem; font-weight: 800; }
.profile-email { font-size: .85rem; color: var(--text-muted); }
.section-title { font-size: .85rem; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 12px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── Toast ────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  border-radius: var(--radius); box-shadow: var(--shadow-lg); font-weight: 700; font-size: .88rem;
  min-width: 240px; animation: toastIn .3s ease-out;
}
@keyframes toastIn { from{opacity:0;transform:translateX(20px)} to{opacity:1;transform:none} }
.toast-success { background: #d1fae5; color: #065f46; border-left: 4px solid var(--green-500); }
.toast-error   { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--red-500); }
.toast-info    { background: var(--blue-50); color: #1e40af; border-left: 4px solid var(--primary); }

/* ── Install Banner ──────────────────────────────────────── */
.install-banner {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 14px 18px;
  display: flex; align-items: center; gap: 12px; z-index: 200; max-width: 400px; width: 90%;
}
.install-banner.hidden { display: none; }
.install-icon { font-size: 1.8rem; }
.install-text { flex: 1; }
.install-text strong { display: block; font-size: .9rem; }
.install-text span { font-size: .78rem; color: var(--text-muted); }

/* ── Matrícula badge ──────────────────────────────────────── */
.matricula-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 700;
  padding: 3px 10px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--primary);
  letter-spacing: .5px;
}
.text-muted { color: var(--text-muted); }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state { text-align: center; color: var(--text-muted); padding: 24px; font-size: .88rem; }

/* ── Spinner ──────────────────────────────────────────────── */
.spinner-sm { width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--primary);
               border-radius: 50%; animation: spin2 .7s linear infinite; }
@keyframes spin2 { to { transform: rotate(360deg); } }

/* ── Lightbox ─────────────────────────────────────────────── */
.lightbox { position: fixed; inset: 0; z-index: 9000; background: rgba(0,0,0,.9);
             display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.lightbox img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: var(--radius-sm); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  .dash-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-overlay.active { display: block; }
  .sidebar-close { display: flex; }
  .hamburger { display: flex; }
  .main-content { margin-left: 0; }
  .conv-panel { width: 100%; position: absolute; z-index: 10; height: 100%; }
  .conv-panel.hidden-mobile { display: none; }
  .chat-area.full-mobile { position: absolute; inset: 0; z-index: 20; }
  .back-btn { display: flex; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-body { padding: 16px; }
  .header-actions { width: 100%; }
  .search-wrap, .search-wrap input { width: 100%; }
  .notif-panel { width: 100%; }
  .toast-container { left: 16px; right: 16px; bottom: 16px; }
  .toast { min-width: unset; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; }
  .quick-actions { grid-template-columns: 1fr 1fr; }
}

/* ── Safe area (iOS) ─────────────────────────────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
  .composer { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .sidebar  { padding-bottom: env(safe-area-inset-bottom); }
}

/* Icono sol en modo claro */
[data-theme="light"] #themeToggle .icon-sun {
  color: #f59e0b;
}

/* Icono luna en modo oscuro */
[data-theme="dark"] #themeToggle .icon-moon {
  color: #93c5fd;
}