/* ═══════════════════════════════════════════════════
   Elo Hub Admin Panel — Shared Stylesheet
   ═══════════════════════════════════════════════════ */

/* ─── Variables ─────────────────────────────────── */
:root {
  --sidebar-w: 250px;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e3a5f;
  --sidebar-active: #1d4ed8;
  --sidebar-text: rgba(255,255,255,.7);
  --sidebar-text-active: #fff;
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --page-bg: #f1f5f9;
  --card-bg: #ffffff;
  --topbar-bg: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --success: #10b981;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --info: #06b6d4;
  --info-light: #cffafe;
  --purple: #8b5cf6;
  --purple-light: #ede9fe;
  --radius: .625rem;
  --radius-lg: 1rem;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 12px rgba(0,0,0,.06), 0 2px 6px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
  --transition: all .2s cubic-bezier(.4,0,.2,1);
}

/* ─── Reset & Base ───────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', Tahoma, 'Helvetica Neue', Arial, sans-serif;
  background: var(--page-bg);
  color: var(--text-primary);
  font-size: .9375rem;
  line-height: 1.6;
}

/* ─── Layout ─────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }

#main {
  margin-right: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.content { padding: 1.5rem; flex: 1; }

/* ─── Sidebar ────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.sidebar-brand-logo {
  display: flex;
  align-items: center;
  gap: .625rem;
  text-decoration: none;
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-radius: .5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-brand-text {
  color: #fff;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.2;
}

.sidebar-brand-subtitle {
  color: rgba(255,255,255,.4);
  font-size: .7rem;
  font-weight: 400;
  display: block;
}

#sidebar-nav {
  padding: .75rem .625rem;
  flex: 1;
}

#sidebar-nav .nav-section {
  color: rgba(255,255,255,.3);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .75rem .75rem .25rem;
  margin-top: .25rem;
}

#sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem .875rem;
  color: var(--sidebar-text);
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
  margin-bottom: .125rem;
}

#sidebar-nav .nav-link i {
  font-size: 1rem;
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
  opacity: .75;
  transition: var(--transition);
}

#sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,.07);
  color: var(--sidebar-text-active);
}

#sidebar-nav .nav-link:hover i { opacity: 1; }

#sidebar-nav .nav-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  box-shadow: 0 2px 8px rgba(37,99,235,.4);
}

#sidebar-nav .nav-link.active i { opacity: 1; }

.sidebar-footer {
  padding: .875rem .625rem;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .625rem .875rem;
  border-radius: var(--radius);
  margin-bottom: .5rem;
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,.12);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-size: .875rem;
}

.sidebar-user-name {
  color: rgba(255,255,255,.85);
  font-size: .8125rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  width: 100%;
  background: rgba(239,68,68,.12);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,.2);
  padding: .5rem .875rem;
  border-radius: var(--radius);
  font-size: .8125rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}

.btn-logout:hover {
  background: rgba(239,68,68,.22);
  color: #f87171;
  border-color: rgba(239,68,68,.3);
}

/* ─── Topbar ─────────────────────────────────────── */
.topbar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  padding: .875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.topbar-title i { color: var(--accent); font-size: 1.125rem; }

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

.topbar-greeting {
  color: var(--text-secondary);
  font-size: .8125rem;
}

/* ─── Page Header ────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: .75rem;
}

.page-header-left { display: flex; flex-direction: column; gap: .125rem; }

.page-header h4 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.page-header .page-subtitle {
  font-size: .8125rem;
  color: var(--text-secondary);
}

/* ─── Cards ──────────────────────────────────────── */
.card-panel {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.card-panel-title {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.card-panel-body { padding: 1.25rem; }
.card-panel-body.no-pad { padding: 0; }

/* ─── Stat Cards ─────────────────────────────────── */
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.stat-icon.blue { background: var(--accent-light); color: var(--accent); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.amber { background: var(--warning-light); color: var(--warning); }
.stat-icon.cyan { background: var(--info-light); color: var(--info); }
.stat-icon.purple { background: var(--purple-light); color: var(--purple); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }

.stat-content { flex: 1; min-width: 0; }

.stat-value {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -.02em;
}

.stat-label {
  font-size: .8125rem;
  color: var(--text-secondary);
  margin-top: .125rem;
}

/* ─── Filters Bar ────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: .625rem;
  flex-wrap: wrap;
  padding: .875rem 1.25rem;
  background: var(--border-light);
  border-bottom: 1px solid var(--border);
}

.filters-bar .form-control,
.filters-bar .form-select {
  font-size: .875rem;
  border-color: var(--border);
  border-radius: var(--radius);
  padding: .4375rem .75rem;
  height: auto;
}

.filters-bar .form-control:focus,
.filters-bar .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* ─── Tables ─────────────────────────────────────── */
.table-responsive { overflow-x: auto; }

.data-table { margin: 0; width: 100%; border-collapse: collapse; }

.data-table thead tr {
  background: var(--border-light);
  border-bottom: 2px solid var(--border);
}

.data-table thead th {
  font-size: .78125rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .75rem 1rem;
  white-space: nowrap;
  border: none;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background .12s;
}

.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbff; }

.data-table tbody td {
  padding: .8125rem 1rem;
  font-size: .875rem;
  vertical-align: middle;
  border: none;
  color: var(--text-primary);
}

.data-table .td-muted { color: var(--text-secondary); font-size: .8125rem; }
.data-table .td-code { font-family: 'Consolas', monospace; font-size: .8125rem; }

/* ─── Skeleton Loading ───────────────────────────── */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(90deg, #e8ecf0 25%, #f5f6f8 50%, #e8ecf0 75%);
  background-size: 800px 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: 4px;
  display: inline-block;
}

/* ─── Badges ─────────────────────────────────────── */
.badge-pill {
  padding: .3125rem .6875rem;
  border-radius: 100px;
  font-size: .75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  white-space: nowrap;
}

.badge-pill.success { background: var(--success-light); color: #059669; }
.badge-pill.danger { background: var(--danger-light); color: #dc2626; }
.badge-pill.warning { background: var(--warning-light); color: #d97706; }
.badge-pill.info { background: var(--info-light); color: #0891b2; }
.badge-pill.purple { background: var(--purple-light); color: #7c3aed; }
.badge-pill.neutral { background: #f1f5f9; color: #475569; }
.badge-pill.blue { background: var(--accent-light); color: var(--accent); }

.badge-count {
  background: var(--accent-light);
  color: var(--accent);
  padding: .1875rem .5rem;
  border-radius: 100px;
  font-size: .75rem;
  font-weight: 700;
}

/* ─── Action Buttons (in tables) ─────────────────── */
.btn-action {
  padding: .3125rem .6875rem;
  font-size: .8125rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  line-height: 1.4;
  white-space: nowrap;
}

.btn-action.edit {
  background: var(--accent-light);
  color: var(--accent);
  border-color: rgba(37,99,235,.15);
}

.btn-action.edit:hover {
  background: var(--accent);
  color: #fff;
}

.btn-action.danger {
  background: var(--danger-light);
  color: var(--danger);
  border-color: rgba(239,68,68,.15);
}

.btn-action.danger:hover {
  background: var(--danger);
  color: #fff;
}

/* ─── Pagination ─────────────────────────────────── */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .875rem 1.25rem;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
  gap: .5rem;
}

.pagination-info {
  font-size: .8125rem;
  color: var(--text-secondary);
}

.pagination-nav {
  display: flex;
  gap: .25rem;
  align-items: center;
}

.page-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: .8125rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  padding: 0;
}

.page-btn:hover:not(:disabled) {
  background: var(--accent-light);
  color: var(--accent);
  border-color: rgba(37,99,235,.2);
}

.page-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.page-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* ─── Toasts ─────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 1rem;
  right: calc(var(--sidebar-w) + 1rem);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: 340px;
}

.toast-item {
  display: flex;
  align-items: flex-start;
  gap: .625rem;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s cubic-bezier(.34,1.56,.64,1);
  font-size: .875rem;
  line-height: 1.4;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast-item.success { background: #fff; border-right: 3px solid var(--success); color: var(--text-primary); }
.toast-item.error { background: #fff; border-right: 3px solid var(--danger); color: var(--text-primary); }
.toast-item.info { background: #fff; border-right: 3px solid var(--accent); color: var(--text-primary); }

.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: .0625rem; }
.toast-item.success .toast-icon { color: var(--success); }
.toast-item.error .toast-icon { color: var(--danger); }
.toast-item.info .toast-icon { color: var(--accent); }

/* ─── Confirm Modal ──────────────────────────────── */
.confirm-modal-icon {
  width: 56px;
  height: 56px;
  background: var(--danger-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto .875rem;
  color: var(--danger);
  font-size: 1.5rem;
}

.confirm-modal-icon.warning {
  background: var(--warning-light);
  color: var(--warning);
}

/* ─── Forms (in modals) ──────────────────────────── */
.form-label {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: .3125rem;
}

.form-label .optional {
  font-weight: 400;
  color: var(--text-muted);
  font-size: .75rem;
}

.form-control, .form-select {
  border-color: var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--text-primary);
  padding: .5rem .75rem;
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  outline: none;
}

/* ─── Empty State ────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: .875rem;
  opacity: .4;
  color: var(--text-muted);
}

.empty-state-title {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: .25rem;
}

.empty-state-subtitle {
  font-size: .8125rem;
  color: var(--text-muted);
}

/* ─── Tabs ───────────────────────────────────────── */
.custom-tabs {
  display: flex;
  gap: .25rem;
  background: var(--border-light);
  border-radius: var(--radius);
  padding: .25rem;
  width: fit-content;
  margin-bottom: 1.25rem;
}

.custom-tab-btn {
  padding: .4375rem 1rem;
  border-radius: calc(var(--radius) - 2px);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: .375rem;
}

.custom-tab-btn.active {
  background: var(--card-bg);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ─── Semester Control (Dashboard) ──────────────── */
.semester-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.semester-card-year {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: .625rem;
  display: flex;
  align-items: center;
  gap: .375rem;
}

.sem-toggle {
  display: flex;
  background: var(--border-light);
  border-radius: var(--radius);
  padding: .1875rem;
  gap: .1875rem;
}

.sem-btn {
  flex: 1;
  padding: .4375rem .5rem;
  border: none;
  background: transparent;
  border-radius: calc(var(--radius) - 3px);
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.sem-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px rgba(37,99,235,.3);
}

.sem-btn:not(.active):hover { background: rgba(0,0,0,.05); }

/* ─── Quick Links ────────────────────────────────── */
.quick-link {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-primary);
  transition: var(--transition);
  border-bottom: 1px solid var(--border-light);
  font-size: .875rem;
}

.quick-link:last-child { border-bottom: none; }

.quick-link:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.quick-link i {
  width: 32px;
  height: 32px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9375rem;
  flex-shrink: 0;
  transition: var(--transition);
}

.quick-link:hover i { background: var(--accent); color: #fff; }

/* ─── Primary Button ─────────────────────────────── */
.btn-primary-custom {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: .5625rem 1.125rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: .375rem;
}

.btn-primary-custom:hover { background: #1d4ed8; transform: translateY(-1px); box-shadow: 0 3px 10px rgba(37,99,235,.3); }
.btn-primary-custom:active { transform: translateY(0); }
.btn-primary-custom:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* ─── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── Utilities ──────────────────────────────────── */
.gap-2 { gap: .5rem; }
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── Animations ─────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in { animation: fadeIn .2s ease; }
