/* ================================
   THEME VARIABLES (MODALS)
   ================================ */

:root {
  --pc-surface: #0b1220;
  --pc-surface-2: rgba(255, 255, 255, 0.04);
  --pc-border: rgba(255, 255, 255, 0.10);
  --pc-text: rgba(255, 255, 255, 0.92);
  --pc-muted: rgba(255, 255, 255, 0.70);
  --pc-muted-2: rgba(255, 255, 255, 0.55);

  --pc-accent: #4c8cff;
  --pc-accent-soft: rgba(76, 140, 255, 0.18);

  --pc-warn: #ffc107;
  --pc-warn-soft: rgba(255, 193, 7, 0.14);

  --pc-danger: #ff4d4d;
  --pc-danger-soft: rgba(255, 77, 77, 0.14);

  --pc-backdrop: rgba(0, 0, 0, 0.55);
  --pc-shadow: 0 20px 60px rgba(0, 0, 0, .55);

  /* Unified hover tokens (match your sidebar-style hover) */
  --ui-hover-bg: rgba(255,255,255,0.06);
  --ui-hover-border: rgba(255,255,255,0.16);
  --ui-hover-glow: rgba(255,255,255,0.08);
}

/* Dark theme overrides */
body.theme-midnight {
  --pc-surface: #0b1220;
}

/* Light themes */
body.theme-light,
body.theme-windows {
  --pc-surface: #ffffff;
  --pc-surface-2: rgba(0, 0, 0, 0.03);
  --pc-border: rgba(0, 0, 0, 0.10);
  --pc-text: rgba(0, 0, 0, 0.90);
  --pc-muted: rgba(0, 0, 0, 0.62);
  --pc-muted-2: rgba(0, 0, 0, 0.50);
  --pc-accent: #2563eb;
  --pc-backdrop: rgba(0, 0, 0, 0.35);
  --pc-shadow: 0 18px 50px rgba(0, 0, 0, .20);

  /* Light theme hover tokens */
  --ui-hover-bg: rgba(0,0,0,0.05);
  --ui-hover-border: rgba(0,0,0,0.14);
  --ui-hover-glow: rgba(0,0,0,0.06);
}

/* ================================
   PAGE LAYOUT & UNIFIED HEADER
   ================================ */

.pc-head.card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
}

.pc-head-actions-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap; /* Forces everything on one line */
}

.pc-inline-filter {
  flex: 1;
}

.pc-filter-group {
  display: flex;
  gap: 8px;
  width: 100%;
  align-items: center;
}

.search-input { flex: 2; min-width: 150px; }
.role-select { flex: 1; min-width: 140px; }

/* Clear Filter Button */
.clear-btn {
  background: var(--pc-surface-2);
  color: var(--pc-muted);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  border: 1px solid var(--pc-border);
  white-space: nowrap;
}

/* ================================
   DARK DROPDOWN FIX
   ================================ */

select.input {
  background-color: var(--pc-surface) !important;
  color: var(--pc-text) !important;
  border: 1px solid var(--pc-border);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='rgba(255,255,255,0.5)' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

/* Force options to stay dark */
select.input option {
  background-color: #0b1220;
  color: #fff;
}

/* ================================
   MODAL BASE & CARDS
   ================================ */

.pc-modal::backdrop { background: var(--pc-backdrop); }

.pc-modal {
  border: none;
  padding: 0;
  background: transparent;
  margin: auto;
}

.pc-modal-card {
  width: min(720px, calc(100vw - 40px));
  background: var(--pc-surface);
  border: 1px solid var(--pc-border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--pc-shadow);
  color: var(--pc-text);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

/* ================================
   CENTERED HEADER & TITLE
   =============================== */

.pc-modal-head-center {
  position: relative;
  padding: 22px 20px 20px;
  border-radius: 18px 18px 0 0;
  text-align: center;
  background: linear-gradient(180deg, var(--pc-accent-soft), var(--pc-surface));
}

.pc-modal-head-edit {
  background: linear-gradient(180deg, var(--pc-warn-soft), var(--pc-surface));
}

/* Danger (Delete confirmation) */
.pc-modal-head-danger {
  background: linear-gradient(180deg, var(--pc-danger-soft), var(--pc-surface));
}

.pc-modal-head-center::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 0;
  height: 1px;
  background: var(--pc-border);
  opacity: .65;
}

.pc-modal-title-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.pc-modal-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.pc-modal-title {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.pc-modal-subtitle {
  max-width: 520px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--pc-muted);
}

.pc-modal-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--pc-accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px var(--pc-border);
  color: var(--pc-text);
}

.pc-modal-icon-edit { background: var(--pc-warn-soft); }

.pc-modal-icon-danger {
  background: var(--pc-danger-soft);
}

.pc-modal-title-danger {
  color: var(--pc-danger);
}

.pc-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--pc-border);
  background: var(--pc-surface-2);
  color: var(--pc-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ================================
   FORM & GRID LAYOUT
   ================================ */

.pc-modal-body { padding: 20px 4px 10px; }

.pc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.pc-grid > div {
  display: flex;
  flex-direction: column;
}

.pc-modal-body label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--pc-muted-2);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input {
  width: 100%;
  background: var(--pc-surface-2);
  border: 1px solid var(--pc-border);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--pc-text);
  font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input:focus {
  border-color: var(--pc-accent);
  box-shadow: 0 0 0 3px var(--pc-accent-soft);
  outline: none;
}

/* Auto-generate highlight */
#create_email:focus ~ div #create_username {
  border-color: var(--pc-accent-soft);
}

/* ================================
   PASSWORD UTILS
   ================================ */

.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.pw-eye {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--pc-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 18px;
}

.pw-reqs {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.pw-reqs li {
  font-size: 13px;
  color: var(--pc-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0.5;
  transition: opacity 0.3s, color 0.3s;
}

.pw-reqs li::before {
  content: "";
  width: 5px;
  height: 5px;
  background: currentColor;
  border-radius: 50%;
}

.pw-bar {
  height: 4px;
  background: var(--pc-surface-2);
  border-radius: 2px;
  margin: 8px 0;
  overflow: hidden;
}

.pw-bar > div {
  height: 100%;
  width: 0;
  transition: width 0.3s ease;
}

/* ================================
   SUCCESS TOAST & ANIMATIONS
   ================================ */

.pc-flash.ok {
  animation: slideInFade 4s forwards;
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10000;
  padding: 14px 20px;
  border-radius: 12px;
  background: #10b981;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

@keyframes slideInFade {
  0% { transform: translateX(100%); opacity: 0; }
  10% { transform: translateX(0); opacity: 1; }
  90% { transform: translateX(0); opacity: 1; }
  100% { transform: translateX(20px); opacity: 0; }
}

/* ================================
   RESPONSIVE OVERRIDES
   ================================ */

@media (max-width: 900px) {
  .pc-head-actions-row {
    flex-direction: column;
    align-items: stretch;
  }
  .pc-filter-group {
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  .pc-grid { grid-template-columns: 1fr; }
}

.pc-modal-actions {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ================================
   DELETE CONFIRM (matches Picture 2)
   ================================ */

/* Slightly narrower card for confirm dialogs */
.pc-confirm-card {
  width: min(560px, calc(100vw - 40px));
  padding: 0;
  overflow: hidden; /* so header radius clips nicely */
}

.pc-confirm-actions {
  padding: 22px;
  display: flex;
  gap: 14px;
  justify-content: center;
}

.pc-confirm-btn {
  flex: 1;
  height: 48px;
  border-radius: 14px;
  font-weight: 800;
  letter-spacing: 0.2px;
  border: 1px solid var(--pc-border);
  background: var(--pc-surface-2);
  color: var(--pc-text);
  cursor: pointer;
}

/* Danger confirm button base */
.pc-confirm-danger {
  border-color: rgba(255, 77, 77, 0.35);
  background: linear-gradient(180deg, rgba(255, 77, 77, 0.22), rgba(255, 77, 77, 0.10));
  color: #fff;
}

@media (max-width: 520px) {
  .pc-confirm-actions {
    flex-direction: column;
  }
  .pc-confirm-btn {
    width: 100%;
  }
}

/* ================================
   BUTTONS (base)
   ================================ */

.btn.primary {
  background: var(--pc-accent);
  color: white;
  border: 1px solid rgba(255,255,255,0.10);
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}

/* ================================
   UNIFIED HOVER (NO DUPLICATION)
   ================================ */

/* Apply same hover feel to all clickable UI buttons/controls */
.btn,
.clear-btn,
.pc-confirm-btn,
.pc-modal-close {
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease, filter .2s ease, transform .08s ease;
}

.btn:hover,
.clear-btn:hover,
.pc-confirm-btn:hover,
.pc-modal-close:hover {
  background: var(--ui-hover-bg);
  border-color: var(--ui-hover-border);
  box-shadow: 0 0 0 3px var(--ui-hover-glow);
  filter: brightness(1.06);
  color: var(--pc-text);
}

.btn:active,
.clear-btn:active,
.pc-confirm-btn:active,
.pc-modal-close:active {
  transform: translateY(1px);
}

/* Keep PRIMARY looking primary on hover */
.btn.primary:hover {
  background: var(--pc-accent);
  box-shadow: 0 0 0 3px var(--pc-accent-soft);
  filter: brightness(1.08);
}

/* Keep DANGER looking danger on hover (confirm delete) */
.pc-confirm-danger:hover {
  box-shadow: 0 0 0 3px var(--pc-danger-soft);
  filter: brightness(1.08);
}

/* Keyboard accessibility */
.btn:focus-visible,
.clear-btn:focus-visible,
.pc-confirm-btn:focus-visible,
.pc-modal-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--pc-accent-soft);
}
/* ================================
   FLASH MESSAGE – INLINE (Option B)
   ================================ */

.pc-flash.ok,
.pc-flash.err{
  position: relative;
  top: auto;
  right: auto;
  margin: 14px 0 18px;
  padding: 14px 18px;
  border-radius: 12px;
  font-weight: 600;
  box-shadow: none;
  animation: none;
}

/* Success */
.pc-flash.ok{
  background: rgba(16, 185, 129, 0.14);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

/* Error */
.pc-flash.err{
  background: rgba(239, 68, 68, 0.14);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.35);
}
