/* ===================================================
   CHAT WIDGET - Edge Glass style
   Variables inherited from base: --bg-deep, --accent (#FFFF00)
=================================================== */

/* -- FAB wrapper -- */
#chat-fab-wrapper {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 500;
}

#chat-fab {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 0, 0.15);
  border: 1px solid rgba(255, 255, 0, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #FFFF00;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.2s, transform 0.15s;
}

#chat-fab svg {
  width: 22px;
  height: 22px;
  display: block;
  flex-shrink: 0;
}

#chat-fab:hover {
  background: rgba(255, 255, 0, 0.25);
  transform: scale(1.06);
}

.chat-unread-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* -- Widget panel -- */
.chat-widget {
  position: fixed;
  bottom: 74px;
  left: 20px;
  width: 320px;
  max-height: calc(100dvh - 64px - 90px);
  background: rgba(10, 10, 20, 0.75);
  border: 1px solid rgba(255, 255, 0, 0.2);
  border-radius: 12px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 500;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}

.chat-widget.is-open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* -- Header -- */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 0, 0.12);
  flex-shrink: 0;
}

.chat-header__title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #FFFF00;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex: 1;
  margin: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header__close,
.chat-header__back {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s;
  flex-shrink: 0;
}

.chat-header__close:hover,
.chat-header__back:hover {
  color: #fff;
}

/* -- Body (scrollable) -- */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,0,0.2) transparent;
}

/* -- Conversation list -- */
.chat-conv-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.06);
  transition: background 0.15s;
}

.chat-conv-item:hover {
  background: rgba(255,255,255,0.06);
}

.chat-conv-item.has-unread {
  background: rgba(255, 255, 0, 0.06);
  border-color: rgba(255, 255, 0, 0.2);
}

.chat-conv-item__name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #e5e5e5;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-conv-item__preview {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.4);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-unread-badge {
  background: #ef4444;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
}

/* -- Messages -- */
.chat-msg {
  max-width: 82%;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 0.8rem;
  line-height: 1.4;
  word-break: break-word;
}

.chat-msg--mine {
  align-self: flex-end;
  background: rgba(255, 255, 0, 0.15);
  border: 1px solid rgba(255, 255, 0, 0.25);
  color: #fff;
  border-bottom-right-radius: 3px;
}

.chat-msg--theirs {
  align-self: flex-start;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  color: #d4d4d4;
  border-bottom-left-radius: 3px;
}

.chat-msg__time {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.3);
  margin-top: 3px;
  text-align: right;
}

/* -- Input bar -- */
.chat-footer {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid rgba(255,255,0,0.12);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: #fff;
  font-size: 0.8rem;
  padding: 6px 10px;
  outline: none;
  resize: none;
  font-family: inherit;
  max-height: 80px;
}

.chat-input::placeholder { color: rgba(255,255,255,0.3); }
.chat-input:focus { border-color: rgba(255,255,0,0.35); }

.chat-send-btn {
  background: rgba(255,255,0,0.15);
  border: 1px solid rgba(255,255,0,0.35);
  border-radius: 8px;
  color: #FFFF00;
  cursor: pointer;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  transition: background 0.15s;
  align-self: flex-end;
}

.chat-send-btn:hover {
  background: rgba(255,255,0,0.25);
}

/* -- Empty state -- */
.chat-empty {
  text-align: center;
  color: rgba(255,255,255,0.3);
  font-size: 0.8rem;
  padding: 20px 0;
}

/* -- Hint placeholder (athlete, no messages yet) -- */
.chat-hint {
  text-align: center;
  color: rgba(255,255,0,0.45);
  font-size: 0.8rem;
  font-style: italic;
  padding: 24px 16px;
  line-height: 1.5;
}

/* -- No-coach state -- */
.chat-no-coach {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 16px;
  text-align: center;
}

.chat-no-coach p {
  color: rgba(255,255,255,0.5);
  font-size: 0.82rem;
  margin: 0;
}

.chat-no-coach__link {
  color: #FFFF00;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid rgba(255,255,0,0.35);
  border-radius: 8px;
  padding: 6px 14px;
  background: rgba(255,255,0,0.08);
  transition: background 0.15s;
}

.chat-no-coach__link:hover {
  background: rgba(255,255,0,0.18);
}

/* -- Mobile -- */
@media (max-width: 480px) {
  #chat-fab-wrapper { left: 16px; }
  .chat-widget {
    width: calc(100vw - 32px);
    left: 16px;
    /* Grow naturally from FAB upward, capped so it never overlaps the fixed header */
    max-height: calc(100dvh - var(--header-h) - 90px);
  }
  .chat-header { padding: 8px 12px; }
  .chat-body { padding: 8px 10px; gap: 5px; }
  .chat-msg { font-size: 0.77rem; padding: 6px 9px; }
  .chat-footer { padding: 6px 8px; }
  .chat-input { font-size: 0.78rem; padding: 5px 9px; }
}
