.user-menu {
  position: relative;
  display: inline-block;
}

.user-menu .login-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.login-status-badge--active {
  /* background removed - set dynamically via JS */
}

.login-status-badge--active:hover {
  /* hover effects handled via JS for color scheme */
  filter: brightness(0.92);
}

/* Color schemes for each user type */
.login-status-badge.badge-guest {
  background: #F3F4F6;
}

.login-status-badge.badge-guest:hover {
  background: #E5E7EB;
}

.login-status-badge.badge-warga {
  background: #DBEAFE;
}

.login-status-badge.badge-warga:hover {
  background: #BFDBFE;
}

.login-status-badge.badge-admin {
  background: #FFEDD5;
}

.login-status-badge.badge-admin:hover {
  background: #FED7AA;
}

.login-status-badge.badge-superuser {
  background: #FEE2E2;
}

.login-status-badge.badge-superuser:hover {
  background: #FECACA;
}

.login-status-badge.badge-pengembang {
  background: #F3E8FF;
}

.login-status-badge.badge-pengembang:hover {
  background: #E9D5FF;
}

.user-menu-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 91px;
}

.user-menu-label--active {
  color: #dc2626;
  font-weight: 600;
}

.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 220px;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 14px 40px rgba(8, 40, 47, 0.18);
  border: 1px solid rgba(12, 60, 70, 0.08);
  overflow: hidden;
  /* raise above page sections and sidebars, keep below modal overlays */
  z-index: 7001;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-menu-dropdown ul {
  list-style: none;
  padding: 10px 0;
  margin: 0;
}

.user-menu-dropdown .menu-item {
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 500;
  color: #0f3f4d;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  border-left: 3px solid transparent;
  position: relative;
}

.user-menu-dropdown .menu-item i {
  width: 18px;
  text-align: center;
  opacity: 0.8;
  transition: all 0.15s ease;
}

.user-menu-dropdown .menu-item:hover {
  background: linear-gradient(90deg, rgba(31, 124, 133, 0.08) 0%, rgba(31, 124, 133, 0.04) 100%);
  border-left-color: #1f7c85;
  padding-left: 15px;
}

.user-menu-dropdown .menu-item:hover i {
  opacity: 1;
  color: #1f7c85;
}

.user-menu-dropdown .menu-item--danger {
  color: #dc2626;
}

.user-menu-dropdown .menu-item--danger:hover {
  background: linear-gradient(90deg, rgba(220, 38, 38, 0.08) 0%, rgba(220, 38, 38, 0.04) 100%);
  border-left-color: #dc2626;
}

.user-menu-dropdown .menu-item--danger:hover i {
  color: #dc2626;
}

.user-menu-dropdown .menu-sep {
  height: 1px;
  background: rgba(12, 60, 70, 0.04);
  margin: 6px 0;
}

.user-list-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.user-list-wrapper {
  overflow: auto;
  max-height: calc(92vh - 180px);
  position: relative;
}

.user-list-table th,
.user-list-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(15, 63, 75, 0.08);
  text-align: left;
  font-size: 14px;
  color: #0f172a;
  background: #ffffff;
}

.user-list-table thead th {
  font-weight: 700;
  color: #0f3f4d;
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 4;
  border-bottom: 1px solid rgba(15, 63, 75, 0.12);
}

.user-list-table th.sticky-col,
.user-list-table td.sticky-col,
.user-list-table th.sticky-right,
.user-list-table td.sticky-right {
  position: sticky;
  z-index: 3;
  background: #f8fafc;
}

.sticky-left {
  left: 0;
}

.sticky-right {
  right: 0;
  z-index: 4;
  background: #ffffff;
}

.user-list-table th.sticky-left,
.user-list-table td.sticky-left {
  min-width: 220px;
  box-shadow: inset 3px 0 0 rgba(15, 63, 75, 0.06);
}

.user-list-table tbody tr:hover td {
  background: rgba(15, 118, 110, 0.08);
}

.user-list-table tbody tr:hover {
  cursor: pointer;
}

.user-list-table th.sticky-right,
.user-list-table td.sticky-right {
  width:123px;
  min-width: 123px;
  max-width: 123px;
  box-shadow: none;
  box-sizing: border-box;
}

.user-list-empty {
  color: #4b5563;
  padding: 18px 0 0;
  font-size: 14px;
}

.action-btns {
  display: flex;
  gap: 6px;
  width: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.btn {
  border: none;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.btn-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 10px;
  flex: 0 0 auto;
}

.btn-icon i {
  font-size: 14px;
}

.btn-small { padding: 6px 8px; font-size: 12px; }
.btn-primary { background: #0f766e; color: #fff; }
.btn-secondary { background: #e6f3f2; color: #064e49; }
.btn-danger { background: #fee2e2; color: #991b1b; }

.user-list-table .action-cell {
  width: 74px;
  max-width: 74px;
  white-space: nowrap;
  padding: 10px 0 !important;
  margin: 0 !important;
  overflow: hidden;
  box-sizing: border-box;
  box-shadow: none !important;
}

.user-list-table .action-cell.sticky-right {
  min-width: auto;
  box-shadow: none;
}

.user-detail-table { width: 100%; border-collapse: collapse; }
.user-detail-table th, .user-detail-table td { padding: 8px 10px; border-bottom: 1px solid rgba(15,63,75,0.06); }

.modal-form {
  display: grid;
  gap: 1px;
}

#userProfileModal .modal-form {
  gap: 1px;
}

#userProfileModal .modal-field {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 2px 4px;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
}

#userProfileModal .modal-field label {
  font-size: 12px;
  font-weight: 700;
  color: #0f3f4d;
  white-space: nowrap;
  box-sizing: border-box;
}

#userProfileModal .modal-field input {
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(15, 63, 75, 0.18);
  background: #f8fafc;
  margin: 4px 0;
  min-width: 0;
  box-sizing: border-box;
}

#userProfileModal .modal-box {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 40px);
  width: min(98%, 640px);
  box-sizing: border-box;
  padding: 20px;
  overflow: visible;
}

/* make modal body scrollable without clipping horizontal content */
#userProfileModal .modal-body {
  padding: 0 0 12px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.modal-field input {
  width: 100%;
  border: 1px solid rgba(15, 63, 75, 0.18);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  color: #0f172a;
  background: #f8fafc;
}

#userEditModal .modal-box {
  display: flex;
  flex-direction: column;
}

#userEditModal .modal-body {
  padding: 0 20px 16px;
}

#userEditModal .modal-footer {
  padding: 14px 20px 20px;
  margin-top: 0;
}

#userEditModal .modal-actions {
  justify-content: flex-end;
}

.modal-field input {
  width: 100%;
  border: 1px solid rgba(15, 63, 75, 0.18);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  color: #0f172a;
  background: #f8fafc;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(15, 63, 75, 0.08);
}

#userEditModal .modal-box {
  display: flex;
  flex-direction: column;
}

#userEditModal .modal-body {
  padding: 0 28px 22px;
}

#userEditModal .modal-footer {
  padding: 16px 28px 28px;
  margin-top: 0;
}

#userEditModal .modal-actions {
  justify-content: flex-end;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

#userEditModal .modal-box {
  padding: 24px;
  max-width: 700px;
}

#userEditModal .modal-header {
  margin-bottom: 18px;
}

#userEditModal .modal-footer {
  padding-top: 16px;
  border-top: 1px solid rgba(15, 63, 75, 0.08);
  margin-top: 14px;
}

#userEditModal .modal-actions {
  justify-content: flex-end;
}

#userEditModal .modal-box {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

#userEditModal .modal-body {
  padding: 0 28px 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

#userProfileModal .modal-body {
  padding: 0 16px 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  box-sizing: border-box;
}

#userProfileModal .modal-box {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 40px);
  width: min(98%, 620px);
  overflow: hidden;
}

#userProfileModal .modal-footer {
  padding: 18px 0 24px 28px;
  margin-top: 0;
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  border-top: 1px solid rgba(15, 63, 75, 0.08);
  background: #ffffff;
}

#userProfileModal .modal-footer .btn {
  min-width: 110px;
}

#userProfileModal .modal-footer #userProfileSave {
  order: -1;
}

#userProfileModal .modal-field input[disabled],
#userProfileModal .modal-field input[readonly] {
  background: #f5f7fa;
  border-color: #d1d5db;
  color: #6b7280;
  cursor: not-allowed;
}

#userEditModal .modal-footer {
  padding: 16px 28px 28px;
  margin-top: 0;
  flex-shrink: 0;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  background: rgba(15, 23, 42, 0.6);
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 40px; /* more breathing room */
}

.modal-overlay.show {
  display: flex;
}

.modal-box {
  position: relative;
  width: min(98%, 1100px); /* wider on desktops */
  max-height: min(100%, 100vh);
  overflow: hidden;
  background: #ffffff;
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 30px 80px rgba(8, 40, 47, 0.22);
}

.modal-header-wrapper {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #ffffff;
  padding: 28px;
  padding-bottom: 0;
  border-bottom: 1px solid rgba(15, 63, 75, 0.08);
}

.modal-content-scroll {
  overflow: hidden;
  max-height: calc(92vh - 180px);
  padding: 0 28px 28px;
}

/* Table behavior inside modal */
.user-list-table { width: 100%; min-width: 700px; }
.user-list-table th, .user-list-table td { white-space: nowrap; }
.modal-content-scroll .user-list-table .action-cell { width: 74px; max-width: 74px; overflow: hidden; box-sizing: border-box; }

.modal-content-scroll .user-list-table th.sticky-col,
.modal-content-scroll .user-list-table td.sticky-col {
  z-index: 5;
}

.modal-content-scroll .user-list-table th.sticky-right,
.modal-content-scroll .user-list-table td.sticky-right {
  z-index: 6;
}

/* Stronger selectors for our modals to override page-wide modal styles in utama.html */
#userListModal.modal-overlay,
#userDetailModal.modal-overlay {
  padding: 40px !important;
  overflow: hidden !important;
}

#userListModal.modal-overlay .modal-box,
#userDetailModal.modal-overlay .modal-box {
  width: min(98%, 1100px) !important;
  max-width: none !important;
  border-radius: 14px !important;
  padding: 28px !important;
}

#userListModal .modal-box {
  height: min(80vh, 760px);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#userListModal .modal-header-wrapper,
#userListModal .modal-footer {
  flex-shrink: 0;
}

#userListModal .modal-content-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  padding: 12px 18px;
}

#userListModal .user-list-table,
#userDetailModal .user-detail-table {
  min-width: 700px;
}

.user-list-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  margin-top: -2px;
  margin-bottom: 12px;
}

.user-list-filter-label {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.user-list-filter-select {
  min-width: 170px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 63, 75, 0.18);
  border-radius: 999px;
  background: #ffffff;
  color: #0f172a;
  font-size: 14px;
  box-shadow: 0 2px 6px rgba(15, 63, 75, 0.08);
}

.user-list-filter-select:focus {
  outline: none;
  border-color: rgba(14, 165, 233, 0.7);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: transparent;
  border: none;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: #0f172a;
}

html.user-scroll-locked,
body.user-scroll-locked {
  overflow: hidden !important;
}

#userListModal,
#userListModal.modal-overlay,
#userListModal .modal-box,
#userListModal .modal-content-scroll {
  overflow: hidden !important;
}

#userListModal .modal-content-scroll {
  overflow-y: auto !important;
  overflow-x: auto !important;
}
