/* ═══════════════════════════════════════════════
   Roles & Permissions — Dark Theme Redesign
   Mission Control aesthetic: deep space, glass, turquoise accents
   ═══════════════════════════════════════════════ */

/* ── Layout ── */
.role-management {
  padding: 0;
  font-family: inherit;
}

.role-management .section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.role-management .section-header h2 {
  font-family: inherit;
  font-size: 28px;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  font-weight: 400;
}

/* ── Stats Strip ── */
.role-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
}

.role-stats .stat-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
}

.role-stats .stat-number {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--amt-turquoise);
}

.role-stats .stat-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

/* ── Section Headers ── */
.roles-section {
  margin-bottom: 32px;
}

.roles-section h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.section-description {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 16px;
  opacity: 0.7;
}

/* ── Role Cards Grid ── */
.role-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.role-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 18px;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.role-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--role-accent, var(--amt-turquoise));
  opacity: 0.6;
  transition: opacity 0.25s;
}

.role-card:hover {
  border-color: rgba(79, 195, 202, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.role-card:hover::before {
  opacity: 1;
}

.role-card.system-role {
  border-left: 3px solid var(--role-accent, var(--text-muted));
}

.role-card.system-role::before {
  display: none;
}

.role-card-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.role-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 16px;
  color: white;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.system-badge {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 9px;
  text-transform: uppercase;
  font-weight: 500;
  letter-spacing: 0.08em;
  border: 1px solid var(--border-color);
}

.role-description {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.role-meta {
  display: flex;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 14px;
  letter-spacing: 0.03em;
}

.role-meta .permission-count {
  color: var(--amt-turquoise);
}

.role-actions {
  display: flex;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.role-actions .btn-icon {
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
}

.role-actions .btn-icon:hover {
  border-color: rgba(79, 195, 202, 0.3);
  color: var(--amt-turquoise);
  background: rgba(79, 195, 202, 0.06);
}

.role-actions .btn-danger:hover {
  border-color: rgba(248, 113, 113, 0.3);
  color: #F87171;
  background: rgba(248, 113, 113, 0.06);
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px dashed var(--border-color);
  font-size: 14px;
}

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 10000;
  padding: 40px 20px;
  overflow-y: auto;
}

.modal-content.modal-large {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  max-width: 780px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

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

.modal-header h3 {
  font-family: inherit;
  font-size: 24px;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  font-weight: 400;
}

.modal-header .close-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-header .close-btn:hover {
  border-color: rgba(79, 195, 202, 0.3);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px 28px;
  max-height: 65vh;
  overflow-y: auto;
}

/* ── Form Fields ── */
.rm-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.rm-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.rm-label .required {
  color: #F87171;
}

.rm-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.rm-input:focus {
  outline: none;
  border-color: rgba(79, 195, 202, 0.4);
  box-shadow: 0 0 0 3px rgba(79, 195, 202, 0.08);
}

.rm-input::placeholder {
  color: var(--text-muted);
  opacity: 0.5;
}

.rm-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.6;
  letter-spacing: 0.02em;
}

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

.rm-grid-full {
  grid-column: span 2;
}

/* ── HR Section ── */
.rm-hr-section {
  background: rgba(217, 119, 6, 0.06);
  border: 1px solid rgba(217, 119, 6, 0.15);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 20px;
}

.rm-hr-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #FBBF24;
  margin-bottom: 4px;
}

.rm-hr-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ── Divider ── */
.rm-divider {
  height: 1px;
  background: var(--border-color);
  margin: 8px 0 20px;
}

/* ── Permissions Section ── */
.rm-permissions-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* Permission Card */
.perm-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.perm-card.active {
  border-color: rgba(79, 195, 202, 0.2);
}

.perm-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.perm-card-header:hover {
  background: rgba(79, 195, 202, 0.03);
}

.perm-card-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(79, 195, 202, 0.06);
  border: 1px solid rgba(79, 195, 202, 0.1);
  border-radius: 8px;
  color: var(--amt-turquoise);
  flex-shrink: 0;
}

.perm-card-icon svg {
  width: 16px;
  height: 16px;
}

.perm-card-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

/* ── Segmented Control (Access Level) ── */
.seg-control {
  display: inline-flex;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.seg-btn {
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
  color: var(--text-muted);
  white-space: nowrap;
}

.seg-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.seg-btn.active {
  background: var(--amt-turquoise);
  color: #050810;
  font-weight: 600;
}

.seg-btn.active-none {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.seg-btn.active-admin {
  background: #FBBF24;
  color: #050810;
}

/* ── Permission Details ── */
.perm-details {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  display: none;
}

.perm-details.open {
  display: block;
}

.perm-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

/* Toggle Pill */
.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.toggle-pill:hover {
  border-color: rgba(79, 195, 202, 0.2);
}

.toggle-pill.on {
  background: rgba(79, 195, 202, 0.08);
  border-color: rgba(79, 195, 202, 0.25);
}

.toggle-pill input {
  display: none;
}

.toggle-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.3;
  transition: all 0.2s;
}

.toggle-pill.on .toggle-pill-dot {
  background: var(--amt-turquoise);
  opacity: 1;
  box-shadow: 0 0 6px rgba(79, 195, 202, 0.4);
}

.toggle-pill-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color 0.2s;
}

.toggle-pill.on .toggle-pill-label {
  color: var(--amt-turquoise);
}

/* Custom permissions section */
.perm-custom {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
}

.perm-custom-title {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 8px;
  opacity: 0.6;
}

/* ── System Role Notice ── */
.system-role-notice {
  border-radius: 10px;
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.system-role-notice-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  flex-shrink: 0;
  font-size: 20px;
}

.system-role-notice h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 6px;
}

.system-role-notice p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

/* ── Modal Footer ── */
.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.modal-footer .btn-danger {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: #F87171;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.modal-footer .btn-danger:hover {
  background: rgba(248, 113, 113, 0.15);
}

.modal-footer .btn-secondary {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.modal-footer .btn-secondary:hover {
  border-color: rgba(79, 195, 202, 0.2);
  color: var(--text-primary);
}

.modal-footer .btn-primary {
  background: var(--amt-turquoise);
  border: none;
  color: #050810;
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}

.modal-footer .btn-primary:hover {
  box-shadow: 0 4px 16px rgba(79, 195, 202, 0.3);
  transform: translateY(-1px);
}

/* ── User Role Badges (used in user management) ── */
.user-roles-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.user-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  color: white;
}

.user-role-badge .remove-role {
  cursor: pointer;
  opacity: 0.7;
  margin-left: 2px;
}

.user-role-badge .remove-role:hover {
  opacity: 1;
}

/* ── Role Assignment Chips ── */
.role-assignment-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.available-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.role-chip:hover {
  border-color: rgba(79, 195, 202, 0.3);
}

.role-chip.selected {
  border-color: var(--amt-turquoise);
  background: rgba(79, 195, 202, 0.08);
}

.role-chip .role-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ── HR Badge (on role cards) ── */
.hr-badge {
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .rm-grid {
    grid-template-columns: 1fr;
  }
  .rm-grid-full {
    grid-column: span 1;
  }
  .role-cards {
    grid-template-columns: 1fr;
  }
  .perm-toggles {
    gap: 6px;
  }
  .seg-control {
    flex-wrap: wrap;
  }
  .role-stats {
    flex-wrap: wrap;
  }
  .modal {
    padding: 20px 12px;
  }
}
