/*
 * Copyright (c) 2026 Leonardo Marchi. Tutti i diritti riservati.
 * Codice proprietario. Uso non autorizzato vietato.
 * Vedi NOTICE.txt per titolarita e condizioni d'uso.
 */

/* Chat widget */
.fullscreen-widget {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 69;
  width: auto;
}

.user-meta .fullscreen-widget {
  position: static;
  left: auto;
  bottom: auto;
  z-index: auto;
}

.user-meta .fullscreen-toggle {
  min-height: 30px;
  padding: 2px 11px 2px 4px;
  gap: 7px;
  border-color: rgba(156, 188, 242, 0.28);
  background: linear-gradient(180deg, rgba(34, 54, 99, 0.9), rgba(21, 33, 62, 0.94));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 8px rgba(4, 10, 22, 0.18);
}

.user-meta .fullscreen-toggle-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: #dbe9ff;
}

.user-meta .fullscreen-toggle-icon {
  font-size: 0.78rem;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid rgba(166, 193, 237, 0.22);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
  color: #eef5ff;
  flex: 0 0 auto;
}

.user-meta .fullscreen-toggle:hover {
  border-color: rgba(132, 177, 255, 0.46);
  background: linear-gradient(180deg, rgba(42, 66, 118, 0.95), rgba(22, 37, 71, 0.95));
}

.user-meta .fullscreen-toggle:focus-visible {
  outline: 2px solid rgba(109, 171, 255, 0.55);
  outline-offset: 2px;
}

.user-meta .fullscreen-toggle.is-active {
  border-color: rgba(73, 228, 145, 0.5);
  background: linear-gradient(180deg, rgba(27, 90, 60, 0.92), rgba(17, 55, 40, 0.94));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 14px rgba(10, 42, 29, 0.22);
}

.user-meta .fullscreen-toggle.is-active .fullscreen-toggle-icon {
  border-color: rgba(84, 240, 158, 0.26);
  background: rgba(65, 210, 137, 0.14);
  color: #d8ffea;
}

.fullscreen-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(166, 193, 237, 0.22);
  background: linear-gradient(180deg, rgba(28, 44, 83, 0.95), rgba(17, 27, 50, 0.95));
  color: #edf4ff;
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(4, 9, 18, 0.35);
}

.fullscreen-toggle:hover {
  border-color: rgba(120, 170, 255, 0.36);
}

.fullscreen-toggle.is-active {
  border-color: rgba(73, 228, 145, 0.52);
  background: linear-gradient(180deg, rgba(27, 89, 59, 0.95), rgba(18, 56, 40, 0.95));
  box-shadow: 0 12px 34px rgba(13, 62, 41, 0.38);
}

.fullscreen-toggle-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.fullscreen-toggle-label {
  line-height: 1;
}

.chat-widget {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 70;
  display: block;
  width: auto;
}

body[data-chat-side="left"] .chat-widget {
  left: 14px;
  right: auto;
}

.chat-widget[hidden] {
  display: none !important;
}

.chat-launcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(166, 193, 237, 0.22);
  background: linear-gradient(180deg, rgba(28, 44, 83, 0.95), rgba(17, 27, 50, 0.95));
  color: #edf4ff;
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(4, 9, 18, 0.35);
  position: relative;
  z-index: 2;
}

.chat-launcher:hover {
  border-color: rgba(120, 170, 255, 0.36);
}

.chat-launcher.has-unread-pulse {
  border-color: rgba(255, 111, 129, 0.34);
  animation: chatUnreadPulseSoft 2.2s ease-in-out infinite;
}

.chat-launcher.has-unread-pulse .chat-launcher-icon {
  color: #ffd6db;
}

@keyframes chatUnreadPulseSoft {
  0%, 100% {
    box-shadow: 0 10px 30px rgba(4, 9, 18, 0.35), 0 0 0 0 rgba(255, 90, 102, 0);
    background: linear-gradient(180deg, rgba(28, 44, 83, 0.95), rgba(17, 27, 50, 0.95));
  }
  50% {
    box-shadow: 0 10px 30px rgba(4, 9, 18, 0.35), 0 0 0 6px rgba(255, 90, 102, 0.10);
    background: linear-gradient(180deg, rgba(49, 39, 62, 0.97), rgba(33, 22, 40, 0.97));
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-launcher.has-unread-pulse {
    animation: none;
  }
}

.chat-launcher-icon {
  font-size: 1rem;
  line-height: 1;
}

.chat-unread-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ff5a66;
  color: #fff;
  font-size: 0.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.chat-unread-badge[hidden] {
  display: none !important;
}

.chat-panel {
  position: absolute;
  right: 0;
  bottom: 50px;
  width: min(680px, calc(100vw - 28px));
  height: min(460px, calc(100vh - 110px));
  border-radius: 14px;
  border: 1px solid rgba(166, 193, 237, 0.2);
  background:
    radial-gradient(120% 150% at 0% 0%, rgba(76, 121, 224, 0.08) 0%, rgba(17, 24, 40, 0.9) 48%, rgba(12, 18, 31, 0.96) 100%);
  box-shadow: 0 18px 48px rgba(4, 8, 16, 0.45);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  backdrop-filter: blur(6px);
  padding: 0;
}

body[data-chat-side="left"] .chat-panel {
  left: 0;
  right: auto;
}

.chat-panel[hidden] {
  display: none !important;
}

.chat-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px 9px;
  border-bottom: 1px solid rgba(166, 193, 237, 0.12);
  background: rgba(16, 24, 43, 0.92);
}

.chat-panel-head .btn-icon {
  width: 28px;
  min-width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  z-index: 3;
}

.chat-panel-title {
  display: grid;
  gap: 1px;
}

.chat-panel-title strong {
  font-family: "Rajdhani", sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #edf4ff;
  font-size: 0.88rem;
}

.chat-panel-title span {
  color: #a8c0ea;
  font-size: 0.72rem;
}

.chat-panel-body {
  display: grid;
  grid-template-columns: 182px 1fr;
  min-height: 0;
  height: 100%;
  gap: 0;
}

.chat-sidebar {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  border-right: 1px solid rgba(166, 193, 237, 0.1);
  background: linear-gradient(180deg, rgba(9, 14, 26, 0.88), rgba(8, 12, 22, 0.9));
}


.chat-sidebar-head {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(166, 193, 237, 0.1);
  color: #9fb7e1;
  font-family: "Rajdhani", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.chat-sidebar-search {
  padding: 6px;
  border-bottom: 1px solid rgba(166, 193, 237, 0.08);
}

.chat-sidebar-search .search {
  width: 100%;
  min-width: 0;
  height: 30px;
  padding: 6px 9px;
  font-size: 0.78rem;
  border-radius: 9px;
}

.chat-users-list {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 5px 6px 6px;
  display: grid;
  gap: 5px;
  align-content: start;
  grid-auto-rows: max-content;
  min-height: 0;
}

.chat-users-list,
.chat-thread-messages {
  scrollbar-width: thin;
  scrollbar-color: rgba(128, 166, 231, 0.58) rgba(255,255,255,0.03);
}

.chat-users-list::-webkit-scrollbar,
.chat-thread-messages::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.chat-users-list::-webkit-scrollbar-track,
.chat-thread-messages::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.02);
  border-radius: 999px;
}

.chat-users-list::-webkit-scrollbar-thumb,
.chat-thread-messages::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(108, 147, 224, 0.9), rgba(64, 103, 181, 0.9));
  border-radius: 999px;
  border: 1px solid rgba(13, 20, 38, 0.45);
}

.chat-users-list::-webkit-scrollbar-thumb:hover,
.chat-thread-messages::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(132, 172, 244, 0.95), rgba(75, 116, 197, 0.95));
}

.chat-user-item {
  width: 100%;
  border: 1px solid rgba(166, 193, 237, 0.12);
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  color: inherit;
  text-align: left;
  padding: 6px 7px;
  display: grid;
  gap: 2px;
  cursor: pointer;
  align-content: start;
}

.chat-user-item:hover {
  border-color: rgba(120, 170, 255, 0.28);
}

.chat-user-item.is-active {
  border-color: rgba(120, 170, 255, 0.35);
  background: rgba(90, 132, 224, 0.12);
}

.chat-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.chat-user-name {
  font-weight: 700;
  color: #eaf2ff;
  font-size: 0.72rem;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-user-unread {
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(255, 90, 102, 0.9);
  color: #fff;
  font-size: 0.62rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.chat-user-preview {
  color: #9bb2da;
  font-size: 0.6rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-thread {
  display: grid;
  grid-template-rows: 1fr auto;
  min-width: 0;
  min-height: 0;
  padding: 0;
  position: relative;
}

.chat-jump-latest {
  position: absolute;
  right: 10px;
  bottom: 56px;
  z-index: 3;
  height: 28px;
  min-width: 28px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(166, 193, 237, 0.28);
  background: rgba(24, 39, 72, 0.94);
  color: #e8f1ff;
  font-family: "Rajdhani", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(4, 10, 22, 0.35);
}


.chat-jump-latest:hover {
  border-color: rgba(120, 170, 255, 0.42);
  background: rgba(35, 56, 101, 0.96);
}

.chat-jump-latest[hidden] {
  display: none !important;
}


.chat-attachment-preview {
  padding: 0 8px 6px;
  border-top: 1px solid rgba(166, 193, 237, 0.08);
  background: rgba(12, 19, 34, 0.25);
}

.chat-attachment-chip {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(166, 193, 237, 0.16);
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  padding: 4px 6px;
  max-width: 100%;
}

.chat-attachment-icon {
  min-width: 30px;
  height: 22px;
  padding: 0 6px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #eef4ff;
  border: 1px solid rgba(166, 193, 237, 0.16);
  background: rgba(255,255,255,0.03);
}

.chat-attachment-meta {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.chat-attachment-meta strong {
  font-size: 0.72rem;
  color: #eaf2ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-attachment-meta small {
  color: #97afda;
  font-size: 0.62rem;
}

.chat-thread-messages {
  overflow: auto;
  padding: 8px 8px 6px;
  display: grid;
  align-content: start;
  gap: 6px;
  transition: background-color 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
  border: 1px solid transparent;
  border-radius: 10px;
  margin: 6px 6px 0 6px;
  background:
    linear-gradient(180deg, rgba(9, 14, 25, 0.92), rgba(10, 16, 28, 0.92)),
    radial-gradient(120% 90% at 100% 0%, rgba(58, 94, 170, 0.08), transparent 55%);
  box-shadow: inset 0 0 0 1px rgba(166, 193, 237, 0.05);
}

.chat-thread-messages.is-drop-target {
  background:
    linear-gradient(180deg, rgba(62, 110, 214, 0.08), rgba(46, 212, 166, 0.04)),
    rgba(255, 255, 255, 0.01);
  border-color: rgba(120, 170, 255, 0.34);
  box-shadow: inset 0 0 0 1px rgba(120, 170, 255, 0.16);
}

.chat-empty {
  border: 1px dashed rgba(166, 193, 237, 0.16);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  color: #8ea6cf;
  font-size: 0.82rem;
  background: rgba(10, 16, 28, 0.75);
}

.chat-day-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0 2px;
}

.chat-day-divider span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 18px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(166, 193, 237, 0.14);
  background: rgba(255,255,255,0.02);
  color: #9fb7e1;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.chat-msg {
  max-width: min(90%, 480px);
  display: grid;
  gap: 3px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(166, 193, 237, 0.12);
  background: rgba(15, 22, 38, 0.9);
}

.chat-msg.is-mine {
  margin-left: auto;
  border-color: rgba(89, 151, 255, 0.28);
  background: linear-gradient(180deg, rgba(46, 84, 155, 0.6), rgba(25, 46, 84, 0.78));
}

.chat-msg-head {
  display: flex;
  gap: 6px;
  align-items: baseline;
  justify-content: space-between;
}

.chat-msg-head-right {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.chat-msg-author {
  font-weight: 700;
  font-size: 0.72rem;
  color: #dbe8ff;
}

.chat-msg-time {
  font-size: 0.64rem;
  color: #93abd4;
  white-space: nowrap;
}

.chat-msg-read {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 14px;
  font-size: 0.62rem;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.04em;
  user-select: none;
}

.chat-msg-read-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 14px;
  padding: 0 4px;
  border-radius: 999px;
  font-size: 0.54rem;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  user-select: none;
}

.chat-msg-read-label.is-sent {
  color: rgba(224, 236, 255, 0.88);
  background: rgba(166, 193, 237, 0.16);
}

.chat-msg-read-label.is-read {
  color: #dff1ff;
  background: rgba(122, 178, 255, 0.34);
}

.chat-msg-read.is-sent {
  color: rgba(207, 224, 255, 0.58);
}

.chat-msg-read.is-read {
  color: #7ab2ff;
}

.chat-msg-action {
  border: 1px solid rgba(166, 193, 237, 0.14);
  background: rgba(255,255,255,0.03);
  color: #cfe0ff;
  height: 20px;
  min-width: 20px;
  padding: 0 5px;
  border-radius: 6px;
  font: inherit;
  line-height: 1;
  font-size: 0.62rem;
  cursor: pointer;
}

.chat-msg-action:hover {
  border-color: rgba(255, 120, 140, 0.34);
  color: #fff;
  background: rgba(255, 94, 116, 0.14);
}

.chat-msg-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.25;
  color: #eef4ff;
  font-size: 0.76rem;
}

.chat-attachment-msg {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  border: 1px solid rgba(166, 193, 237, 0.15);
  border-radius: 9px;
  background: rgba(255,255,255,0.02);
  padding: 5px 6px;
  color: inherit;
  text-decoration: none;
}

.chat-attachment-msg:hover {
  border-color: rgba(120, 170, 255, 0.3);
}

.chat-attachment-msg.is-image {
  display: grid;
  gap: 4px;
  max-width: min(260px, 100%);
}

.chat-attachment-msg.is-image img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid rgba(166, 193, 237, 0.12);
  background: rgba(255,255,255,0.02);
}

.chat-attachment-msg.is-image span {
  font-size: 0.64rem;
  color: #b1c7ee;
  line-height: 1.2;
  word-break: break-word;
}

.chat-send-form {
  border-top: 1px solid rgba(166, 193, 237, 0.1);
  padding: 7px 6px 6px;
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  background: rgba(10, 16, 28, 0.88);
  margin: 0 6px 6px;
  border-radius: 10px;
  position: relative;
}

.chat-send-form textarea {
  resize: none;
  min-height: 36px;
  max-height: 84px;
  border-radius: 10px;
  border: 1px solid rgba(166, 193, 237, 0.18);
  background: rgba(13, 20, 34, 0.95);
  color: #eaf2ff;
  padding: 6px 8px;
  font: inherit;
}

.chat-send-form textarea:focus {
  outline: none;
  border-color: rgba(120, 170, 255, 0.36);
  box-shadow: 0 0 0 3px rgba(120, 170, 255, 0.12);
}

.chat-send-form .btn {
  align-self: end;
  min-height: 36px;
}

.chat-emoji-wrap {
  position: relative;
  align-self: end;
}

.chat-emoji-wrap .btn {
  min-width: 36px;
  padding-inline: 8px;
}

.chat-emoji-wrap .btn.is-active {
  border-color: rgba(120, 170, 255, 0.36);
  box-shadow: 0 0 0 3px rgba(120, 170, 255, 0.12);
}

.chat-emoji-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: min(320px, calc(100vw - 40px));
  max-height: 260px;
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid rgba(166, 193, 237, 0.18);
  border-radius: 12px;
  background: rgba(16, 25, 44, 0.98);
  box-shadow: 0 16px 36px rgba(4, 8, 16, 0.42);
  overflow: hidden;
  z-index: 6;
}

.chat-emoji-panel[hidden] {
  display: none !important;
}

.chat-emoji-panel-head {
  padding: 8px;
  border-bottom: 1px solid rgba(166, 193, 237, 0.1);
  background: rgba(255,255,255,0.02);
}

.chat-emoji-panel-head .search {
  width: 100%;
  min-width: 0;
  height: 30px;
  font-size: 0.78rem;
  padding: 6px 9px;
}

.chat-emoji-list {
  overflow: auto;
  padding: 8px;
  display: grid;
  gap: 6px;
  align-content: start;
  scrollbar-width: thin;
}

.chat-emoji-item {
  width: 100%;
  border: 1px solid rgba(166, 193, 237, 0.12);
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  color: inherit;
  text-align: left;
  padding: 6px 8px;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: center;
  cursor: pointer;
}

.chat-emoji-item:hover {
  border-color: rgba(120, 170, 255, 0.3);
  background: rgba(90, 132, 224, 0.08);
}

.chat-emoji-char {
  font-size: 1.05rem;
  line-height: 1;
  text-align: center;
}

.chat-emoji-name {
  font-size: 0.72rem;
  color: #bfd3f3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-upload-progress {
  margin-top: 6px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  color: #9fb7e1;
  font-size: 0.65rem;
}

.chat-upload-progress-bar {
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(79, 140, 255, 0.9), rgba(46, 212, 166, 0.95));
  box-shadow: 0 0 0 1px rgba(120, 170, 255, 0.14) inset;
}

.chat-upload-progress::before {
  content: "";
  grid-column: 1 / 2;
  grid-row: 1 / 2;
  height: 7px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  box-shadow: inset 0 0 0 1px rgba(166, 193, 237, 0.1);
}

.chat-upload-progress .chat-upload-progress-bar {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
}

.chat-upload-progress span {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  min-width: 38px;
  text-align: right;
  font-weight: 700;
}


