/* ═══════════════════════════════════════════════════════════════
   TrainingManagement System — TMS.CSS  v2.0
   Bootstrap 5.3 loaded via CDN. This file: TMS-specific styles.
   ═══════════════════════════════════════════════════════════════ */

/* ── Design tokens ── */
:root {
  --sidebar-width: 240px;
  --sidebar-bg   : #1a2340;
  --sidebar-hover: #243058;
  --sidebar-active:#2e3d72;
  --accent       : #3b5bdb;
  --accent-light : #e8edff;
  --topbar-h     : 60px;
  --border       : #e5e9f0;
  --surface      : #f4f6fb;
  --text-main    : #1a2340;
  --text-muted   : #7b88a8;
  --radius       : 10px;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  background: var(--surface);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* ══════════════════════════════════
   SIDEBAR
══════════════════════════════════ */
#sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
  box-shadow: 2px 0 18px rgba(0,0,0,.18);
  overflow-y: auto;
  overflow-x: hidden;
}
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1039;
}

.sidebar-brand {
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-brand .brand-icon { color: #7c9bff; font-size: 22px; margin-right: 8px; }
.sidebar-brand .brand-title {
  color: #fff; font-size: 15px; font-weight: 700;
  line-height: 1.3; display: flex; align-items: center;
}
.sidebar-brand .brand-sub {
  color: rgba(255,255,255,.4); font-size: 10.5px;
  letter-spacing: .06em; text-transform: uppercase;
  margin-top: 3px; padding-left: 30px;
}
.nav-section-label {
  color: rgba(255,255,255,.3); font-size: 10px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 18px 20px 6px;
}
.sidebar-nav .nav-link {
  color: rgba(255,255,255,.7); padding: 9px 20px;
  border-radius: 7px; margin: 1px 10px; font-size: 13.5px;
  display: flex; align-items: center; gap: 10px;
  transition: background .15s, color .15s;
  cursor: pointer; text-decoration: none; border: none;
  background: none; width: calc(100% - 20px); text-align: left;
}
.sidebar-nav .nav-link:hover  { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--sidebar-active); color: #fff; }
.sidebar-nav .nav-link i { font-size: 16px; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-footer {
  margin-top: auto; padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.3); font-size: 11px; flex-shrink: 0;
}
.sidebar-footer a { color: rgba(255,255,255,.5); text-decoration: none; }
.sidebar-footer a:hover { color: #fff; }

/* ══════════════════════════════════
   TOP BAR
══════════════════════════════════ */
#topbar {
  position: fixed; top: 0;
  left: var(--sidebar-width); right: 0;
  height: var(--topbar-h);
  background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; z-index: 1030;
  transition: left .25s ease;
}
.topbar-title { font-size: 17px; font-weight: 600; color: var(--text-main); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; color: #5a6484; font-size: 17px;
  transition: background .15s;
}
.topbar-icon-btn:hover { background: #eaedf5; }
.topbar-icon-btn .dot {
  position: absolute; top: 4px; right: 4px;
  width: 9px; height: 9px; background: #e63757;
  border-radius: 50%; border: 2px solid #fff;
}
.avatar-circle {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; cursor: pointer; flex-shrink: 0;
}
#sidebar-toggle {
  display: none; background: none; border: none;
  font-size: 22px; color: var(--text-main);
  cursor: pointer; padding: 0; margin-right: 10px; line-height: 1;
}

/* ══════════════════════════════════
   GLOBAL SEARCH BAR
══════════════════════════════════ */
.global-search-wrap { position: relative; }
.global-search-wrap input {
  width: 220px; font-size: 13.5px;
  padding-left: 34px;
  border-color: var(--border);
  background: var(--surface);
  transition: width .2s;
}
.global-search-wrap input:focus { width: 280px; background: #fff; }
.global-search-wrap .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none; font-size: 14px;
}
#global-search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  min-width: 340px; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0,0,0,.13);
  z-index: 2000; max-height: 420px; overflow-y: auto;
}
.search-section-label {
  padding: 8px 14px 4px; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted);
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
.search-result-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; width: 100%;
  background: none; border: none; text-align: left; cursor: pointer;
  transition: background .12s;
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--accent-light); }
.sri-icon {
  width: 32px; height: 32px; border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.sri-title { font-size: 13px; font-weight: 600; color: var(--text-main); }
.sri-sub   { font-size: 11.5px; color: var(--text-muted); }
.sri-title mark { background: #fff3cd; border-radius: 2px; padding: 0 1px; }
.search-result-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: 13px; }
#search-overlay {
  position: fixed; inset: 0; z-index: 1999;
  background: transparent;
}

/* ══════════════════════════════════
   MAIN CONTENT
══════════════════════════════════ */
#main {
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-h);
  min-height: 100vh;
  transition: margin-left .25s ease;
}
.page-content { padding: 28px 28px 60px; }
.page         { display: none; }
.page.active  { display: block; animation: fadeInPage .18s ease; }
@keyframes fadeInPage { from { opacity:.5; transform:translateY(6px); } to { opacity:1; transform:none; } }

/* ══════════════════════════════════
   PAGE HEADER
══════════════════════════════════ */
.page-header { margin-bottom: 24px; }
.page-header h4 { font-weight: 700; color: var(--text-main); margin: 0; font-size: 20px; }
.page-header p  { color: var(--text-muted); font-size: 13.5px; margin: 4px 0 0; }

/* ══════════════════════════════════
   KPI CARDS
══════════════════════════════════ */
.kpi-card {
  background: #fff; border-radius: var(--radius);
  padding: 20px 22px; border: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; height: 100%;
  transition: box-shadow .15s;
}
.kpi-card:hover { box-shadow: 0 4px 16px rgba(59,91,219,.1); }
.kpi-icon {
  width: 52px; height: 52px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.kpi-label {
  font-size: 11.5px; color: var(--text-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
}
.kpi-value { font-size: 28px; font-weight: 700; color: var(--text-main); line-height: 1.1; }
.kpi-delta { font-size: 12px; margin-top: 3px; }
.kpi-delta.up   { color: #1a9e5c; }
.kpi-delta.down { color: #e63757; }

/* ══════════════════════════════════
   SECTION CARDS
══════════════════════════════════ */
.section-card {
  background: #fff; border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
}
.section-card .card-header-custom {
  padding: 13px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap; gap: 8px;
}
.section-card .card-header-custom h6 {
  margin: 0; font-weight: 700; font-size: 14px; color: var(--text-main);
}

/* ══════════════════════════════════
   STATUS / MODE BADGES
══════════════════════════════════ */
.badge-open      { background: #d4f5e5; color: #1a7a4a; }
.badge-closed    { background: #fde8e8; color: #b91c1c; }
.badge-draft     { background: #f1f3f9; color: #5a6484; }
.badge-completed { background: #e8edff; color: #3b5bdb; }
.badge-ilt       { background: #fff3cd; color: #856404; }
.badge-vilt      { background: #cff4fc; color: #055160; }
.badge-elearning { background: #f3e8ff; color: #6d28d9; }

/* ══════════════════════════════════
   DATA TABLE
══════════════════════════════════ */
.tms-table th {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted); background: #f8f9fc;
  border-bottom: 1px solid var(--border); padding: 10px 14px; white-space: nowrap;
}
.tms-table td {
  padding: 11px 14px; vertical-align: middle;
  font-size: 13.5px; color: #2d3555; border-color: #f0f2f8;
}
.tms-table tbody tr:hover { background: #f8f9fc; }
.tms-table .btn { white-space: nowrap; }

/* ══════════════════════════════════
   TRAINER CARDS
══════════════════════════════════ */
.trainer-card {
  background: #fff; border-radius: var(--radius); border: 1px solid var(--border);
  padding: 24px 20px; text-align: center; height: 100%;
  transition: box-shadow .15s;
}
.trainer-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.trainer-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #fff; margin: 0 auto 12px;
}
.trainer-name { font-weight: 700; font-size: 15px; color: var(--text-main); }
.trainer-spec { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.trainer-meta { font-size: 12px; color: #5a6484; margin-top: 10px; }
.trainer-meta span { display: inline-block; margin: 2px 4px; }

/* ══════════════════════════════════
   COURSE DETAIL BANNER
══════════════════════════════════ */
.course-detail-banner {
  background: linear-gradient(135deg, #1a2340 0%, #2e3d72 100%);
  border-radius: var(--radius); padding: 28px; color: #fff; margin-bottom: 20px;
}
.course-detail-banner .course-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.course-detail-banner .course-desc  { color: rgba(255,255,255,.75); font-size: 14px; max-width: 680px; line-height: 1.65; }
.course-stat-box { background: rgba(255,255,255,.1); border-radius: 8px; padding: 12px 16px; }
.course-stat-box .stat-label { font-size: 11px; color: rgba(255,255,255,.55); text-transform: uppercase; letter-spacing: .05em; }
.course-stat-box .stat-value { font-size: 18px; font-weight: 700; margin-top: 2px; }

/* ══════════════════════════════════
   ACTIVITY FEED
══════════════════════════════════ */
.activity-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f0f2f8; }
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.activity-text { font-size: 13px; color: #2d3555; }
.activity-time { font-size: 11.5px; color: #9ba5c0; margin-top: 2px; }

/* ══════════════════════════════════
   PROGRESS LABELS
══════════════════════════════════ */
.prog-label { display: flex; justify-content: space-between; font-size: 12px; color: #5a6484; margin-bottom: 4px; }

/* ══════════════════════════════════
   EMPTY STATE
══════════════════════════════════ */
.empty-state { padding: 48px 16px; }
.empty-state-icon { font-size: 48px; color: #d0d7e8; }

/* ══════════════════════════════════
   TOAST CONTAINER
══════════════════════════════════ */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999; display: flex; flex-direction: column; align-items: flex-end;
}

/* ══════════════════════════════════
   MODALS — form spacing
══════════════════════════════════ */
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); }
.modal-title  { font-weight: 700; font-size: 15px; color: var(--text-main); }
.form-label   { font-size: 13px; font-weight: 600; color: #3d4867; margin-bottom: 4px; }
.form-control, .form-select {
  font-size: 13.5px; border-color: var(--border);
  border-radius: 6px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,91,219,.12);
}

/* ══════════════════════════════════
   TOOLBAR ROW (search + filter + btns)
══════════════════════════════════ */
.toolbar-row {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 8px; margin-bottom: 16px;
}
.toolbar-row .toolbar-left  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.toolbar-row .toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-row .form-control,
.toolbar-row .form-select   { font-size: 13px; height: 34px; padding: 4px 10px; }
.toolbar-row input          { min-width: 180px; max-width: 240px; }

/* ══════════════════════════════════
   COUNT BADGE
══════════════════════════════════ */
.count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; border-radius: 20px; padding: 0 6px;
  background: var(--accent-light); color: var(--accent);
  font-size: 11.5px; font-weight: 700; margin-left: 6px;
}

/* ══════════════════════════════════
   CONFIRM MODAL
══════════════════════════════════ */
#confirmModal .modal-body { font-size: 14px; color: var(--text-main); }

/* ══════════════════════════════════
   RESPONSIVE — MOBILE (≤768px)
══════════════════════════════════ */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #sidebar-overlay.open { display: block; }
  #topbar { left: 0; }
  #sidebar-toggle { display: block; }
  #main { margin-left: 0; }
  .page-content { padding: 20px 14px 48px; }
  .global-search-wrap input { width: 150px; }
  .global-search-wrap input:focus { width: 200px; }
  .kpi-value { font-size: 24px; }
  .course-detail-banner { padding: 18px 14px; }
  .course-detail-banner .course-title { font-size: 17px; }
  .toolbar-row { gap: 6px; }
  #global-search-results { min-width: 280px; right: -20px; }
}
@media (max-width: 480px) {
  .topbar-title { font-size: 14px; }
  .page-header h4 { font-size: 17px; }
}
