/* ===========================
   VARIABLES & RESET
   =========================== */
:root {
  --blue-50:  #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;
  --blue-900: #1e3a8a;
  --indigo-600: #4f46e5;
  --cyan-500:  #06b6d4;
  --teal-500:  #14b8a6;

  --sidebar-w: 260px;
  --sidebar-collapsed-w: 68px;
  --topbar-h: 60px;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow:    0 4px 12px rgba(0,0,0,.10);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.14);

  --transition: .22s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: 'Segoe UI', system-ui, sans-serif; color: var(--text-primary); background: var(--bg-page); }
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }

/* ===========================
   LOGIN
   =========================== */
.login-body { background: linear-gradient(135deg, var(--blue-900) 0%, var(--blue-700) 50%, var(--cyan-500) 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }

.login-wrapper { display: flex; width: 900px; min-height: 560px; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-lg); }

.login-brand {
  flex: 1;
  background: linear-gradient(160deg, rgba(255,255,255,.08) 0%, rgba(255,255,255,.02) 100%);
  backdrop-filter: blur(8px);
  border-right: 1px solid rgba(255,255,255,.15);
  padding: 3rem 2.5rem;
  display: flex; align-items: center;
  color: #fff;
}
.brand-icon { font-size: 3rem; margin-bottom: 1.2rem; opacity: .9; }
.brand-content h1 { font-size: 1.9rem; font-weight: 700; line-height: 1.25; margin-bottom: .75rem; }
.brand-content p { opacity: .8; margin-bottom: 2rem; font-size: .95rem; }
.brand-features { display: flex; flex-direction: column; gap: .6rem; }
.brand-features li { display: flex; align-items: center; gap: .6rem; font-size: .88rem; opacity: .85; }
.brand-features i { color: var(--cyan-500); }

.login-form-panel { width: 400px; background: var(--bg-card); display: flex; align-items: center; justify-content: center; padding: 2.5rem; }

.login-card { width: 100%; }
.login-card-header { text-align: center; margin-bottom: 1.8rem; }
.login-avatar { width: 64px; height: 64px; background: linear-gradient(135deg, var(--blue-600), var(--indigo-600)); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.6rem; margin: 0 auto 1rem; }
.login-card-header h2 { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); }
.login-card-header p { color: var(--text-secondary); font-size: .88rem; margin-top: .3rem; }

.login-form { display: flex; flex-direction: column; gap: 1.1rem; }
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-group label { font-size: .82rem; font-weight: 600; color: var(--text-secondary); display: flex; align-items: center; gap: .4rem; }
.form-group input, .form-group select, .form-input {
  padding: .65rem .9rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: .93rem; transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--bg-card); color: var(--text-primary); width: 100%;
}
.form-group input:focus, .form-group select:focus, .form-input:focus {
  outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-100);
}
.input-password-wrap { position: relative; }
.input-password-wrap input { padding-right: 2.8rem; }
.toggle-pw { position: absolute; right: .7rem; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: .9rem; }

.btn-login {
  padding: .78rem; background: linear-gradient(135deg, var(--blue-600), var(--blue-700));
  color: #fff; border: none; border-radius: var(--radius-sm); font-size: .95rem; font-weight: 600;
  cursor: pointer; transition: opacity var(--transition), transform var(--transition);
  display: flex; align-items: center; justify-content: center; gap: .5rem; margin-top: .4rem;
}
.btn-login:hover { opacity: .92; transform: translateY(-1px); }

.login-footer-links { text-align: center; margin-top: 1.2rem; font-size: .85rem; }

/* ===========================
   ALERTS
   =========================== */
.alert { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; border-radius: var(--radius-sm); font-size: .88rem; margin-bottom: .8rem; }
.alert-danger  { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.alert-info    { background: var(--blue-50); color: var(--blue-700); border: 1px solid var(--blue-200); }
.alert-close { margin-left: auto; background: none; border: none; cursor: pointer; opacity: .6; font-size: .9rem; }

/* ===========================
   LAYOUT
   =========================== */
.app-body { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: linear-gradient(180deg, var(--blue-900) 0%, var(--blue-800) 100%);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh; z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-w); }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1rem; border-bottom: 1px solid rgba(255,255,255,.1);
  min-height: 64px;
}
.sidebar-logo { display: flex; align-items: center; gap: .7rem; color: #fff; font-weight: 700; font-size: 1.05rem; overflow: hidden; }
.sidebar-logo i { font-size: 1.3rem; color: var(--cyan-500); flex-shrink: 0; }
.sidebar-logo-text { white-space: nowrap; transition: opacity var(--transition); }
.sidebar.collapsed .sidebar-logo-text { opacity: 0; width: 0; }

.sidebar-toggle { background: none; border: none; color: rgba(255,255,255,.7); cursor: pointer; font-size: 1rem; padding: .3rem; border-radius: 4px; transition: color var(--transition); }
.sidebar-toggle:hover { color: #fff; }

.sidebar-nav { flex: 1; padding: .8rem 0; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }

.nav-item { position: relative; }
.nav-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem 1.1rem; color: rgba(255,255,255,.75); font-size: .88rem;
  transition: background var(--transition), color var(--transition);
  cursor: pointer; white-space: nowrap; overflow: hidden;
}
.nav-link:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(255,255,255,.15); color: #fff; font-weight: 600; }
.nav-link i:first-child { font-size: 1rem; flex-shrink: 0; width: 20px; text-align: center; }
.nav-link span { overflow: hidden; text-overflow: ellipsis; }
.submenu-arrow { margin-left: auto; font-size: .7rem; transition: transform var(--transition); flex-shrink: 0; }
.nav-item.has-submenu.open .submenu-arrow { transform: rotate(90deg); }

.submenu { background: rgba(0,0,0,.2); max-height: 0; overflow: hidden; transition: max-height .3s ease; }
.nav-item.has-submenu.open .submenu { max-height: 400px; }
.submenu .nav-link { padding-left: 2.5rem; font-size: .85rem; }

.sidebar.collapsed .nav-link span,
.sidebar.collapsed .submenu-arrow { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .submenu { max-height: 0 !important; }

.sidebar-user {
  display: flex; align-items: center; gap: .6rem;
  padding: .9rem 1rem; border-top: 1px solid rgba(255,255,255,.1); overflow: hidden;
}
.user-avatar-sm {
  width: 34px; height: 34px; background: linear-gradient(135deg, var(--blue-500), var(--indigo-600));
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .78rem; font-weight: 700; flex-shrink: 0;
}
.user-info-sm { flex: 1; overflow: hidden; }
.user-name-sm { display: block; color: #fff; font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role-sm { display: block; color: rgba(255,255,255,.55); font-size: .75rem; white-space: nowrap; }
.logout-btn { color: rgba(255,255,255,.6); font-size: .95rem; flex-shrink: 0; padding: .2rem .4rem; }
.logout-btn:hover { color: #fff; text-decoration: none; }
.sidebar.collapsed .user-info-sm { display: none; }

/* Main wrapper */
.main-wrapper { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; transition: margin-left var(--transition); }
.sidebar.collapsed ~ .main-wrapper { margin-left: var(--sidebar-collapsed-w); }

/* Topbar */
.topbar {
  height: var(--topbar-h); background: var(--bg-card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 1rem; padding: .4rem; border-radius: var(--radius-sm); }
.btn-icon:hover { background: var(--bg-page); color: var(--text-primary); }

.breadcrumb { display: flex; align-items: center; gap: .4rem; font-size: .82rem; }
.breadcrumb li { color: var(--text-muted); }
.breadcrumb li + li::before { content: "/"; margin-right: .4rem; }
.breadcrumb li.active { color: var(--text-primary); font-weight: 500; }
.breadcrumb a { color: var(--blue-600); }

.topbar-right { display: flex; align-items: center; gap: .75rem; }

/* ===========================
   BADGES
   =========================== */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 100px; font-size: .75rem; font-weight: 600; }
.badge-admin   { background: #ede9fe; color: #5b21b6; }
.badge-user    { background: var(--blue-50); color: var(--blue-700); }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: var(--blue-100); color: var(--blue-700); }
.badge-lg      { font-size: .88rem; padding: .3rem .9rem; }

/* ===========================
   CARDS
   =========================== */
.card { background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.4rem; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.card-body { padding: 1.4rem; }
.card-footer { padding: 1rem 1.4rem; border-top: 1px solid var(--border); }

/* Stats */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { border-radius: var(--radius); padding: 1.4rem; display: flex; align-items: center; gap: 1rem; color: #fff; box-shadow: var(--shadow); }
.stat-card--blue   { background: linear-gradient(135deg, var(--blue-600), var(--blue-700)); }
.stat-card--indigo { background: linear-gradient(135deg, var(--indigo-600), #4338ca); }
.stat-card--cyan   { background: linear-gradient(135deg, var(--cyan-500), #0891b2); }
.stat-card--teal   { background: linear-gradient(135deg, var(--teal-500), #0f766e); }
.stat-icon { font-size: 2rem; opacity: .85; }
.stat-label { font-size: .8rem; opacity: .85; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }

/* Quick links */
.quick-links-grid { display: flex; flex-wrap: wrap; gap: 1rem; }
.quick-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .6rem; padding: 1.5rem 2rem; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); color: var(--blue-600);
  font-size: .9rem; font-weight: 600; transition: all var(--transition); min-width: 160px;
}
.quick-card i { font-size: 1.8rem; }
.quick-card:hover { background: var(--blue-600); color: #fff; box-shadow: var(--shadow); transform: translateY(-2px); text-decoration: none; }

.section-divider { height: 1.5rem; }

/* ===========================
   PAGE LAYOUT
   =========================== */
.flash-container { padding: .8rem 1.5rem 0; }
.page-content { padding: 1.5rem; flex: 1; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.4rem; flex-wrap: wrap; gap: .8rem; }
.page-title { font-size: 1.35rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.page-subtitle { color: var(--text-secondary); font-size: .88rem; margin-top: .3rem; }
.mt-4 { margin-top: 1.5rem; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: .25rem; }
.label-sm { font-size: .8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: .5rem; }

/* ===========================
   BUTTONS
   =========================== */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1.1rem; border-radius: var(--radius-sm); font-size: .88rem; font-weight: 600; cursor: pointer; transition: all var(--transition); border: 1.5px solid transparent; }
.btn-primary { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }
.btn-primary:hover { background: var(--blue-700); border-color: var(--blue-700); }
.btn-outline { background: transparent; color: var(--blue-600); border-color: var(--blue-300, #93c5fd); }
.btn-outline:hover { background: var(--blue-50); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }

/* ===========================
   TABLES
   =========================== */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th { background: var(--bg-page); color: var(--text-secondary); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: .65rem 1rem; border-bottom: 2px solid var(--border); text-align: left; white-space: nowrap; }
.data-table td { padding: .7rem 1rem; border-bottom: 1px solid var(--border); color: var(--text-primary); }
.data-table tbody tr:hover { background: var(--bg-page); }
.data-table code { background: var(--blue-50); color: var(--blue-700); padding: .1rem .4rem; border-radius: 4px; font-size: .83rem; }

.table-toolbar { margin-bottom: 1rem; }
.input-search { padding: .55rem .9rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .88rem; width: 280px; transition: border-color var(--transition); }
.input-search:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-100); }

/* ===========================
   MODALS
   =========================== */
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.modal-backdrop.open { display: flex; }
.modal { background: var(--bg-card); border-radius: var(--radius-lg); width: 520px; max-width: 95vw; box-shadow: var(--shadow-lg); animation: slideIn .2s ease; }
@keyframes slideIn { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.2rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1rem; }
.modal-close:hover { color: var(--text-primary); }
.modal-form { padding: 1.4rem 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: .6rem; padding-top: .4rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-select { padding: .65rem .9rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .93rem; background: var(--bg-card); color: var(--text-primary); width: 100%; }
.form-select:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-100); }

/* ===========================
   ROLES PAGE
   =========================== */
.roles-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.2rem; }
.role-card .card-header { flex-direction: column; align-items: flex-start; }
.menus-checklist { display: flex; flex-direction: column; gap: .4rem; max-height: 280px; overflow-y: auto; }
.check-item { display: flex; align-items: center; gap: .5rem; cursor: pointer; padding: .3rem .5rem; border-radius: var(--radius-sm); transition: background var(--transition); }
.check-item:hover { background: var(--bg-page); }
.check-item input[type=checkbox] { accent-color: var(--blue-600); width: 15px; height: 15px; }
.check-label { display: flex; align-items: center; gap: .5rem; font-size: .88rem; }
.sub-tag { font-size: .7rem; background: var(--blue-100); color: var(--blue-600); padding: 0 .4rem; border-radius: 100px; }

/* ===========================
   FILTERS / CURSOS
   =========================== */
.filter-card .card-header { gap: 1rem; }
.filters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.filter-actions { display: flex; gap: .6rem; flex-wrap: wrap; padding-top: .5rem; border-top: 1px solid var(--border); margin-top: .5rem; }

/* ===========================
   TOAST
   =========================== */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast { display: flex; align-items: center; gap: .6rem; padding: .75rem 1.2rem; border-radius: var(--radius); box-shadow: var(--shadow); font-size: .88rem; min-width: 240px; animation: toastIn .2s ease; }
@keyframes toastIn { from { transform: translateX(60px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-success { background: #ecfdf5; color: #065f46; border-left: 4px solid #10b981; }
.toast-warning { background: #fffbeb; color: #92400e; border-left: 4px solid #f59e0b; }
.toast-error   { background: #fef2f2; color: #991b1b; border-left: 4px solid #ef4444; }

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-wrapper { margin-left: 0 !important; }
  .login-wrapper { flex-direction: column; width: 100%; min-height: 100vh; border-radius: 0; }
  .login-brand { padding: 2rem; }
  .login-form-panel { width: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .filters-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .filters-grid { grid-template-columns: 1fr; }
}

/* ===========================
   FILTRO ESPECIAL SIN CURSO
   =========================== */
.filter-special {
  margin: .75rem 0 .25rem;
  padding: .6rem 1rem;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: .75rem;
  cursor: pointer;
  user-select: none;
}
.toggle-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #f97316;
  cursor: pointer;
}
.toggle-text { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.toggle-text strong { color: #c2410c; }
.toggle-text small  { color: #9a3412; font-size: .75rem; opacity: .8; }

/* ===========================
   PROGRESS BAR MINI (tablas)
   =========================== */
.progress-bar-mini {
  display: flex;
  align-items: center;
  gap: .4rem;
  min-width: 100px;
}
.progress-bar-mini .progress-fill {
  height: 8px;
  background: var(--primary);
  border-radius: 4px;
  flex: 1;
  max-width: 80px;
  min-width: 4px;
}
.progress-bar-mini span {
  font-size: .8rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.text-muted { color: var(--text-muted); font-style: italic; }

/* ===========================
   ESTATUS EMPLEADO (Activo / Inactivo)
   Reutilizable en cualquier tabla del portal.
   =========================== */
.estatus-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .76rem;
  font-weight: 700;
  padding: .15rem .55rem;
  border-radius: 12px;
  white-space: nowrap;
}
.estatus-pill .estatus-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.estatus-pill.activo   { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.estatus-pill.activo   .estatus-dot { background: #16a34a; box-shadow: 0 0 0 2px rgba(22,163,74,.18); }
.estatus-pill.inactivo { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.estatus-pill.inactivo .estatus-dot { background: #dc2626; box-shadow: 0 0 0 2px rgba(220,38,38,.18); }
tr.row-inactivo > td   { background: #fafafa; color: #6b7280; }
