/* Gate Avatar — floating draggable user widget, injected via nginx sub_filter */
#gate-avatar-root {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 2147483647;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans SC", sans-serif;
  user-select: none;
  transition: box-shadow 0.2s;
}

#gate-avatar-root.gate-avatar--dragging {
  opacity: 0.88;
  transition: none;
}

/* ── Avatar Button ── */
.gate-avatar-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.8);
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 6px rgba(99, 102, 241, 0.25);
  transition:
    transform 0.15s,
    box-shadow 0.15s;
  line-height: 1;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}

.gate-avatar-btn.gate-avatar--custom {
  text-indent: -9999px;
}

.gate-avatar-btn:hover {
  transform: scale(1.12);
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.4);
}

.gate-avatar-btn:active {
  transform: scale(0.92);
}

/* ── Online indicator ── */
.gate-avatar-online {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  border: 1.5px solid rgba(0, 0, 0, 0.35);
}

/* ── Dropdown Panel ── */
.gate-avatar-panel {
  position: absolute;
  top: 32px;
  right: 0;
  width: 220px;
  max-height: 360px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 10px;
  box-shadow:
    0 6px 28px rgba(0, 0, 0, 0.14),
    0 1px 3px rgba(0, 0, 0, 0.05);
  animation: gate-avatar-in 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: top right;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
}

.gate-avatar-panel::-webkit-scrollbar {
  width: 4px;
}

.gate-avatar-panel::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 2px;
}

@keyframes gate-avatar-in {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.gate-avatar-panel--hidden {
  display: none;
}

/* ── Panel Header ── */
.gate-avatar-header {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.gate-avatar-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  background-size: cover;
  background-position: center;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.gate-avatar-info {
  min-width: 0;
}

.gate-avatar-name {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gate-avatar-domain {
  font-size: 10px;
  color: #9ca3af;
  margin-top: 1px;
}

/* ── Panel Body (logout) ── */
.gate-avatar-body {
  padding: 6px;
}

.gate-avatar-logout {
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 7px;
  background: #fef2f2;
  color: #dc2626;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.15s;
  font-family: inherit;
}

.gate-avatar-logout:hover {
  background: #fee2e2;
}

.gate-avatar-logout:active {
  background: #fecaca;
}

/* ── Panel Arrow ── */
.gate-avatar-panel::before {
  content: "";
  position: absolute;
  top: -5px;
  left: var(--arrow-x, calc(100% - 14px));
  width: 10px;
  height: 10px;
  background: rgba(255, 255, 255, 0.98);
  transform: rotate(45deg);
  border-radius: 2px 0 0 0;
}

.gate-avatar-panel--flip-y::before {
  top: auto;
  bottom: -5px;
  transform: rotate(225deg);
}

.gate-avatar-panel--flip-x::before {
  left: auto;
  right: calc(100% - var(--arrow-x, 14px) - 10px);
}

/* ── Divider ── */
.gate-avatar-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.06);
  margin: 0 10px;
}

/* ── Settings Section ── */
.gate-avatar-settings {
  padding: 8px 10px 10px;
}

.gate-avatar-settings-title {
  font-size: 10px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding-left: 2px;
}

.gate-avatar-field {
  display: block;
  margin-bottom: 7px;
}

.gate-avatar-field span {
  display: block;
  font-size: 10px;
  color: #6b7280;
  margin-bottom: 3px;
}

.gate-avatar-field input[type="url"],
.gate-avatar-field input[type="text"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 6px;
  font-size: 11px;
  font-family: inherit;
  color: #111827;
  background: rgba(0, 0, 0, 0.02);
  outline: none;
  box-sizing: border-box;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.gate-avatar-field input[type="url"]:focus,
.gate-avatar-field input[type="text"]:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.gate-avatar-field input::placeholder {
  color: #c4c4c4;
}

/* Checkbox row */
.gate-avatar-field--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0;
}

.gate-avatar-field--row span {
  margin-bottom: 0;
}

.gate-avatar-field--row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #6366f1;
  cursor: pointer;
}

/* Save button */
.gate-avatar-save {
  width: 100%;
  margin-top: 6px;
  padding: 7px 0;
  border: none;
  border-radius: 7px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition:
    opacity 0.15s,
    transform 0.1s;
}

.gate-avatar-save:hover {
  opacity: 0.9;
}

.gate-avatar-save:active {
  transform: scale(0.97);
}

.gate-avatar-save--done {
  background: #34d399 !important;
}

/* ── Dark Mode ── */
@media (prefers-color-scheme: dark) {
  .gate-avatar-panel {
    background: rgba(30, 41, 59, 0.97);
    box-shadow:
      0 6px 28px rgba(0, 0, 0, 0.4),
      0 1px 3px rgba(0, 0, 0, 0.2);
  }

  .gate-avatar-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
  }

  .gate-avatar-panel::before {
    background: rgba(30, 41, 59, 0.97);
  }

  .gate-avatar-panel--flip-y::before {
    background: rgba(30, 41, 59, 0.97);
  }

  .gate-avatar-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
  }

  .gate-avatar-name {
    color: #f1f5f9;
  }

  .gate-avatar-domain {
    color: #64748b;
  }

  .gate-avatar-divider {
    background: rgba(255, 255, 255, 0.08);
  }

  .gate-avatar-field span {
    color: #94a3b8;
  }

  .gate-avatar-field input[type="url"],
  .gate-avatar-field input[type="text"] {
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
  }

  .gate-avatar-field input[type="url"]:focus,
  .gate-avatar-field input[type="text"]:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.2);
  }

  .gate-avatar-field input::placeholder {
    color: #475569;
  }

  .gate-avatar-logout {
    background: rgba(220, 38, 38, 0.15);
    color: #fca5a5;
  }

  .gate-avatar-logout:hover {
    background: rgba(220, 38, 38, 0.25);
  }

  .gate-avatar-logout:active {
    background: rgba(220, 38, 38, 0.35);
  }

  .gate-avatar-btn {
    border-color: rgba(255, 255, 255, 0.5);
  }

  .gate-avatar-save {
    background: linear-gradient(135deg, #818cf8, #6366f1);
  }
}

/* ── Compact / minimized state ── */
#gate-avatar-root.gate-avatar--compact .gate-avatar-btn {
  width: 22px;
  height: 22px;
  font-size: 10px;
  border-width: 1.5px;
}

#gate-avatar-root.gate-avatar--compact .gate-avatar-online {
  width: 5px;
  height: 5px;
}
