/* ═══════════════════════════════════════════════════
   CommandHQ — SaaS Admin Panel Design System
   A premium admin/back-office template
   ═══════════════════════════════════════════════════ */

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

/* ── Tokens ── */
:root {
  /* Colors — Slate professional palette with emerald accents */
  --bg-primary:      #0f1117;
  --bg-secondary:    #161921;
  --bg-tertiary:     #1e2130;
  --bg-elevated:     #262a3a;
  --bg-hover:        #2d3244;
  --bg-input:        #1a1d28;

  --surface-glass:   rgba(255, 255, 255, 0.03);
  --surface-glass-hover: rgba(255, 255, 255, 0.06);

  --text-primary:    #eaeaf0;
  --text-secondary:  #8b8da0;
  --text-tertiary:   #5c5e72;
  --text-inverse:    #0f1117;

  --accent-primary:  #10b981;
  --accent-light:    #34d399;
  --accent-dark:     #059669;
  --accent-glow:     rgba(16, 185, 129, 0.2);
  --accent-subtle:   rgba(16, 185, 129, 0.1);

  --blue:            #3b82f6;
  --blue-subtle:     rgba(59, 130, 246, 0.12);
  --red:             #ef4444;
  --red-subtle:      rgba(239, 68, 68, 0.12);
  --amber:           #f59e0b;
  --amber-subtle:    rgba(245, 158, 11, 0.12);
  --purple:          #8b5cf6;
  --purple-subtle:   rgba(139, 92, 246, 0.12);
  --cyan:            #06b6d4;

  --border:          rgba(255, 255, 255, 0.07);
  --border-strong:   rgba(255, 255, 255, 0.12);
  --border-accent:   rgba(16, 185, 129, 0.3);

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

  --text-xs:   0.75rem;
  --text-sm:   0.8125rem;
  --text-base: 0.875rem;
  --text-lg:   1.125rem;
  --text-xl:   1.375rem;
  --text-2xl:  1.75rem;
  --text-3xl:  2.25rem;

  /* Spacing */
  --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem;
  --s-4: 1rem; --s-5: 1.25rem; --s-6: 1.5rem;
  --s-8: 2rem; --s-10: 2.5rem; --s-12: 3rem;
  --s-16: 4rem;

  /* Radius */
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px;
  --r-xl: 16px; --r-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 16px var(--accent-glow);

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed: 68px;
  --header-height: 56px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

html { font-size: 16px; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;
}
a { color: var(--accent-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App Shell ── */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}

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

.main__header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s-6);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.main__content {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-6);
  scrollbar-width: thin;
  scrollbar-color: var(--bg-elevated) transparent;
}
.main__content::-webkit-scrollbar { width: 6px; }
.main__content::-webkit-scrollbar-track { background: transparent; }
.main__content::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: var(--r-full); }

/* ── Sidebar ── */
.sidebar__header {
  height: var(--header-height);
  padding: 0 var(--s-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--text-primary);
}

.sidebar__logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-dark));
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
}

.sidebar__nav { flex: 1; padding: var(--s-3); overflow-y: auto; }

.sidebar__section {
  margin-bottom: var(--s-4);
}

.sidebar__label {
  padding: var(--s-2) var(--s-3);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

.sidebar__item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  text-decoration: none;
}
.sidebar__item:hover { background: var(--surface-glass-hover); color: var(--text-primary); text-decoration: none; }
.sidebar__item.active { background: var(--accent-subtle); color: var(--accent-light); }

.sidebar__item-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.6; }
.sidebar__item.active .sidebar__item-icon { opacity: 1; }

.sidebar__item-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--r-full);
  min-width: 20px;
  text-align: center;
}

.sidebar__footer {
  border-top: 1px solid var(--border);
  padding: var(--s-3);
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.15s var(--ease);
}
.sidebar__user:hover { background: var(--surface-glass-hover); }

.sidebar__avatar {
  width: 34px; height: 34px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--accent-primary), var(--blue));
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: var(--text-sm); color: white;
}

.sidebar__user-info { flex: 1; min-width: 0; }
.sidebar__username { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.sidebar__role { font-size: var(--text-xs); color: var(--text-tertiary); }

/* ── Header ── */
.header__left { display: flex; align-items: center; gap: var(--s-4); }

.header__breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.header__breadcrumb-sep { color: var(--text-tertiary); }
.header__breadcrumb-current { color: var(--text-primary); font-weight: 600; }

.header__right { display: flex; align-items: center; gap: var(--s-3); }

.header__search {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3);
  width: 240px;
}

.header__search input {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: var(--text-sm);
  outline: none;
  width: 100%;
}
.header__search input::placeholder { color: var(--text-tertiary); }

.header__icon-btn {
  position: relative;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: var(--s-2);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.header__icon-btn:hover { background: var(--surface-glass-hover); color: var(--text-primary); }

.header__notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--red);
  border-radius: var(--r-full);
  border: 2px solid var(--bg-secondary);
}

/* ── Page Layout ── */
.page__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-6);
}

.page__title {
  font-size: var(--text-xl);
  font-weight: 700;
}

.page__subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--s-1);
}

.page__actions { display: flex; gap: var(--s-2); }

/* ── Cards ── */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-4);
}

.card__title {
  font-size: var(--text-base);
  font-weight: 600;
}

/* ── Stats ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-4);
  margin-bottom: var(--s-6);
}

.stat {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}

.stat__icon {
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--s-3);
}

.stat__label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
  margin-bottom: var(--s-1);
}

.stat__value {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.2;
}

.stat__change {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--text-xs);
  font-weight: 500;
  margin-top: var(--s-2);
  padding: 2px 8px;
  border-radius: var(--r-full);
}
.stat__change--up { background: var(--accent-subtle); color: var(--accent-light); }
.stat__change--down { background: var(--red-subtle); color: var(--red); }

/* ── Tables ── */
.table-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.table-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
}

.table-card__title { font-size: var(--text-base); font-weight: 600; }

.table-card__actions { display: flex; gap: var(--s-2); }

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

th {
  text-align: left;
  padding: var(--s-3) var(--s-5);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
}

td {
  padding: var(--s-3) var(--s-5);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-glass); }

.table__user {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.table__user-avatar {
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: var(--text-xs); color: white;
  flex-shrink: 0;
}

.table__user-name { font-weight: 500; color: var(--text-primary); }
.table__user-email { font-size: var(--text-xs); color: var(--text-tertiary); }

.table__actions {
  display: flex;
  gap: var(--s-1);
}

.table__action-btn {
  background: none; border: none;
  color: var(--text-tertiary);
  padding: var(--s-1);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.table__action-btn:hover { background: var(--surface-glass-hover); color: var(--text-primary); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: 500;
}
.badge--green   { background: var(--accent-subtle); color: var(--accent-light); }
.badge--red     { background: var(--red-subtle); color: var(--red); }
.badge--amber   { background: var(--amber-subtle); color: var(--amber); }
.badge--blue    { background: var(--blue-subtle); color: var(--blue); }
.badge--purple  { background: var(--purple-subtle); color: var(--purple); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  font-family: var(--font-sans);
}
.btn--primary {
  background: var(--accent-primary);
  color: white;
}
.btn--primary:hover { background: var(--accent-dark); box-shadow: var(--shadow-glow); }

.btn--secondary {
  background: var(--surface-glass);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn--secondary:hover { background: var(--surface-glass-hover); border-color: var(--border-strong); }

.btn--danger { background: var(--red-subtle); color: var(--red); }
.btn--danger:hover { background: rgba(239, 68, 68, 0.2); }

.btn--sm { padding: var(--s-1) var(--s-3); font-size: var(--text-xs); }
.btn--icon {
  width: 32px; height: 32px;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
  background: var(--surface-glass);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
}
.btn--icon:hover { background: var(--surface-glass-hover); color: var(--text-primary); }

/* ── Forms ── */
.input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  outline: none;
  width: 100%;
  transition: border-color 0.2s var(--ease);
}
.input:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-subtle); }
.input::placeholder { color: var(--text-tertiary); }

.select {
  appearance: none;
  background: var(--bg-input) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235c5e72' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-2) var(--s-8) var(--s-2) var(--s-3);
  color: var(--text-primary);
  font-size: var(--text-sm);
  cursor: pointer;
  outline: none;
}
.select:focus { border-color: var(--accent-primary); }

.checkbox {
  width: 16px; height: 16px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--bg-input);
  cursor: pointer;
  accent-color: var(--accent-primary);
}

.toggle {
  position: relative;
  width: 40px; height: 22px;
  background: var(--bg-elevated);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background 0.2s var(--ease);
}
.toggle.active { background: var(--accent-primary); }
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: white;
  border-radius: var(--r-full);
  transition: transform 0.2s var(--ease);
}
.toggle.active::after { transform: translateX(18px); }

/* ── Tabs ── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: var(--s-1);
  margin-bottom: var(--s-5);
}
.tab {
  padding: var(--s-3) var(--s-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: none; border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent-light); border-bottom-color: var(--accent-primary); }

/* ── Filters Bar ── */
.filters {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}

.filters__search {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.filters__search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
}
.filters__search input {
  padding-left: 32px;
}

/* ── Activity Log ── */
.activity-item {
  display: flex;
  gap: var(--s-4);
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }

.activity-item__icon {
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.activity-item__content { flex: 1; min-width: 0; }
.activity-item__text { font-size: var(--text-sm); line-height: 1.5; }
.activity-item__text strong { color: var(--text-primary); font-weight: 600; }
.activity-item__time { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 2px; }

/* ── Progress Bar ── */
.progress { margin-bottom: var(--s-4); }
.progress__header {
  display: flex; justify-content: space-between;
  font-size: var(--text-xs); margin-bottom: var(--s-1);
}
.progress__label { color: var(--text-secondary); }
.progress__value { font-weight: 600; color: var(--text-primary); }
.progress__bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  border-radius: var(--r-full);
  transition: width 0.5s var(--ease);
}

/* ── Grid Layouts ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--s-4); }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border);
}
.pagination__info { font-size: var(--text-xs); color: var(--text-tertiary); }
.pagination__btns { display: flex; gap: var(--s-2); }

/* ── Modal styles ── */
.modal-preview {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  max-width: 520px;
  margin: var(--s-8) auto;
  overflow: hidden;
}
.modal-preview__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-5);
  border-bottom: 1px solid var(--border);
}
.modal-preview__body { padding: var(--s-5); }
.modal-preview__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
}

/* ── Role permission grid ── */
.perm-grid {
  display: grid;
  grid-template-columns: 180px repeat(4, 1fr);
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.perm-grid__cell {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.perm-grid__cell:nth-child(5n) { border-right: none; }
.perm-grid__cell--header {
  background: var(--bg-tertiary);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}
.perm-grid__cell--label {
  justify-content: flex-start;
  font-weight: 500;
  color: var(--text-primary);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .stats-row { grid-template-columns: 1fr; }
}
