/* website/chat/chat.css */

.protonox-chat-button {
  position: fixed;
  right: 20px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #1d4ed8, #22d3ee);
  color: #f8fafc;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.35);
  z-index: 1200;
}

.protonox-chat-button:hover {
  transform: translateY(-2px);
}

.protonox-chat-button .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  padding: 0 6px;
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 18px;
  text-align: center;
}

.protonox-chat-popup {
  position: fixed;
  bottom: 92px;
  right: 20px;
  width: min(360px, 90vw);
  max-height: 70vh;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.95);
  color: #f8fafc;
  display: none;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.45);
  overflow: hidden;
  z-index: 1300;
}

body.light-mode .protonox-chat-popup {
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
}

.protonox-chat-popup.is-open {
  display: flex;
}

.chat-popup__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.chat-popup__tabs {
  display: flex;
  gap: 0.5rem;
}

.chat-popup__tabs button {
  border: none;
  background: transparent;
  color: inherit;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.chat-popup__tabs button.is-active {
  background: rgba(59, 130, 246, 0.28);
}

.chat-popup__close {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.2rem;
  cursor: pointer;
}

.chat-popup__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.chat-panel {
  display: none;
  flex: 1;
}

.chat-panel.is-active {
  display: flex;
}

.chat-panel[data-panel="global"] {
  flex-direction: column;
}

.chat-panel[data-panel="threads"].is-active {
  display: grid;
  grid-template-columns: minmax(150px, 200px) 1fr;
  gap: 0.75rem;
}

.chat-threads {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-right: 1px solid rgba(148, 163, 184, 0.2);
  padding: 0.75rem;
  overflow-y: auto;
}

.chat-threads__section {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.chat-threads__section h4 {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.75;
}

.chat-threads__list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.chat-threads__list button {
  border: none;
  border-radius: 10px;
  padding: 0.4rem 0.55rem;
  background: rgba(148, 163, 184, 0.18);
  color: inherit;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.chat-threads__list button.is-active {
  background: rgba(59, 130, 246, 0.4);
  color: #0f172a;
}

.chat-thread__name {
  font-size: 0.85rem;
  font-weight: 600;
}

.chat-thread__meta {
  font-size: 0.7rem;
  opacity: 0.7;
}

.chat-thread-body {
  flex: 1;
  padding: 0.75rem;
}

.chat-thread-info {
  padding: 0.5rem 0.6rem;
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.16);
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.6rem;
}

.chat-thread-info strong {
  font-weight: 600;
}

.chat-thread-info span {
  font-size: 0.7rem;
  opacity: 0.75;
}

.chat-directory {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 200px;
  overflow-y: auto;
}

.chat-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.18);
}

.chat-user.is-suggested {
  background: rgba(34, 197, 94, 0.18);
}

.chat-user__main {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.chat-user__status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f97316;
  opacity: 0.8;
}

.chat-user__status.is-online {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.chat-user__info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  gap: 0.15rem;
}

.chat-user__info strong {
  font-size: 0.85rem;
  font-weight: 600;
}

.chat-user__info span {
  font-size: 0.7rem;
  opacity: 0.7;
}

.chat-user__action {
  border: none;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #0f172a;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}

.chat-user__action:disabled {
  background: rgba(148, 163, 184, 0.25);
  color: rgba(226, 232, 240, 0.65);
  cursor: default;
}

body.light-mode .chat-user {
  background: rgba(148, 163, 184, 0.2);
}

body.light-mode .chat-user.is-suggested {
  background: rgba(34, 197, 94, 0.22);
}

body.light-mode .chat-thread-info {
  background: rgba(148, 163, 184, 0.28);
  color: #0f172a;
}

body.light-mode .chat-thread-info span {
  opacity: 0.7;
}

body.light-mode .chat-user__action:disabled {
  color: rgba(51, 65, 85, 0.65);
}

.chat-messages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 280px;
  overflow-y: auto;
}

.chat-messages li {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.45);
  font-size: 0.9rem;
}

.chat-messages li.is-self {
  align-self: flex-end;
  background: rgba(59, 130, 246, 0.45);
  color: #0f172a;
}

.chat-message__author {
  font-size: 0.75rem;
  opacity: 0.75;
}

.chat-message__text {
  line-height: 1.35;
  word-break: break-word;
}

.chat-messages time {
  font-size: 0.7rem;
  opacity: 0.6;
  align-self: flex-end;
}

.chat-popup__footer {
  padding: 0.65rem 0.75rem;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.chat-popup__footer form {
  display: flex;
  gap: 0.5rem;
}

.chat-popup__status {
  margin-top: 0.45rem;
  font-size: 0.75rem;
  line-height: 1.3;
  color: rgba(226, 232, 240, 0.75);
}

.chat-popup__status.is-error {
  color: #f87171;
}

body.light-mode .protonox-chat-popup .chat-popup__status {
  color: #334155;
}

body.light-mode .protonox-chat-popup .chat-popup__status.is-error {
  color: #b91c1c;
}

.chat-popup__footer input {
  flex: 1;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  padding: 0.45rem 0.6rem;
  background: rgba(15, 23, 42, 0.35);
  color: inherit;
}

.chat-popup__footer button {
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #0f172a;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
}

.chat-empty {
  font-size: 0.85rem;
  opacity: 0.7;
}

/* Vista completa */
.chat-full {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
}

.chat-full__sidebar {
  background: rgba(15, 23, 42, 0.4);
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

body.light-mode .chat-full__sidebar {
  background: rgba(226, 232, 240, 0.65);
}

.chat-full__threads {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.chat-full__threads button {
  border-radius: 12px;
  border: none;
  padding: 0.55rem 0.75rem;
  background: rgba(148, 163, 184, 0.25);
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.chat-full__threads button.is-active {
  background: rgba(59, 130, 246, 0.45);
  color: #0f172a;
}

.chat-full__directory {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 220px;
  overflow-y: auto;
}

.chat-full__body {
  background: rgba(15, 23, 42, 0.35);
  border-radius: 16px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

body.light-mode .chat-full__body {
  background: rgba(248, 250, 252, 0.8);
}

.chat-full__status {
  font-size: 0.85rem;
  color: rgba(226, 232, 240, 0.75);
}

.chat-full__status.is-error {
  color: #f87171;
}

body.light-mode .chat-full__status {
  color: #475569;
}

body.light-mode .chat-full__status.is-error {
  color: #b91c1c;
}

.chat-full__panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.chat-full__global ul,
.chat-full__private ul {
  max-height: 320px;
  overflow-y: auto;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.chat-full__composer {
  display: flex;
  gap: 0.75rem;
}

.chat-full__composer input {
  flex: 1;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  padding: 0.6rem 0.75rem;
  background: rgba(15, 23, 42, 0.35);
  color: inherit;
}

.chat-full__composer button {
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #22d3ee, #6366f1);
  padding: 0.55rem 1.2rem;
  color: #0f172a;
  cursor: pointer;
}

@media (max-width: 820px) {
  .chat-full {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .chat-panel[data-panel="threads"].is-active {
    grid-template-columns: 1fr;
  }
  .chat-threads {
    border-right: none;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
  }
}
