/* ══════════════════════════════════════════
   TalentLMS Admin — Design System
   Minimalista · Linear/Notion inspired
   ══════════════════════════════════════════ */

:root {
  /* Colors */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a26;
  --bg-elevated: #1e1e2e;
  --bg-hover: #252535;
  --bg-active: #2a2a3d;

  --border: #2a2a3a;
  --border-light: #1e1e30;
  --border-focus: #5b6ef5;

  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --text-muted: #5a5a70;
  --text-inverse: #0a0a0f;

  --accent: #5b6ef5;
  --accent-light: #7b8af8;
  --accent-dim: rgba(91, 110, 245, 0.15);
  --accent-glow: rgba(91, 110, 245, 0.3);

  --success: #34d399;
  --success-dim: rgba(52, 211, 153, 0.15);
  --warning: #fbbf24;
  --warning-dim: rgba(251, 191, 36, 0.15);
  --error: #f87171;
  --error-dim: rgba(248, 113, 113, 0.15);

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;

  /* Spacing */
  --sidebar-width: 260px;
  --header-height: 64px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;

  /* Transitions */
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── RESET ─────────────────────────────── */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
}

input {
  font-family: var(--font);
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
  outline: none;
}

/* ── LAYOUT ────────────────────────────── */

#app {
  display: flex;
  height: 100vh;
}

/* ── SIDEBAR ───────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-slow);
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border-light);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: white;
}

.logo h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.sidebar nav {
  padding: 12px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 450;
  color: var(--text-secondary);
  transition: all var(--transition);
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent-light);
}

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active svg {
  opacity: 1;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
}

.branch-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── MAIN ──────────────────────────────── */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── HEADER ────────────────────────────── */

.header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.menu-toggle {
  display: none;
  padding: 4px;
  color: var(--text-secondary);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
}

.header h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

/* ── CONTENT ───────────────────────────── */

.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.tab-panel {
  display: none;
  animation: fadeIn 200ms ease;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── TOOLBAR ───────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.search-box {
  flex: 1;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px;
  height: 40px;
  transition: border-color var(--transition);
}

.search-box:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.search-box svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  height: 100%;
  font-size: 13px;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

/* ── BUTTONS ───────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

.btn-ghost {
  color: var(--text-secondary);
  padding: 6px 10px;
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-success {
  background: var(--success);
  color: var(--text-inverse);
}

.btn-success:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 5px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ── TABLE ─────────────────────────────── */

.table-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody tr:last-child td {
  border-bottom: none;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.avatar-purple { background: rgba(139, 92, 246, 0.2); color: #a78bfa; }
.avatar-blue { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.avatar-green { background: rgba(52, 211, 153, 0.2); color: #34d399; }
.avatar-orange { background: rgba(251, 146, 60, 0.2); color: #fb923c; }
.avatar-pink { background: rgba(244, 114, 182, 0.2); color: #f472b6; }
.avatar-cyan { background: rgba(34, 211, 238, 0.2); color: #22d3ee; }

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}

.status-active {
  background: var(--success-dim);
  color: var(--success);
}

.status-inactive {
  background: var(--error-dim);
  color: var(--error);
}

.actions-cell {
  display: flex;
  gap: 4px;
}

.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 14px;
}

.empty-state .sub {
  font-size: 12px;
  margin-top: 4px;
}

/* ── LOADING ───────────────────────────── */

.loading-state {
  padding: 80px 24px;
  text-align: center;
  color: var(--text-muted);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-state p {
  font-size: 13px;
}

/* ── MODAL ─────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-slow);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-slow);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.modal-close {
  padding: 4px;
  color: var(--text-muted);
  border-radius: 4px;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── FORM ──────────────────────────────── */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-input {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  transition: all var(--transition);
}

.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-dim);
  outline: none;
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-select {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%235a5a70' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  transition: all var(--transition);
}

.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-dim);
  outline: none;
}

/* ── TOAST ─────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: 2000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 450;
  min-width: 280px;
  max-width: 420px;
  animation: toastIn 300ms ease forwards;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.toast.removing {
  animation: toastOut 200ms ease forwards;
}

.toast-success {
  background: #0d3320;
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: var(--success);
}

.toast-error {
  background: #3d1212;
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--error);
}

.toast-info {
  background: #1a1a3d;
  border: 1px solid rgba(91, 110, 245, 0.3);
  color: var(--accent-light);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* ── COURSE CARD ───────────────────────── */

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.course-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: all var(--transition);
}

.course-card:hover {
  border-color: var(--text-muted);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.course-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  line-height: 1.3;
}

.course-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.course-actions {
  display: flex;
  gap: 6px;
}

/* ── GROUP DETAIL ──────────────────────── */

.group-members {
  margin-top: 12px;
}

.member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}

.member-row:last-child {
  border-bottom: none;
}

/* ── COUNT BADGE ───────────────────────── */

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-hover);
  color: var(--text-secondary);
}

/* ── RESPONSIVE ────────────────────────── */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.5);
  }

  .menu-toggle {
    display: block;
  }

  .content {
    padding: 16px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    max-width: none;
  }

  .course-grid {
    grid-template-columns: 1fr;
  }

  table {
    font-size: 12px;
  }

  thead th,
  tbody td {
    padding: 10px 12px;
  }
}

/* ── TEMPLATE SELECTOR ─────────────────── */

.template-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.template-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: all var(--transition);
  background: var(--bg-tertiary);
}

.template-option:hover {
  border-color: var(--text-muted);
  background: var(--bg-hover);
}

.template-option.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.template-option input[type="radio"] {
  display: none;
}

/* ── TOGGLE SWITCH ─────────────────────── */

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}

.toggle-row:hover {
  background: var(--bg-hover);
}

.toggle-row:last-child {
  border-bottom: none;
}

.toggle-info {
  flex: 1;
  min-width: 0;
}

.toggle-name {
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toggle-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  margin-left: 16px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: var(--accent);
}

/* ── ADMIN STATS ───────────────────────── */

.admin-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  flex: 1;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 2px;
}

/* ── SCROLLBAR ─────────────────────────── */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
