/* =========================================================
   User Management — Premium Layout (Scoped)
   Reutiliza variáveis e classes dl-* do department_list.css
   ========================================================= */

/* --- User cards list --- */
.um-users-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.um-user-card {
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.um-user-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  border-color: rgba(197,165,114,0.3);
}

.um-user-card.um-user-inactive {
  opacity: 0.55;
}

.um-user-main {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex: 1;
  min-width: 0;
}

.um-user-info {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  min-width: 0;
  flex: 1;
}

.um-user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c5a572 0%, #9d8359 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.um-user-details {
  min-width: 0;
}

.um-user-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #1f2937;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.um-user-username {
  font-weight: 400;
  font-size: 0.8rem;
  color: #9ca3af;
}

.um-user-email {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 2px;
}

.um-user-badges {
  display: flex;
  gap: 0.375rem;
  margin-top: 0.375rem;
  flex-wrap: wrap;
}

.um-user-badges .dl-pill {
  font-size: 0.7rem;
  padding: 2px 8px;
}

/* --- Permissions summary tags --- */
.um-user-permissions-summary {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.um-perm-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 20px;
  background: #f3f4f6;
  color: #4b5563;
  white-space: nowrap;
}

.um-perm-tag i {
  font-size: 0.65rem;
}

.um-perm-tag.um-perm-super {
  background: linear-gradient(135deg, #c5a572, #9d8359);
  color: #fff;
}

.um-perm-tag.um-perm-none {
  background: #fef3c7;
  color: #92400e;
}

/* --- User actions --- */
.um-user-actions {
  display: flex;
  gap: 0.375rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* --- Modal --- */
.um-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.um-modal {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.25);
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: umModalIn 0.25s ease-out;
}

.um-modal.um-modal-sm {
  max-width: 440px;
}

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

.um-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

.um-modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
}

.um-modal-header h2 i {
  color: #c5a572;
  margin-right: 0.5rem;
}

.um-modal-username {
  color: #c5a572;
}

.um-modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: #9ca3af;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.um-modal-close:hover {
  background: #f3f4f6;
  color: #1f2937;
}

.um-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.um-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(0,0,0,0.08);
}

/* --- Permission sections --- */
.um-perm-section {
  margin-bottom: 1.5rem;
}

.um-perm-section:last-child {
  margin-bottom: 0;
}

.um-perm-section h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.um-perm-section h3 i {
  color: #c5a572;
  font-size: 0.85rem;
}

/* --- Section header with count --- */
.um-perm-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.625rem;
}

.um-perm-count {
  font-size: 0.75rem;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.um-filter-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: #eff6ff;
  color: #3b82f6;
  white-space: nowrap;
}

.um-filter-badge i {
  font-size: 0.55rem;
}

/* --- Section toolbar (search + select all) --- */
.um-section-toolbar {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.625rem;
}

.um-search-inline {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: #f9fafb;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 8px;
  padding: 0.375rem 0.625rem;
  flex: 1;
  min-width: 0;
  transition: border-color 0.15s;
}

.um-search-inline:focus-within {
  border-color: rgba(197,165,114,0.5);
}

.um-search-inline i {
  color: #9ca3af;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.um-search-inline input {
  border: none;
  background: none;
  outline: none;
  font-size: 0.8rem;
  color: #374151;
  width: 100%;
  min-width: 0;
}

.um-search-inline input::placeholder {
  color: #d1d5db;
}

.um-search-clear {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 0;
  font-size: 0.7rem;
  flex-shrink: 0;
  line-height: 1;
}

.um-search-clear:hover {
  color: #374151;
}

/* --- Select all button --- */
.um-select-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: none;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 8px;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  color: #6b7280;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.um-select-all-btn:hover {
  background: #f9fafb;
  border-color: rgba(197,165,114,0.3);
  color: #374151;
}

.um-select-all-btn i {
  color: #c5a572;
  font-size: 0.8rem;
}

.um-perm-note {
  font-size: 0.8rem;
  color: #6b7280;
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 0.625rem 0.875rem;
  margin-top: 0.5rem;
}

.um-perm-note i {
  color: #d97706;
  margin-right: 0.25rem;
}

.um-perm-empty {
  font-size: 0.8rem;
  color: #9ca3af;
  font-style: italic;
}

/* --- Toggle switch --- */
.um-toggle-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: #374151;
  user-select: none;
}

.um-toggle-label input[type="checkbox"] {
  display: none;
}

.um-toggle-switch {
  width: 44px;
  height: 24px;
  background: #d1d5db;
  border-radius: 12px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.um-toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.um-toggle-label input:checked + .um-toggle-switch {
  background: linear-gradient(135deg, #c5a572, #9d8359);
}

.um-toggle-label input:checked + .um-toggle-switch::after {
  transform: translateX(20px);
}

/* --- Checkbox grid --- */
.um-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
}

.um-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: #374151;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.06);
  background: #fafafa;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}

.um-checkbox-label:hover {
  background: #f3f4f6;
  border-color: rgba(197,165,114,0.3);
}

.um-checkbox-label.um-checked {
  background: #fdf8f0;
  border-color: rgba(197,165,114,0.4);
}

.um-checkbox-label.um-checked:hover {
  background: #faf3e6;
}

.um-checkbox-label input[type="checkbox"] {
  accent-color: #c5a572;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.um-checkbox-code {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-left: auto;
}

/* --- Create user form --- */
.um-create-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.um-create-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 600px) {
  .um-create-row {
    grid-template-columns: 1fr;
  }
}

/* --- Field for modal forms --- */
.um-field {
  margin-bottom: 0;
}

.um-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.375rem;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .um-user-card {
    flex-direction: column;
    align-items: stretch;
    padding: 1rem;
  }

  .um-user-main {
    flex-direction: column;
    gap: 0.75rem;
  }

  .um-user-permissions-summary {
    padding-left: 0;
  }

  .um-user-actions {
    border-top: 1px solid rgba(0,0,0,0.06);
    padding-top: 0.75rem;
    justify-content: flex-end;
  }

  .um-modal {
    max-height: 90vh;
    border-radius: 14px;
  }

  .um-checkbox-grid {
    grid-template-columns: 1fr;
  }

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

  .um-select-all-btn {
    justify-content: center;
  }

  .um-perm-section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .um-user-type-selector {
    flex-direction: column;
  }
}

/* --- User type selector (radio cards) --- */
.um-user-type-selector {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.um-type-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
  min-width: 180px;
  background: #fff;
}

.um-type-option:hover {
  border-color: #c5a572;
  background: #fdfaf5;
}

.um-type-option.um-type-selected {
  border-color: #c5a572;
  background: linear-gradient(135deg, #fdf8f0, #f5ead6);
  box-shadow: 0 2px 8px rgba(197, 165, 114, 0.2);
}

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

.um-type-option > i {
  font-size: 1.25rem;
  color: #9ca3af;
  width: 24px;
  text-align: center;
}

.um-type-option.um-type-selected > i {
  color: #c5a572;
}

.um-type-option div {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.um-type-option strong {
  font-size: 0.9rem;
  color: #1f2937;
}

.um-type-option small {
  font-size: 0.75rem;
  color: #9ca3af;
}

.um-type-option.um-type-selected strong {
  color: #8b6914;
}

/* --- Badge variants --- */
.dl-pill-simple {
  background: #eff6ff;
  color: #3b82f6;
}

.dl-pill-regular {
  background: #f0fdf4;
  color: #16a34a;
}
