/* ============================================================
   public/css/system-admin.css — System Administration Styles
   ============================================================ */

/* ── Tab Navigation ─────────────────────────────────────────── */
.sysadmin-tabs {
  display: flex;
  gap: 4px;
  background: var(--card2, #1a1d23);
  border: 1px solid var(--border, #2a2d35);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 24px;
}

.sysadmin-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted, #8b8fa3);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sysadmin-tab:hover {
  color: var(--text, #e4e6eb);
  background: rgba(255,255,255,0.04);
}

.sysadmin-tab.active {
  background: var(--accent, #6c5ce7);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

.sysadmin-tab .tab-icon {
  font-size: 16px;
}

/* ── Panel Show/Hide ────────────────────────────────────────── */
.sysadmin-panel {
  display: none;
}
.sysadmin-panel.active {
  display: block;
  animation: fadeSlideIn 0.3s ease;
}

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

/* ── Stats Bar ──────────────────────────────────────────────── */
.sysadmin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card2, #1a1d23);
  border: 1px solid var(--border, #2a2d35);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  transition: border-color 0.2s;
}

.stat-card:hover {
  border-color: var(--accent, #6c5ce7);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text, #e4e6eb);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--muted, #8b8fa3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Action Bar ─────────────────────────────────────────────── */
.sysadmin-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.action-left {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
}

.sysadmin-search {
  padding: 10px 14px;
  border: 1px solid var(--border, #2a2d35);
  border-radius: 8px;
  background: var(--card2, #1a1d23);
  color: var(--text, #e4e6eb);
  font-size: 13px;
  width: 280px;
  transition: border-color 0.2s;
}

.sysadmin-search:focus {
  outline: none;
  border-color: var(--accent, #6c5ce7);
}

.sysadmin-select {
  padding: 10px 14px;
  border: 1px solid var(--border, #2a2d35);
  border-radius: 8px;
  background: var(--card2, #1a1d23);
  color: var(--text, #e4e6eb);
  font-size: 13px;
  cursor: pointer;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn-sysadmin-primary {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: var(--accent, #6c5ce7);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-sysadmin-primary:hover {
  background: #5a4bd1;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.4);
}

.btn-sysadmin-outline {
  padding: 10px 20px;
  border: 1px solid var(--border, #2a2d35);
  border-radius: 8px;
  background: transparent;
  color: var(--text, #e4e6eb);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-sysadmin-outline:hover {
  border-color: var(--accent, #6c5ce7);
  color: var(--accent, #6c5ce7);
}

.btn-sysadmin-danger {
  padding: 6px 12px;
  border: 1px solid #e74c3c;
  border-radius: 6px;
  background: transparent;
  color: #e74c3c;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-sysadmin-danger:hover {
  background: #e74c3c;
  color: #fff;
}

.btn-sysadmin-sm {
  padding: 6px 12px;
  border: 1px solid var(--border, #2a2d35);
  border-radius: 6px;
  background: transparent;
  color: var(--muted, #8b8fa3);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-sysadmin-sm:hover {
  border-color: var(--accent, #6c5ce7);
  color: var(--accent, #6c5ce7);
}

/* ── Table ──────────────────────────────────────────────────── */
.sysadmin-table-wrapper {
  border: 1px solid var(--border, #2a2d35);
  border-radius: 12px;
  overflow: hidden;
}

.sysadmin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.sysadmin-table thead {
  background: var(--card2, #1a1d23);
}

.sysadmin-table th {
  padding: 14px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--muted, #8b8fa3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border, #2a2d35);
}

.sysadmin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, #2a2d35);
  color: var(--text, #e4e6eb);
}

.sysadmin-table tbody tr:hover {
  background: rgba(108, 92, 231, 0.04);
}

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

.table-empty {
  text-align: center;
  color: var(--muted, #8b8fa3);
  padding: 40px 16px !important;
}

/* ── Status & Role Badges ───────────────────────────────────── */
.badge-active {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(46, 213, 115, 0.15);
  color: #2ed573;
}

.badge-inactive {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(231, 76, 60, 0.15);
  color: #e74c3c;
}

.badge-level {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-level-1 { background: rgba(116, 185, 255, 0.15); color: #74b9ff; }
.badge-level-2 { background: rgba(253, 203, 110, 0.15); color: #fdcb6e; }
.badge-level-3 { background: rgba(255, 159, 67, 0.15);  color: #ff9f43; }
.badge-level-4 { background: rgba(231, 76, 60, 0.15);   color: #e74c3c; }

/* ── Roles Grid ─────────────────────────────────────────────── */
.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.role-card {
  background: var(--card2, #1a1d23);
  border: 1px solid var(--border, #2a2d35);
  border-radius: 12px;
  padding: 24px;
  transition: all 0.2s;
}

.role-card:hover {
  border-color: var(--accent, #6c5ce7);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.role-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.role-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text, #e4e6eb);
}

.role-card-desc {
  font-size: 13px;
  color: var(--muted, #8b8fa3);
  margin-top: 4px;
}

.role-card-users {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border, #2a2d35);
  font-size: 12px;
  color: var(--muted, #8b8fa3);
}

.role-card-users strong {
  color: var(--text, #e4e6eb);
}

/* ── Clickable Role Cards ───────────────────────────────────── */
.role-card-clickable {
  cursor: pointer;
  user-select: none;
}

.role-expand-hint {
  float: right;
  font-size: 11px;
  color: var(--accent, #6c5ce7);
  opacity: 0.7;
  transition: opacity 0.2s;
}

.role-card-clickable:hover .role-expand-hint {
  opacity: 1;
}

.role-card-user-list {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border, #2a2d35);
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeSlideIn 0.25s ease;
}

.role-user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  transition: background 0.2s;
}

.role-user-item:hover {
  background: rgba(108, 92, 231, 0.06);
}

.role-user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.role-user-info strong {
  font-size: 13px;
  color: var(--text, #e4e6eb);
}

.role-user-info small {
  font-size: 11px;
  color: var(--muted, #8b8fa3);
}

/* ── Modal ──────────────────────────────────────────────────── */
.sysadmin-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.sysadmin-modal {
  background: var(--card, #14161a);
  border: 1px solid var(--border, #2a2d35);
  border-radius: 16px;
  width: 600px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: slideUp 0.3s ease;
}

.sysadmin-modal-sm {
  width: 420px;
}

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

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text, #e4e6eb);
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted, #8b8fa3);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.modal-close:hover {
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.1);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border, #2a2d35);
}

/* ── Modal Steps ────────────────────────────────────────────── */
.modal-steps {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.modal-steps .step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--card2, #1a1d23);
  border: 1px solid var(--border, #2a2d35);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted, #8b8fa3);
  transition: all 0.2s;
}

.modal-steps .step span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--border, #2a2d35);
  font-weight: 700;
  font-size: 11px;
}

.modal-steps .step.active {
  border-color: var(--accent, #6c5ce7);
  color: var(--text, #e4e6eb);
}

.modal-steps .step.active span {
  background: var(--accent, #6c5ce7);
  color: #fff;
}

.modal-steps .step.completed span {
  background: #2ed573;
  color: #fff;
}

.modal-step-content {
  display: none;
}

.modal-step-content.active {
  display: block;
  animation: fadeSlideIn 0.3s ease;
}

/* ── Form Elements ──────────────────────────────────────────── */
.sysadmin-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted, #8b8fa3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.sysadmin-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border, #2a2d35);
  border-radius: 8px;
  background: var(--card2, #1a1d23);
  color: var(--text, #e4e6eb);
  font-size: 14px;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.sysadmin-input:focus {
  outline: none;
  border-color: var(--accent, #6c5ce7);
}

.input-hint {
  display: block;
  font-size: 11px;
  color: var(--muted, #8b8fa3);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.form-col {
  display: flex;
  flex-direction: column;
}

.sysadmin-settings-card {
  padding: 18px;
  border: 1px solid var(--border, #2a2d35);
  border-radius: 12px;
  background: var(--card2, #1a1d23);
}

.sysadmin-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

/* ── Password Field ─────────────────────────────────────────── */
.password-field {
  position: relative;
}

.password-field input {
  padding-right: 40px;
}

.toggle-password {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
}

.password-strength {
  height: 4px;
  border-radius: 2px;
  margin-top: 8px;
  transition: all 0.3s;
}

/* ── Employee Preview ───────────────────────────────────────── */
.employee-preview {
  background: var(--card2, #1a1d23);
  border: 1px solid var(--border, #2a2d35);
  border-radius: 8px;
  padding: 16px;
  margin-top: 12px;
}

.preview-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

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

.preview-row span {
  color: var(--muted, #8b8fa3);
}

/* ── PII Notice ─────────────────────────────────────────────── */
.pii-notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: rgba(108, 92, 231, 0.08);
  border: 1px solid rgba(108, 92, 231, 0.2);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}

.pii-icon {
  font-size: 24px;
}

.pii-notice strong {
  display: block;
  color: var(--accent, #6c5ce7);
  margin-bottom: 4px;
  font-size: 14px;
}

.pii-notice p {
  font-size: 12px;
  color: var(--muted, #8b8fa3);
  margin: 0;
}

/* ── Toast Notification ─────────────────────────────────────── */
.sysadmin-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  z-index: 10001;
  animation: slideUp 0.3s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.sysadmin-toast.success {
  background: #2ed573;
}

.sysadmin-toast.error {
  background: #e74c3c;
}

.sysadmin-toast.info {
  background: var(--accent, #6c5ce7);
}

/* ── Action Buttons in Table ────────────────────────────────── */
.action-group {
  display: flex;
  gap: 6px;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sysadmin-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .sysadmin-tabs {
    flex-direction: column;
  }
  .form-row,
  .sysadmin-form-grid {
    grid-template-columns: 1fr;
  }
  .sysadmin-modal {
    width: 95vw;
  }
}

/* Polished compact account action buttons */
.action-group {
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 120px;
}

.action-group .btn-sysadmin-sm,
.action-group .btn-sysadmin-danger {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--action-border, rgba(108, 92, 231, 0.34));
  background: var(--action-bg, rgba(108, 92, 231, 0.1));
  color: var(--action-color, #6c5ce7);
  font-size: 14px;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.action-group .btn-sysadmin-sm:nth-child(1) {
  --action-color: #3b82f6;
  --action-border: rgba(59, 130, 246, 0.34);
  --action-bg: rgba(59, 130, 246, 0.1);
  --action-bg-hover: rgba(59, 130, 246, 0.18);
  --action-shadow: rgba(59, 130, 246, 0.2);
}

.action-group .btn-sysadmin-sm:nth-child(2) {
  --action-color: #f59e0b;
  --action-border: rgba(245, 158, 11, 0.34);
  --action-bg: rgba(245, 158, 11, 0.1);
  --action-bg-hover: rgba(245, 158, 11, 0.18);
  --action-shadow: rgba(245, 158, 11, 0.2);
}

.action-group .btn-sysadmin-sm:nth-child(3) {
  --action-color: #22c55e;
  --action-border: rgba(34, 197, 94, 0.34);
  --action-bg: rgba(34, 197, 94, 0.1);
  --action-bg-hover: rgba(34, 197, 94, 0.18);
  --action-shadow: rgba(34, 197, 94, 0.2);
}

.action-group .btn-sysadmin-danger {
  --action-color: #ef4444;
  --action-border: rgba(239, 68, 68, 0.34);
  --action-bg: rgba(239, 68, 68, 0.1);
  --action-bg-hover: rgba(239, 68, 68, 0.18);
  --action-shadow: rgba(239, 68, 68, 0.2);
}

.action-group .btn-sysadmin-sm:hover,
.action-group .btn-sysadmin-danger:hover,
.action-group .btn-sysadmin-sm:focus-visible,
.action-group .btn-sysadmin-danger:focus-visible {
  outline: none;
  border-color: var(--action-color);
  background: var(--action-bg-hover, rgba(108, 92, 231, 0.18));
  color: var(--action-color);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px var(--action-shadow, rgba(108, 92, 231, 0.2));
}

.action-group .btn-sysadmin-sm:active,
.action-group .btn-sysadmin-danger:active {
  transform: translateY(0);
  box-shadow: none;
}
