/* MSN / Windows Live Messenger — tema do chat flutuante (sobrescreve style.css no .msn-chat-root) */

.msn-chat-root {
  --msn-bar: linear-gradient(180deg, #2b7fd6 0%, #0f5cad 55%, #0a4a8f 100%);
  --msn-bar-border: #003d7a;
  --msn-bg: #dce8f5;
  --msn-row-glass: rgba(255, 255, 255, 0.38);
  --msn-bubble-me: linear-gradient(180deg, #4a9eff 0%, #1e7fe0 100%);
  --msn-bubble-other: #ffffff;
  --msn-text: #1a1a1a;
  --msn-wink-bar: linear-gradient(180deg, #d0dff2 0%, #c2d4eb 100%);
}

.msn-chat-root #chat-toggle.chat-toggle-btn {
  pointer-events: auto;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

.msn-chat-root .chat-toggle-btn {
  background: linear-gradient(180deg, #6ec030 0%, #3d8c1a 100%);
  border: 1px solid #2d6a14;
  border-radius: 6px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 4px 12px rgba(0, 0, 0, 0.35);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
}

.msn-chat-root .chat-toggle-btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.msn-chat-root .chat-toggle-energy {
  font-size: 18px;
  line-height: 1;
  filter: drop-shadow(0 0 6px rgba(255, 235, 120, 0.85)) drop-shadow(0 1px 0 rgba(0, 0, 0, 0.35));
}

.msn-chat-root .chat-box.msn-chat-window {
  width: 320px;
  height: 520px;
  max-height: min(520px, calc(100vh - 100px));
  border-radius: 4px;
  border: 1px solid #0a3d7a;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12) inset,
    0 12px 40px rgba(0, 0, 0, 0.55);
  background: var(--msn-bg);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.msn-chat-root .chat-header.msn-chat-titlebar {
  background: var(--msn-bar);
  border-bottom: 1px solid var(--msn-bar-border);
  padding: 8px 10px;
  cursor: move;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

/* Canal/contato pela lista lateral — combobox redundante no título */
.msn-chat-root #chat-target-select {
  display: none !important;
}

.msn-chat-root .msn-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.msn-chat-root .msn-title-icon {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: linear-gradient(135deg, #7ec8ff 0%, #1e6fd4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.msn-chat-root .msn-title-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.msn-chat-root .msn-title-main {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
}

.msn-chat-root .msn-title-sub {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.88);
  font-weight: 500;
}

.msn-chat-root .chat-header .btn-icon-s {
  color: #fff !important;
  opacity: 0.95;
}

.msn-chat-root .chat-header .btn-icon-s:hover {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* Lista principal — linhas compactas como MSN (não “pílulas” altas) */
.msn-chat-root .chat-online-list {
  display: block;
  flex: 0 1 auto;
  min-height: 0;
  max-height: 38%;
  min-height: 108px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  padding: 6px 6px 7px;
  background:
    linear-gradient(180deg, rgba(210, 228, 248, 0.55) 0%, rgba(185, 210, 238, 0.4) 100%);
  -webkit-backdrop-filter: blur(12px) saturate(1.08);
  backdrop-filter: blur(12px) saturate(1.08);
  border-bottom: 1px solid rgba(70, 110, 165, 0.38);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.msn-chat-root .msn-contact-groups {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  max-width: 100%;
}

.msn-chat-root .msn-contact-title {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(30, 55, 90, 0.88);
  margin: 8px 2px 3px;
  padding-bottom: 2px;
  border-bottom: 1px solid rgba(80, 120, 170, 0.22);
}

.msn-chat-root .msn-contact-groups .msn-contact-title:first-child {
  margin-top: 0;
}

.msn-chat-root .msn-empty-contact {
  font-size: 10px;
  color: rgba(70, 95, 130, 0.85);
  padding: 3px 6px 4px;
  font-style: italic;
}

.msn-chat-root .online-user-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--msn-row-glass);
  border: 1px solid rgba(95, 130, 175, 0.38);
  border-left: 3px solid transparent;
  color: #152d4d;
  font-size: 11px;
  font-weight: 600;
  font-family: "Segoe UI", Tahoma, sans-serif;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  justify-content: flex-start;
  padding: 4px 8px;
  min-height: 26px;
  border-radius: 2px;
  transition: background 0.12s ease, border-color 0.12s ease;
  overflow: hidden;
}

.msn-chat-root .online-user-tag .dot {
  flex-shrink: 0;
}

.msn-chat-root .online-user-tag.msn-contact-row > span:not(.dot) {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msn-chat-root .online-user-tag.msn-contact-row:hover {
  background: rgba(255, 255, 255, 0.58);
  border-color: rgba(70, 120, 190, 0.5);
}

.msn-chat-root .online-user-tag.msn-contact-row--active {
  outline: none;
  border-left-color: #1e6fd4;
  background: linear-gradient(90deg, rgba(200, 225, 255, 0.75) 0%, rgba(255, 255, 255, 0.45) 100%);
  border-color: rgba(70, 130, 200, 0.55);
  box-shadow: inset 0 0 0 1px rgba(30, 111, 212, 0.2);
}

.msn-chat-root .online-user-tag.online {
  border-left-color: rgba(46, 160, 67, 0.55);
}

.msn-chat-root .online-user-tag.waiting {
  border-left-color: rgba(217, 119, 6, 0.85);
}

.msn-chat-root .chat-messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(180deg, rgba(200, 218, 242, 0.35) 0%, rgba(185, 205, 235, 0.5) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cpath fill='%23a8bdd4' fill-opacity='.1' d='M0 0h40v40H0zm40 40h40v40H40z'/%3E%3C/svg%3E");
  padding: 8px;
  gap: 8px;
  display: flex;
  flex-direction: column;
}

/* Boas-vindas na Sala de Contatos (sem duplicar a lista) */
.msn-contacts-welcome {
  margin: auto;
  max-width: 280px;
  text-align: center;
  padding: 10px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.38);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(100, 140, 190, 0.4);
  box-shadow: 0 1px 8px rgba(20, 60, 120, 0.06);
}

.msn-contacts-welcome-icon {
  font-size: 22px;
  line-height: 1;
  margin-bottom: 6px;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.8));
}

.msn-contacts-welcome-title {
  font-size: 12px;
  font-weight: 700;
  color: #1a3d5f;
  margin-bottom: 6px;
}

.msn-contacts-welcome-text,
.msn-contacts-welcome-hint {
  font-size: 11px;
  line-height: 1.4;
  color: #3d5577;
  margin: 0 0 6px 0;
}

.msn-contacts-welcome-hint {
  margin-bottom: 0;
  opacity: 0.88;
  font-size: 10px;
}

.msn-room {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid #b7cbe4;
  border-radius: 8px;
  padding: 10px;
}

.msn-room-title {
  font-size: 13px;
  font-weight: 700;
  color: #204567;
}

.msn-room-sub {
  font-size: 11px;
  color: #4c6787;
  margin-bottom: 8px;
}

.msn-room-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.msn-room-card {
  border: 1px solid #97b2d3;
  border-radius: 6px;
  background: linear-gradient(180deg, #ffffff 0%, #e8f0fb 100%);
  color: #1e3f62;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  cursor: pointer;
}

.msn-room-card.online { border-color: #6bb086; }
.msn-room-card.offline { opacity: 0.92; }
.msn-room-card:hover { filter: brightness(1.04); }

.msn-chat-root .chat-msg.msn-msg {
  max-width: 88%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.msn-chat-root .chat-msg.msn-msg.me {
  background: var(--msn-bubble-me);
  color: #fff;
  border-bottom-right-radius: 2px;
  border-color: rgba(0, 80, 160, 0.45);
}

.msn-chat-root .chat-msg.msn-msg.other {
  background: var(--msn-bubble-other);
  color: var(--msn-text);
  border-bottom-left-radius: 2px;
}

.msn-chat-root .chat-msg.msn-msg .chat-sender {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 4px;
}

.msn-chat-root .chat-msg.msn-msg.me .chat-sender {
  color: rgba(255, 255, 255, 0.92);
}

.msn-chat-root .chat-msg.msn-msg.other .chat-sender {
  color: #1565c0;
}

.msn-chat-root .chat-msg.msn-msg .chat-text {
  word-break: break-word;
  white-space: pre-wrap;
}

.msn-chat-root .chat-msg.msn-msg .chat-time {
  font-size: 10px;
  margin-top: 4px;
  opacity: 0.75;
}

.msn-chat-root .chat-msg.msn-msg.me .chat-time {
  color: rgba(255, 255, 255, 0.85);
}

/* Winks — menu em popover acionado pelo ícone ✨ */
.msn-chat-composer {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.msn-wink-popover {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: calc(100% + 4px);
  z-index: 35;
  display: none;
  border-radius: 6px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.38);
  border: 1px solid #7a9bc4;
  overflow: hidden;
  max-height: min(280px, 48vh);
  overflow-y: auto;
}

.msn-wink-popover.is-open {
  display: block;
}

.msn-wink-popover .msn-wink-toolbar {
  border-top: none;
  border-bottom: none;
}

.msn-wink-toolbar-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.msn-wink-toolbar-top .msn-chamar-atencao-btn {
  flex: 1 1 0;
  min-width: 120px;
}

.msn-chat-root .btn-wink-menu {
  flex-shrink: 0;
  width: 36px;
  min-width: 36px;
  height: 34px;
  padding: 0;
  margin: 0;
  border-radius: 3px;
  border: 1px solid rgba(90, 125, 175, 0.65);
  background: linear-gradient(180deg, #fff 0%, #e4ecf7 100%);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: background 0.12s ease, transform 0.1s ease;
}

.msn-chat-root .btn-wink-menu:hover {
  background: linear-gradient(180deg, #fff 0%, #d4e5ff 100%);
}

.msn-chat-root .btn-wink-menu:active {
  transform: scale(0.96);
}

.msn-chat-root .btn-wink-menu.is-open {
  background: linear-gradient(180deg, #c8ddfa 0%, #a8c8f0 100%);
  border-color: #4a7eb8;
}

/* Winks */
.msn-wink-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--msn-wink-bar);
  border-top: 1px solid #b0c4de;
  border-bottom: 1px solid #9bb3d4;
  flex-shrink: 0;
}

.msn-wink-label-bar {
  font-size: 10px;
  font-weight: 700;
  color: #2a4a6e;
  width: 100%;
  margin-bottom: 2px;
  letter-spacing: 0.02em;
}

.msn-wink-btn {
  width: 32px;
  height: 28px;
  border: 1px solid #8fa8c8;
  border-radius: 4px;
  background: linear-gradient(180deg, #fff 0%, #e4ecf7 100%);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0;
  transition: transform 0.12s ease, background 0.12s ease;
}

.msn-wink-btn:hover {
  background: linear-gradient(180deg, #fff 0%, #d4e5ff 100%);
  transform: scale(1.08);
}

.msn-wink-btn:active {
  transform: scale(0.96);
}

.msn-wink-bubble {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 12px;
  min-width: 120px;
  text-align: center;
  border-radius: 8px;
  animation: msn-wink-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.msn-chat-root .chat-msg.msn-msg.me .msn-wink-bubble {
  background: rgba(255, 255, 255, 0.12);
  border: 1px dashed rgba(255, 255, 255, 0.45);
}

.msn-chat-root .chat-msg.msn-msg.other .msn-wink-bubble {
  background: linear-gradient(180deg, #f0f7ff 0%, #dce9fb 100%);
  border: 1px solid #9bb8e0;
}

.msn-wink-emoji {
  font-size: 36px;
  line-height: 1;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.12));
}

.msn-wink-label {
  font-size: 12px;
  font-weight: 700;
  font-family: "Segoe UI", Tahoma, sans-serif;
}

.msn-chat-root .chat-msg.msn-msg.me .msn-wink-label {
  color: rgba(255, 255, 255, 0.95);
}

.msn-chat-root .chat-msg.msn-msg.other .msn-wink-label {
  color: #0d47a1;
}

.msn-wink-bubble[data-kind="nudge"] .msn-wink-emoji {
  animation: msn-wink-nudge-emoji 0.6s ease;
}

@keyframes msn-wink-pop {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  70% {
    transform: scale(1.05);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

@keyframes msn-wink-nudge-emoji {
  0%,
  100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-12deg) scale(1.1);
  }
  75% {
    transform: rotate(12deg) scale(1.1);
  }
}

/* Nudge: treme a janela inteira (ou o botão MSN se o chat estiver fechado) */
.msn-chat-window.msn-nudge-shake,
.msn-chat-root .chat-toggle-btn.msn-nudge-shake {
  animation: msn-window-shake 0.55s ease;
}

@keyframes msn-window-shake {
  0%,
  100% {
    transform: translate(0, 0);
  }
  12% {
    transform: translate(-8px, 3px) rotate(-0.5deg);
  }
  25% {
    transform: translate(8px, -3px) rotate(0.5deg);
  }
  37% {
    transform: translate(-7px, 4px);
  }
  50% {
    transform: translate(7px, -4px);
  }
  62% {
    transform: translate(-5px, 2px);
  }
  75% {
    transform: translate(5px, -2px);
  }
}

.msn-chat-root .chat-input-area {
  display: flex;
  align-items: center;
  background: linear-gradient(180deg, #d8e6f6 0%, #cadcf0 100%);
  border-top: 1px solid rgba(100, 140, 185, 0.45);
  padding: 6px 8px;
  flex-shrink: 0;
  gap: 6px;
}

.msn-chat-root .chat-input-area input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(90, 125, 175, 0.55);
  color: #111;
  border-radius: 2px;
  font-family: "Segoe UI", Tahoma, sans-serif;
  font-size: 12px;
  padding: 7px 9px;
  min-height: 34px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

.msn-chat-root .chat-input-area input::placeholder {
  color: #6b7a8f;
}

.msn-chat-root .chat-input-area .btn-primary {
  background: linear-gradient(180deg, #5a9fd4 0%, #2a7bc8 100%);
  border: 1px solid #1a5a9e;
  border-radius: 2px;
  font-weight: 600;
  font-size: 11px;
  padding: 0 12px;
  min-height: 34px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.msn-chat-root .chat-input-area .btn-primary:hover {
  filter: brightness(1.06);
}

/* Botão estilo MSN — Chamar atenção (Nudge) */
.msn-chamar-atencao-btn {
  font-family: "Segoe UI", Tahoma, sans-serif;
  font-size: 10px;
  font-weight: 700;
  padding: 5px 10px;
  margin-right: 0;
  border-radius: 3px;
  border: 1px solid #8b4513;
  background: linear-gradient(180deg, #ffd080 0%, #f5a623 100%);
  color: #3d2200;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
  white-space: nowrap;
}

.msn-chamar-atencao-btn:hover {
  filter: brightness(1.05);
}

.msn-chamar-atencao-btn:active {
  transform: scale(0.98);
}

/* Barra assistente financeiro (ADMIN) */
.chat-ia-financeiro-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 4px 8px 5px;
  background: linear-gradient(180deg, rgba(210, 235, 210, 0.75) 0%, rgba(190, 225, 195, 0.55) 100%);
  border-top: 1px solid rgba(100, 160, 100, 0.35);
  font-family: "Segoe UI", Tahoma, sans-serif;
  font-size: 10px;
  color: #143818;
}

.chat-ia-financeiro-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.chat-ia-financeiro-label input {
  margin: 0;
}

.chat-ia-hint {
  opacity: 0.85;
  font-size: 10px;
}

.chat-ia-hint kbd {
  background: rgba(0, 0, 0, 0.08);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
}

/* Mensagem do assistente no histórico do chat */
.msn-chat-root .chat-msg.assistant-financeiro {
  align-self: stretch;
  max-width: 100%;
  background: linear-gradient(180deg, #f3e8ff 0%, #e9d5ff 100%);
  border: 1px solid #c4b5fd;
}

.msn-chat-root .chat-msg.assistant-financeiro .chat-sender {
  color: #5b21b6;
  font-weight: 700;
}

.msn-chat-root .chat-msg.assistant-financeiro--err {
  background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%);
  border-color: #f87171;
}

.msn-chat-root .chat-msg.assistant-financeiro--err .chat-sender {
  color: #991b1b;
}

.msn-assistant-body {
  font-size: 12px;
  line-height: 1.45;
}

.msn-chat-root .chat-ia-financeiro-bar {
  flex-shrink: 0;
}

/* Uma tela por vez: Sala de Contatos (só Canais) OU conversa (mensagens + composição) */
.msn-chat-root .chat-box.msn-chat-contacts-mode #chat-messages,
.msn-chat-root .chat-box.msn-chat-contacts-mode #chat-ia-financeiro-bar,
.msn-chat-root .chat-box.msn-chat-contacts-mode .msn-chat-composer {
  display: none !important;
}

.msn-chat-root .chat-box.msn-chat-conversation-mode #chat-online-list {
  display: none !important;
}

.msn-chat-root .chat-box.msn-chat-contacts-mode .chat-online-list {
  flex: 1 1 auto;
  max-height: none;
  min-height: 0;
}

.msn-chat-root .chat-box.msn-chat-conversation-mode #chat-messages {
  display: flex;
  flex-direction: column;
}
