/* ============================================================
   /staff/assets/css/message-button.css — v1.0
   Drop-in message button with channel dropdown + quick popup
   ============================================================ */

/* ─── The trigger button itself (any styling is fine) ──── */
.msg-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  overflow: visible;
}

/* ─── Two glowing dots traveling along the border ────────
   Both dots animate offset-distance 0→100%, but with
   different starting offsets via separate keyframes.
   This avoids the "catch-up" bug at rounded corners. */
.msg-btn::before,
.msg-btn::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent, #16a34a);
  box-shadow: 0 0 4px var(--accent, #16a34a),
              0 0 8px var(--accent, #16a34a);
  top: 0;
  left: 0;
  margin: -3px;   /* center on the path line */
  offset-path: border-box;
  pointer-events: none;
}
.msg-btn::before {
  animation: msg-btn-orbit-a 4s linear infinite;
}
.msg-btn::after {
  animation: msg-btn-orbit-b 4s linear infinite;
}
@keyframes msg-btn-orbit-a {
  from { offset-distance: 0%; }
  to   { offset-distance: 100%; }
}
@keyframes msg-btn-orbit-b {
  from { offset-distance: 50%; }
  to   { offset-distance: 150%; }
}

/* When dropdown is open, freeze rotation */
.msg-btn[aria-expanded="true"]::before,
.msg-btn[aria-expanded="true"]::after {
  animation-play-state: paused;
}

/* ─── Channel dropdown ──────────────────────────────────── */
.msg-dropdown {
  position: absolute;
  z-index: 10000;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  padding: .35rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  min-width: 200px;
  display: none;
}
.msg-dropdown.placed-above {
  /* When opening upward, shadow looks better cast upward */
  box-shadow: 0 -4px 16px rgba(0,0,0,.18);
}
.msg-dropdown.show { display: block; }

.msg-dropdown-item {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .5rem .7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: .88rem;
  color: var(--text, #18181b);
  background: transparent;
  border: none;
  width: 100%;
  text-align: right;
  font-family: inherit;
  transition: background .12s;
  text-decoration: none;
}
.msg-dropdown-item:hover {
  background: var(--surface2, #f4f4f5);
}
.msg-dropdown-item .msg-ic {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: .95rem;
  flex-shrink: 0;
  background: #6b7280;   /* default fallback */
}
.msg-dropdown-item .msg-ic.brand-sovellus { background: var(--accent, #16a34a); }
.msg-dropdown-item .msg-ic.brand-telegram { background: #229ED9; }
.msg-dropdown-item .msg-ic.brand-whatsapp { background: #25D366; }
.msg-dropdown-item .msg-ic.brand-email    { background: #EA4335; }
.msg-dropdown-item.disabled {
  opacity: .35;
  cursor: not-allowed;
  pointer-events: none;
}

[data-theme="dark"] .msg-dropdown {
  background: var(--surface2, #1f1f23);
  border-color: rgba(255,255,255,.1);
}
[data-theme="dark"] .msg-dropdown-item:hover {
  background: rgba(255,255,255,.06);
}

/* ─── In-app popup (Sovellus) ───────────────────────────── */
.msg-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.msg-popup-backdrop.show { display: flex; }

.msg-popup {
  background: var(--surface, #fff);
  border-radius: 12px;
  padding: 1rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  display: flex;
  flex-direction: column;
  gap: .75rem;
  max-height: 92vh;
  overflow-y: auto;
}
[data-theme="dark"] .msg-popup {
  background: var(--surface2, #1f1f23);
}

.msg-popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.msg-popup-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text, #18181b);
  margin: 0;
}
.msg-popup-recipient {
  font-size: .85rem;
  color: var(--text2, #6b7280);
}
.msg-popup-close {
  appearance: none;
  background: transparent;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text2, #6b7280);
  padding: .25rem .45rem;
  border-radius: 6px;
}
.msg-popup-close:hover { background: var(--surface2, #f4f4f5); }

.msg-popup-context {
  background: var(--surface2, #f4f4f5);
  border-right: 3px solid var(--accent, #16a34a);
  border-radius: 6px;
  padding: .55rem .7rem;
  font-size: .78rem;
  color: var(--text2, #6b7280);
  line-height: 1.5;
  white-space: pre-wrap;
}
[data-theme="dark"] .msg-popup-context {
  background: rgba(255,255,255,.04);
}

.msg-popup-textarea {
  width: 100%;
  padding: .65rem .8rem;
  font-size: .92rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  background: var(--surface, #fff);
  color: var(--text, #18181b);
  font-family: inherit;
  outline: none;
  min-height: 90px;
  resize: vertical;
  box-sizing: border-box;
}
.msg-popup-textarea:focus {
  border-color: var(--accent, #16a34a);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #16a34a) 15%, transparent);
}
[data-theme="dark"] .msg-popup-textarea {
  background: rgba(255,255,255,.04);
  border-color: rgba(255,255,255,.1);
  color: var(--text, #fff);
}

.msg-popup-actions {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
}
.msg-popup-btn {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--surface, #fff);
  color: var(--text, #18181b);
  padding: .55rem 1rem;
  font-size: .88rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: all .12s;
}
.msg-popup-btn:hover:not(:disabled) {
  background: var(--surface2, #f4f4f5);
}
.msg-popup-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.msg-popup-btn.primary {
  background: var(--accent, #16a34a);
  color: white;
  border-color: var(--accent, #16a34a);
}
.msg-popup-btn.primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

[data-theme="dark"] .msg-popup-btn {
  background: rgba(255,255,255,.04);
  border-color: rgba(255,255,255,.1);
}
