/* ============================================================
   Sistema de Gestión Educativa - Instituto CEC - v2.0
   ============================================================ */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #64748b;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --purple: #7c3aed;
  --purple-light: #f5f3ff;
  --info: #0891b2;
  --info-light: #ecfeff;
  --teal: #0d9488;
  --teal-light: #f0fdfa;
  --orange: #ea580c;
  --orange-light: #fff7ed;
  --bg: #f1f5f9;
  --white: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-light: #64748b;
  --text-muted: #94a3b8;
  --sidebar-w: 240px;
  --topbar-h: 64px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.5; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }

/* ===== LOGIN ===== */
#login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #2563eb 100%);
  padding: 20px;
}
.login-card {
  background: white;
  border-radius: 16px;
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.login-logo { font-size: 26px; font-weight: 800; color: var(--primary); text-align: center; margin-bottom: 4px; }
.login-logo i { margin-right: 8px; }
.login-subtitle { text-align: center; color: var(--text-light); font-size: 13px; margin-bottom: 28px; }

/* ===== APP LAYOUT ===== */
#app-layout { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
#sidebar {
  width: var(--sidebar-w);
  background: #0f172a;
  color: white;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow: hidden;
}
.sidebar-logo { padding: 20px 18px 14px; border-bottom: 1px solid rgba(255,255,255,0.07); flex-shrink: 0; }
.sidebar-logo-title { font-size: 15px; font-weight: 700; color: white; display: flex; align-items: center; gap: 10px; }
.sidebar-logo-title i { background: var(--primary); padding: 8px; border-radius: 8px; font-size: 13px; }
.sidebar-logo-sub { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 3px; margin-left: 36px; }
.sidebar-nav { flex: 1; padding: 8px 8px; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
.sidebar-section { font-size: 10px; font-weight: 700; color: rgba(255,255,255,0.3); letter-spacing: 1px; text-transform: uppercase; padding: 14px 10px 5px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; cursor: pointer; color: rgba(255,255,255,0.6); font-size: 13px; font-weight: 500; transition: all 0.15s; margin-bottom: 2px; user-select: none; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-item.active { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(37,99,235,0.4); }
.nav-item i { width: 16px; text-align: center; font-size: 13px; flex-shrink: 0; }
.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,0.07); flex-shrink: 0; }
.btn-logout { width: 100%; padding: 8px; background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.6); border: 1px solid rgba(255,255,255,0.1); border-radius: 7px; cursor: pointer; font-size: 12px; transition: all 0.15s; display: flex; align-items: center; justify-content: center; gap: 6px; }
.btn-logout:hover { background: rgba(220,38,38,0.3); color: #fca5a5; border-color: rgba(220,38,38,0.4); }

/* ===== MAIN CONTENT ===== */
#main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }

/* ===== TOPBAR ===== */
#topbar { height: var(--topbar-h); background: white; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow); flex-shrink: 0; }
.topbar-title { font-size: 17px; font-weight: 700; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-info { display: flex; align-items: center; gap: 8px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.btn-icon { position: relative; width: 36px; height: 36px; border-radius: 8px; background: transparent; border: 1px solid var(--border); cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-light); transition: all 0.15s; }
.btn-icon:hover { background: var(--bg); color: var(--text); }
.notif-badge { position: absolute; top: -4px; right: -4px; background: var(--danger); color: white; border-radius: 10px; font-size: 10px; min-width: 18px; height: 18px; padding: 0 4px; display: flex; align-items: center; justify-content: center; font-weight: 700; border: 2px solid white; }

/* ===== PAGE CONTENT ===== */
#page-content { flex: 1; padding: 24px; overflow-y: auto; }
/* Modo chat: el scroll lo maneja el panel interno, no el contenedor */
#page-content.chat-mode { overflow: hidden; padding: 0; display: flex; flex-direction: column; }

/* ===== PAGE HEADER ===== */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-header-left h2 { font-size: 20px; font-weight: 700; color: var(--text); }
.page-header-left p { font-size: 13px; color: var(--text-light); margin-top: 2px; }

/* ===== CARDS ===== */
.card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); overflow: hidden; }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 14px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.card-body { padding: 18px; }

/* ===== STAT CARDS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
/* Stats inline en 3 columnas — usado en tarjetas de cursos del campus y similares */
.grid-inline-3-stat { display: grid; grid-template-columns: 1fr 1fr 1fr; }
.stat-card { background: white; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); border: 1px solid var(--border); transition: box-shadow 0.2s, transform 0.1s; cursor: default; }
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 8px; }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.purple { background: var(--purple-light); color: var(--purple); }
.stat-icon.teal { background: var(--teal-light); color: var(--teal); }
.stat-value { font-size: 24px; font-weight: 800; color: var(--text); line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text-light); font-weight: 500; }
.stat-change { font-size: 11px; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ===== DASHBOARD GRID ===== */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead { background: #f8fafc; }
th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-light); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
tr.row-danger td { background: #fff5f5; }
tr.row-danger:hover td { background: #fef2f2; }
tr.row-success td { background: #f0fdf4; }
tr.row-success:hover td { background: #dcfce7; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

/* ===== PAGINATION ===== */
.pagination { padding: 12px 16px; display: flex; align-items: center; justify-content: center; gap: 12px; border-top: 1px solid var(--border); background: #fafafa; }

/* ===== BADGES ===== */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-yellow { background: #fef9c3; color: #a16207; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-teal { background: #ccfbf1; color: #0f766e; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: none; cursor: pointer; font-size: 13px; font-weight: 600; transition: all 0.15s; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); box-shadow: 0 2px 8px rgba(37,99,235,0.35); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #e2e8f0; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover:not(:disabled) { background: #b45309; }
.btn-purple { background: var(--purple); color: white; }
.btn-purple:hover:not(:disabled) { background: #6d28d9; }
.btn-info { background: var(--info); color: white; }
.btn-info:hover:not(:disabled) { background: #0e7490; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 12px; padding: 0; text-decoration: underline; }

/* ===== ACTION BUTTONS ===== */
.action-btns { display: flex; gap: 4px; align-items: center; flex-wrap: nowrap; }
.btn-sm.btn-info, .btn-sm.btn-warning, .btn-sm.btn-success, .btn-sm.btn-danger, .btn-sm.btn-purple { padding: 5px 8px; }

/* ===== FORMS ===== */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-control { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; color: var(--text); background: white; transition: border-color 0.15s, box-shadow 0.15s; outline: none; width: 100%; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 11px; color: var(--text-muted); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.req { color: var(--danger); }

/* ===== SEARCH BAR ===== */
.search-bar { position: relative; }
.search-bar .form-control { padding-left: 36px; }
.search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; pointer-events: none; }
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ===== ALERTS ===== */
.alert { padding: 12px 14px; border-radius: 8px; font-size: 13px; display: flex; align-items: flex-start; gap: 8px; }
.alert i { flex-shrink: 0; margin-top: 1px; }
.alert-error { background: var(--danger-light); color: #b91c1c; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--primary-light); color: #1e40af; border: 1px solid #bfdbfe; }
.alert-success { background: var(--success-light); color: #15803d; border: 1px solid #bbf7d0; }

/* ===== MODALS ===== */
#modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(2px); }
#modal-overlay.open { display: flex; }
.modal-box { background: white; border-radius: 14px; max-width: 560px; width: 100%; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.2); animation: modalIn 0.2s ease-out; overflow: hidden; }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 900px; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(-10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; background: #fafafa; }
.modal-title { font-size: 15px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.modal-close { width: 30px; height: 30px; border-radius: 6px; border: none; background: transparent; cursor: pointer; color: var(--text-light); font-size: 14px; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.modal-close:hover { background: var(--danger-light); color: var(--danger); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

/* ===== NOTIFICATIONS ===== */
.notif-panel { position: absolute; top: calc(var(--topbar-h) + 4px); right: 20px; width: 360px; background: white; border-radius: 12px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); z-index: 150; max-height: 480px; overflow-y: auto; }
.notif-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 13px; position: sticky; top: 0; background: white; z-index: 1; }
.notif-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid #f1f5f9; display: flex; gap: 10px; transition: background 0.1s; cursor: default; }
.notif-item:hover { background: #fafafa; }
.notif-item.unread { background: #f0f7ff; }
.notif-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.notif-icon.blue { background: var(--primary-light); color: var(--primary); }
.notif-icon.green { background: var(--success-light); color: var(--success); }
.notif-icon.red { background: var(--danger-light); color: var(--danger); }
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-size: 13px; font-weight: 700; color: var(--text); }
.notif-msg { font-size: 12px; color: var(--text-light); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ===== TOAST ===== */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px; font-size: 13px; font-weight: 600; max-width: 340px; box-shadow: var(--shadow-lg); pointer-events: auto; animation: toastIn 0.3s ease-out; transition: opacity 0.3s; }
.toast.hide { opacity: 0; }
.toast.success { background: #15803d; color: white; }
.toast.error { background: #b91c1c; color: white; }
.toast.warning { background: #d97706; color: white; }
.toast.info { background: var(--primary); color: white; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ===== SPINNER ===== */
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; flex-shrink: 0; }
.spinner-lg { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px; gap: 14px; color: var(--text-light); font-size: 14px; }

/* ===== EMPTY STATE ===== */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; text-align: center; }
.empty-state-icon { width: 72px; height: 72px; border-radius: 20px; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 28px; color: var(--text-muted); margin-bottom: 16px; }
.empty-state-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-state-desc { font-size: 13px; color: var(--text-light); margin-bottom: 20px; max-width: 320px; }

/* ===== AVATAR ===== */
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }

/* ===== DETAIL GRID ===== */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.detail-item { background: #f8fafc; border-radius: 8px; padding: 10px 12px; }
.detail-item label { display: block; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 3px; }
.detail-item span { font-size: 13px; font-weight: 600; color: var(--text); }
.section-subtitle { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 10px; }

/* ===== GRID CARDS ===== */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* ===== CURSO CARDS ===== */
.curso-card { background: white; border-radius: var(--radius); border: 1px solid var(--border); padding: 18px; box-shadow: var(--shadow); transition: all 0.2s; }
.curso-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.curso-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.curso-icon { width: 42px; height: 42px; border-radius: 10px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.curso-nombre { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.curso-desc { font-size: 12px; color: var(--text-light); margin-bottom: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.curso-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; }
.curso-info-grid > div { font-size: 12px; color: var(--text-light); display: flex; align-items: center; gap: 5px; }
.curso-info-grid i { color: var(--primary); width: 12px; }
.curso-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ===== SEDE CARDS ===== */
.sede-card { background: white; border-radius: var(--radius); border: 1px solid var(--border); padding: 18px; box-shadow: var(--shadow); transition: all 0.2s; }
.sede-card:hover { box-shadow: var(--shadow-md); }
.sede-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sede-icon { width: 42px; height: 42px; border-radius: 10px; background: var(--purple-light); color: var(--purple); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.sede-nombre { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.sede-info { font-size: 12px; color: var(--text-light); display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.sede-info i { color: var(--purple); width: 12px; }

/* ===== USUARIOS TABS ===== */
.usr-tabs-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.usr-tab-btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; border-radius: 99px; border: 2px solid #e2e8f0; background: #f8fafc; color: #64748b; font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s; white-space: nowrap; }
.usr-tab-btn:hover { border-color: var(--tab-color, #6366f1); color: var(--tab-color, #6366f1); background: #fff; }
.usr-tab-btn.active { border-color: var(--tab-color, #6366f1); background: var(--tab-color, #6366f1); color: #fff; }
.usr-tab-btn i { font-size: 12px; }
.usr-tab-badge { background: rgba(255,255,255,.25); color: inherit; border-radius: 99px; padding: 1px 8px; font-size: 11px; font-weight: 700; }
.usr-tab-btn:not(.active) .usr-tab-badge { background: #e2e8f0; color: #64748b; }

/* ===== FILTER BAR (inline) ===== */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search-bar { position: relative; flex: 1; min-width: 180px; }
.search-bar .form-control { padding-left: 34px; }
.search-bar .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; pointer-events: none; }

/* ===== ACTION BUTTONS (compact table) ===== */
.action-btns { display: flex; gap: 4px; align-items: center; justify-content: flex-end; flex-wrap: nowrap; }

/* ===== INLINE BTN-SM (for table action buttons without .btn class) ===== */
.btn-sm.btn-success, a.btn-sm.btn-success { background: var(--success); color: white; padding: 5px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; border: none; display: inline-flex; align-items: center; gap: 4px; transition: all 0.15s; }
.btn-sm.btn-success:hover { background: #15803d; }
.btn-sm.btn-warning, a.btn-sm.btn-warning { background: var(--warning); color: white; }
.btn-sm.btn-warning:hover { background: #b45309; }
.btn-sm.btn-danger, a.btn-sm.btn-danger { background: var(--danger); color: white; }
.btn-sm.btn-danger:hover { background: #b91c1c; }
.btn-sm.btn-info, a.btn-sm.btn-info { background: var(--info); color: white; }
.btn-sm.btn-info:hover { background: #0e7490; }
.btn-sm.btn-purple, a.btn-sm.btn-purple { background: var(--purple); color: white; }
.btn-sm.btn-purple:hover { background: #6d28d9; }

/* Bare .btn-sm.btn-* without .btn parent - table use case */
button.btn-success:not(.btn) { background: var(--success); color: white; padding: 5px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; border: none; display: inline-flex; align-items: center; gap: 4px; transition: all 0.15s; }
button.btn-warning:not(.btn) { background: var(--warning); color: white; padding: 5px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; border: none; display: inline-flex; align-items: center; gap: 4px; transition: all 0.15s; }
button.btn-danger:not(.btn) { background: var(--danger); color: white; padding: 5px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; border: none; display: inline-flex; align-items: center; gap: 4px; transition: all 0.15s; }
button.btn-info:not(.btn) { background: var(--info); color: white; padding: 5px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; border: none; display: inline-flex; align-items: center; gap: 4px; transition: all 0.15s; }
button.btn-purple:not(.btn) { background: var(--purple); color: white; padding: 5px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; border: none; display: inline-flex; align-items: center; gap: 4px; transition: all 0.15s; }

/* ===== TABLE ROW STATES ===== */
tr.row-danger td { background: #fff5f5 !important; }
tr.row-success td { background: #f0fdf4 !important; }

/* ===== SPINNER LARGE ===== */
.spinner-lg { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; margin: 0 auto 12px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #main-content { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .grid-cards { grid-template-columns: 1fr; }
}

/* ============================================================
   HAMBURGER — Botón menú mobile + overlay sidebar
   ============================================================ */

/* El botón hamburguesa solo es visible en mobile */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 38px;
  height: 38px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 6px;
  transition: background .15s;
  flex-shrink: 0;
}
.hamburger:hover { background: var(--bg); }
.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all .2s;
  transform-origin: center;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Overlay oscuro cuando el sidebar está abierto en mobile */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
  backdrop-filter: blur(2px);
}
#sidebar-overlay.open { display: block; }

/* Sidebar abierto en mobile */
@media (max-width: 768px) {
  .hamburger { display: flex; }
  #sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.25); }
}

/* ============================================================
   RESPONSIVE MOBILE — Tablas con acciones y menú contextual
   ============================================================ */

/* ── Visibilidad condicional ── */
.hide-on-mobile  { display: flex !important; }
.show-on-mobile  { display: none !important; }

/* ── Botón "⋯" menú contextual (mobile) ── */
.btn-more-wrap {
  position: relative;
}
.btn-more {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 16px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  line-height: 1;
  transition: background .15s;
  letter-spacing: 2px;
}
.btn-more:hover { background: #e2e8f0; }

.btn-more-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.13);
  z-index: 500;
  min-width: 180px;
  padding: 6px;
  flex-direction: column;
  gap: 2px;
}
.btn-more-menu.open { display: flex; }

.btn-more-menu .btn,
.btn-more-menu button {
  width: 100%;
  justify-content: flex-start;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  color: #1e293b;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background .12s;
  white-space: nowrap;
}
.btn-more-menu .btn:hover,
.btn-more-menu button:hover { background: #f8fafc; }
.btn-more-menu .btn.btn-danger,
.btn-more-menu button.btn-danger { color: #dc2626; }
.btn-more-menu .btn.btn-danger:hover,
.btn-more-menu button.btn-danger:hover { background: #fef2f2; }

.menu-sep {
  height: 1px;
  background: #f1f5f9;
  margin: 4px 0;
}

/* ── Tabla responsiva: data-label en mobile ── */
@media (max-width: 768px) {
  /* page-content menos padding en mobile */
  #page-content { padding: 12px; }
  #page-content.chat-mode { padding: 0; overflow: hidden; }

  /* Topbar: ocultar texto largo, achicar padding */
  #topbar { padding: 0 12px; }
  .topbar-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }

  /* page-header: stack vertical en mobile */
  .page-header {
    flex-direction: column;
    gap: 10px;
  }
  .page-header > div:last-child {
    width: 100%;
  }
  .page-header > div:last-child .btn,
  .page-header > div:last-child button {
    flex: 1;
    justify-content: center;
  }

  /* page-title más pequeño */
  .page-title, h1.page-title { font-size: 17px !important; }

  /* Filtros: full width */
  .form-control { max-width: 100% !important; }

  /* Tabs que overflow: scroll horizontal */
  div[style*="width:fit-content"] {
    width: 100% !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Mostrar/ocultar para mobile */
  .hide-on-mobile  { display: none !important; }
  .show-on-mobile  { display: flex !important; }

  /* Tabla responsive con data-label */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; }

  table.table-responsive thead { display: none; }
  table.table-responsive tbody tr {
    display: flex;
    flex-direction: column;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-bottom: 10px;
    padding: 4px 0;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  }
  table.table-responsive tbody tr:hover { background: #fafafa; }
  table.table-responsive td {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 14px;
    border-bottom: 1px solid #f8fafc;
    font-size: 13px;
  }
  table.table-responsive td:last-child { border-bottom: none; }
  table.table-responsive td::before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: #94a3b8;
    min-width: 72px;
    flex-shrink: 0;
    padding-top: 2px;
    line-height: 1.4;
  }
  /* Celda de acciones: sin label, alineada a la derecha */
  table.table-responsive td.td-actions {
    justify-content: flex-end;
    padding: 10px 14px;
  }
  table.table-responsive td.td-actions::before { display: none; }

  /* Modal: pantalla completa en mobile */
  .modal-box, .modal-lg, .modal-xl {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 95vh;
    border-radius: 16px 16px 0 0;
    margin-top: auto;
  }
  #modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  /* Toast abajo centrado */
  #toast-container {
    bottom: 16px;
    right: 12px;
    left: 12px;
    align-items: center;
  }
  .toast { max-width: 100%; width: 100%; }

  /* Stats grid: 2 columnas en mobile */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* Ocultar columna de sede en superadmin (muy ancha) solo en pantallas chicas */
  table.table-responsive td[data-label="Sede"] { display: none; }
}

@media (max-width: 480px) {
  #page-content { padding: 8px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .card-body { padding: 12px; }
  .modal-body { padding: 14px; }

  /* En pantallas muy chicas, ocultar también Fecha y Tipo en tablas para priorizar info clave */
  table.table-responsive td[data-label="Fecha"] { display: none; }
}

/* ============================================================
   CAMPUS VIRTUAL - Estilos adicionales
   ============================================================ */

/* Tabs del campus */
.campus-tab {
  flex: 1;
  padding: 10px 16px;
  background: none;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.campus-tab:hover {
  background: rgba(99,102,241,0.08);
  color: #6366f1;
}
.campus-tab.active {
  background: #fff;
  color: #6366f1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* Animación pulse para clases en vivo */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 8px 40px rgba(16,185,129,0.5), 0 0 0 3px #10b981; }
  50%       { box-shadow: 0 8px 60px rgba(16,185,129,0.8), 0 0 0 6px #34d399; }
}

/* Avatar de autor en foro */
.foro-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}

/* Tarjeta de curso en campus */
.campus-curso-card {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border: 1px solid #f1f5f9;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.campus-curso-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.12);
}

/* Indicador en vivo */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  animation: pulse 1.5s ease-in-out infinite;
}

/* Sidebar del campus con gradiente diferente */
#campus-sidebar {
  background: linear-gradient(180deg, #1e3a5f 0%, #0f172a 100%);
}

/* ── Drag & Drop — Módulos y Materiales ────────────────────────────────────── */
.drag-handle-modulo,
.drag-handle-mat {
  cursor: grab !important;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
}
.drag-handle-modulo:hover,
.drag-handle-mat:hover {
  opacity: 1;
  color: #7c3aed !important;
}
.drag-handle-modulo:active,
.drag-handle-mat:active {
  cursor: grabbing !important;
}
.modulo-drag-item {
  transition: opacity 0.15s;
}
.modulo-drag-item.dragging {
  opacity: 0.4;
}
.mat-drag-item {
  transition: background 0.12s, opacity 0.15s;
}
.mat-drag-item:hover {
  background: #faf5ff;
}
.mat-drag-item.dragging {
  opacity: 0.4;
}

/* ── Chat HTML content: renderizado seguro en cualquier dispositivo ── */
.chat-html-content {
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.chat-html-content img {
  max-width: 100% !important;
  height: auto !important;
  display: block;
  border-radius: 6px;
}
.chat-html-content table {
  max-width: 100%;
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  overflow-x: auto;
  display: block;
}
.chat-html-content td,
.chat-html-content th {
  padding: 4px 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  white-space: normal;
}
.chat-html-content a {
  color: inherit;
  text-decoration: underline;
  word-break: break-all;
}
.chat-html-content p,
.chat-html-content ul,
.chat-html-content ol,
.chat-html-content h1,
.chat-html-content h2,
.chat-html-content h3,
.chat-html-content h4 {
  margin: 4px 0;
}
.chat-html-content * {
  max-width: 100% !important;
  box-sizing: border-box;
}
/* Burbuja HTML en mobile: usa todo el ancho disponible */
@media (max-width: 640px) {
  .msg-bubble-mine,
  .msg-bubble-other {
    max-width: calc(100vw - 48px) !important;
  }
}

/* ── Paginador de usuarios ───────────────────────────────────────── */
.usr-pg-btn {
  padding: 6px 11px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  line-height: 1;
}
.usr-pg-btn:hover:not(:disabled) {
  background: #eff6ff;
  border-color: #2563eb;
  color: #2563eb;
}
.usr-pg-btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  font-weight: 700;
}
.usr-pg-btn:disabled {
  opacity: .35;
  cursor: default;
}
@media (max-width: 480px) {
  .usr-pg-btn { padding: 5px 8px; font-size: 12px; }
}
