/* ==========================================================================
   Sign-in, store picker and sidebar store chip (static/sunny/js/sunny-auth.js)

   Uses sunny.css's theme tokens only, so light/dark follows the page toggle
   (<html data-theme>). sunny.css itself is unchanged.
   ========================================================================== */

/* Nobody signed in: the chat is never painted, only the sign-in card. */
html.sunny-auth-locked .sunny-app {
  visibility: hidden;
}

.sunny-auth [hidden],
.sunny-auth[hidden],
.sunny-store[hidden] {
  display: none !important;
}

/* ---------- Gate ---------- */
.sunny-auth {
  position: fixed;
  inset: 0;
  z-index: 10000; /* above .sunny-modal */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px max(16px, env(safe-area-inset-left, 0px));
  overflow-y: auto;
  background: var(--sunny-canvas);
  background: var(--sunny-surface);
  font-family: var(--sunny-font-ui);
}

/* Change store over a live chat: the chat stays visible, dimmed. */
.sunny-auth--overlay {
  background: rgba(0, 0, 0, 0.5);
}

.sunny-auth.is-busy {
  cursor: progress;
}

.sunny-auth__card {
  width: 100%;
  max-width: 420px;
  margin: auto 0;
  padding: 32px 28px 28px;
  border: 1px solid var(--sunny-modal-border);
  border-radius: 16px;
  background: var(--sunny-modal-bg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.sunny-auth__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.sunny-auth__brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.sunny-auth__brand span {
  color: var(--sunny-brand-text);
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
}

.sunny-auth__step {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0;
}

.sunny-auth__title {
  margin: 0;
  color: var(--sunny-modal-title);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
}

.sunny-auth__lede {
  margin: -6px 0 4px;
  color: var(--sunny-modal-text);
  font-size: 14px;
}

.sunny-auth__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--sunny-modal-title);
  font-size: 13px;
  font-weight: 500;
}

.sunny-auth__field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--sunny-modal-border);
  border-radius: 10px;
  background: var(--sunny-composer-bg);
  color: var(--sunny-composer-text);
  font: inherit;
  font-size: 15px;
  font-weight: 400;
}

.sunny-auth__field input::placeholder {
  color: var(--sunny-composer-placeholder);
}

.sunny-auth__field input:focus {
  outline: 2px solid #54d6c7;
  outline-offset: 1px;
  border-color: transparent;
}

.sunny-auth__primary {
  margin-top: 4px;
  padding: 11px;
  border-radius: 12px;
  background: linear-gradient(109.51deg, #fddd95 -0.48%, #b5eda3 63.08%);
  background-size: 200% 100%;
  background-position: 0% 0%;
  color: #0b1932;
  font-size: 16px;
  font-weight: 600;
  transition: background-position 0.5s ease-in-out;
}

.sunny-auth__primary:hover:not(:disabled) {
  background-position: 100% 0%;
}

.sunny-auth__primary:disabled {
  opacity: 0.7;
  cursor: progress;
}

.sunny-auth__secondary {
  padding: 10px 16px;
  border: 1px solid var(--sunny-modal-cancel-border);
  border-radius: 10px;
  background: var(--sunny-modal-cancel-bg);
  color: var(--sunny-modal-cancel-text);
  font-size: 14px;
  font-weight: 500;
}

.sunny-auth__secondary:hover {
  background: var(--sunny-modal-cancel-hover);
}

.sunny-auth__link {
  color: var(--sunny-modal-title);
  font-size: inherit;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sunny-auth button:focus-visible {
  outline: 2px solid #54d6c7;
  outline-offset: 2px;
}

.sunny-auth__error {
  margin: 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.08);
  color: #b42318;
  font-size: 14px;
}

[data-theme="dark"] .sunny-auth__error {
  background: rgba(239, 68, 68, 0.16);
  color: #fecaca;
}

.sunny-auth__env {
  margin: 2px 0 0;
  color: var(--sunny-modal-text);
  font-size: 12.5px;
  text-align: center;
  overflow-wrap: anywhere;
}

.sunny-auth__status {
  margin: 0;
  color: var(--sunny-modal-text);
  font-size: 14px;
}

.sunny-auth__status:empty {
  display: none;
}

/* ---------- Store list ---------- */
.sunny-auth__stores {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: min(50vh, 360px);
  margin: 0 -4px;
  padding: 0 4px;
  overflow-y: auto;
}

.sunny-auth__stores:empty {
  display: none;
}

.sunny-auth__store {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--sunny-modal-border);
  border-radius: 10px;
  background: var(--sunny-card-bg);
  text-align: left;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.sunny-auth__store:hover:not(:disabled) {
  background: var(--sunny-item-active-bg);
}

.sunny-auth__store.is-current {
  border-color: #54d6c7;
}

.sunny-auth__store:disabled {
  opacity: 0.6;
  cursor: progress;
}

.sunny-auth__store-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  color: var(--sunny-modal-title);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
}

.sunny-auth__store-meta {
  overflow: hidden;
  color: var(--sunny-modal-text);
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sunny-auth__tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--sunny-item-active-bg);
  color: var(--sunny-item-text);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
}

.sunny-auth__tag--current {
  background: rgba(84, 214, 199, 0.18);
}

@media (max-width: 480px) {
  .sunny-auth {
    align-items: flex-start;
  }

  .sunny-auth__card {
    padding: 24px 20px 20px;
  }
}

/* ---------- Sidebar store chip (top of .sunny-sidebar__footer) ---------- */
.sunny-store {
  margin-bottom: 8px;
  padding: 10px 12px;
  border: 1px solid var(--sunny-sidebar-footer-border);
  border-radius: 8px;
}

.sunny-store__info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sunny-store__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--sunny-item-text);
}

.sunny-store__text {
  min-width: 0;
}

.sunny-store__name,
.sunny-store__user {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sunny-store__name {
  color: var(--sunny-sidebar-text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.sunny-store__user {
  color: var(--sunny-muted);
  font-size: 12px;
  line-height: 1.4;
}

.sunny-store__actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.sunny-store__btn {
  flex: 1;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--sunny-hover-bg);
  color: var(--sunny-item-text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.15s ease;
}

.sunny-store__btn:hover {
  background: var(--sunny-item-active-bg);
}

.sunny-store__btn:focus-visible {
  outline: 2px solid #54d6c7;
  outline-offset: 2px;
}
