/* Chatbot Stylesheet
   EW Sirnach AG, Ueli Kienholz, 21.6.2025, 12:06
*/

:root {
  /* Farbsystem */
  --primary-color: #491c4d;
  --header-bg: #f0f0f0;
  --chat-gradient: linear-gradient(45deg,
    #000000 0%, #6c1874 20%, #9A474D 40%,
    #C97727 60%, #f7a600 80%, #ffffff 100%
  );
}

/* ===== Chat-Button (eingeklappt) ===== */
.chat-button {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--chat-gradient);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  z-index: 1000;
}

.chat-button::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  height: 80%;
  background: white;
  border-radius: 50%;
  z-index: 1;
}

.chat-button::after {
  content: "";
  position: absolute;
  top: calc(60% - 3px);
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50%;
  height: 50%;
  background: var(--chat-gradient);
  -webkit-mask: url('data:image/svg+xml;utf8,\
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">\
<path d="M20 2H4C2.897 2 2 2.897 2 4v16l4-4h14\
c1.103 0 2-0.897 2-2V4C22 2.897 21.103 2 20 2z"/>\
</svg>') no-repeat center/contain;
  mask: url('data:image/svg+xml;utf8,\
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">\
<path d="M20 2H4C2.897 2 2 2.897 2 4v16l4-4h14\
c1.103 0 2-0.897 2-2V4C22 2.897 21.103 2 20 2z"/>\
</svg>') no-repeat center/contain;
  z-index: 2;
}

.chat-icon-text {
  position: absolute;
  top: calc(60% - 7px);
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  font-size: 16px;
  font-weight: bold;
  line-height: 1;
  text-align: center;
  color: white;
}

/* ===== Chat-Container ===== */
.chat-container {
  position: fixed;
  top: 15vh;
  bottom: 30px;
  right: 30px;
  width: 360px;
  max-width: 90vw;
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  border: 1px solid #d0d0d0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 1000;
}

.chat-container.active {
  opacity: 1;
  visibility: visible;
  bottom: 100px; /* Fenster 100 px über dem unteren Viewport-Rand platzieren */
}

/* Header */
.chat-header {
  background-color: var(--header-bg);
  color: var(--primary-color);
  padding: 10px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
}

.header-text {
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: bold;
}

.header-subtitle {
  font-size: 12px;
  border: 1px solid var(--primary-color);
  border-radius: 15px;
  padding: 2px 8px;
}

.legal-link {
  font-size: 10px;
}

.legal-link a {
  color: var(--primary-color) !important;
  text-decoration: underline !important;
}

.collapse-chat {
  background: transparent;
  border: none;
  color: var(--primary-color);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.collapse-chat svg {
  width: 20px;
  height: 20px;
}

.collapse-chat svg path {
  fill: var(--primary-color);
}

/* Messages */
.chat-messages {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  background: white;
  display: flex;
  flex-direction: column;
  position: relative;
}

.message {
  margin-bottom: 15px;
  max-width: 80%;
  padding: 10px 15px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-line;
}

.bot-message {
  background: var(--header-bg);
  color: #333;
  text-align: left;
  align-self: flex-start;
  border-radius: 10px 10px 10px 0;
  position: relative;
  margin-left: 32px; /* Platz für das Icon */
  padding-left: 12px;
}

.bot-message::before {
  content: "";
  position: absolute;
  top: 8px;
  left: -32px;
  width: 24px;
  height: 24px;
  background-color: var(--primary-color);

  /* WebKit-Mask mit Zeilenfortsetzung */
  -webkit-mask: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'>\
<path d='M161.473,196.324a43.044,43.044,0,1,0,43.044,43.044A\
43.092,43.092,0,0,0,161.473,196.324Zm0,70.088a27.044,27.044,0,1,1,\
27.044-27.044A27.075,27.075,0,0,1,161.473,266.412Zm189.054-70.088\
a43.044,43.044,0,1,0,43.044,43.044A43.093,43.093,0,0,0,350.527,196.324\
Zm0,70.088a27.044,27.044,0,1,1,27.044-27.044A27.075,27.075,0,0,1,\
350.527,266.412Zm-33.715,67.663A8,8,0,0,1,314.1,345.06a112.042,112.042,\
0,0,1-116.206,0,8,8,0,0,1,8.276-13.694,96.085,96.085,0,0,0,99.654,0\
A8,8,0,0,1,316.812,334.075ZM485.364,160.3H470.949V146.431A35.589,35.589,\
0,0,0,435.4,110.882H264c0-.016,0-.03,0-.046V75.342a35.879,35.879,0,1,0-16,0\
v35.494c0,.016,0,.03,0,.046H76.6a35.589,35.589,0,0,0-35.549,35.549V160.3H26.636\
A26.666,26.666,0,0,0,0,186.933V356.3a26.667,26.667,0,0,0,26.636,26.636H41.051\
V396.8A35.59,35.59,0,0,0,76.6,432.348h42.433v67.158a8,8,0,0,0,12,6.928l128.323,\
-74.086H435.4A35.59,35.59,0,0,0,470.949,396.8V382.933h14.415A26.667,26.667,\
0,0,0,512,356.3V186.933A26.666,26.666,0,0,0,485.364,160.3ZM236.121,40.372A19.879,\
19.879,0,1,1,256,60.252,19.9,19.9,0,0,1,236.121,40.372ZM26.636,366.933A10.648,\
10.648,0,0,1,16,356.3V186.933A10.648,10.648,0,0,1,26.636,176.3H41.051V366.933\
ZM454.949,396.8A19.571,19.571,0,0,1,435.4,416.348H257.213a8,8,0,0,0-4,1.072l\
-118.18,68.229v-61.3a8,8,0,0,0-8-8H76.6A19.571,19.571,0,0,1,57.051,396.8V146.431\
A19.57,19.57,0,0,1,76.6,126.882H435.4a19.57,19.57,0,0,1,19.549,19.549ZM496,356.3\
a10.648,10.648,0,0,1-10.636,10.636H470.949V176.3h14.415A10.648,10.648,0,0,1,496,\
186.933Z'/>\
</svg>") no-repeat center/contain;

  /* dasselbe für die Mask-Eigenschaft */
  mask: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'>\
<path d='M161.473,196.324a43.044,43.044,0,1,0,43.044,43.044A\
43.092,43.092,0,0,0,161.473,196.324Zm0,70.088a27.044,27.044,0,1,1,\
27.044-27.044A27.075,27.075,0,0,1,161.473,266.412Zm189.054-70.088\
a43.044,43.044,0,1,0,43.044,43.044A43.093,43.093,0,0,0,350.527,196.324\
Zm0,70.088a27.044,27.044,0,1,1,27.044-27.044A27.075,27.075,0,0,1,\
350.527,266.412Zm-33.715,67.663A8,8,0,0,1,314.1,345.06a112.042,112.042,\
0,0,1-116.206,0,8,8,0,0,1,8.276-13.694,96.085,96.085,0,0,0,99.654,0\
A8,8,0,0,1,316.812,334.075ZM485.364,160.3H470.949V146.431A35.589,35.589,\
0,0,0,435.4,110.882H264c0-.016,0-.03,0-.046V75.342a35.879,35.879,0,1,0-16,0\
v35.494c0,.016,0,.03,0,.046H76.6a35.589,35.589,0,0,0-35.549,35.549V160.3H26.636\
A26.666,26.666,0,0,0,0,186.933V356.3a26.667,26.667,0,0,0,26.636,26.636H41.051\
V396.8A35.59,35.59,0,0,0,76.6,432.348h42.433v67.158a8,8,0,0,0,12,6.928l128.323,\
-74.086H435.4A35.59,35.59,0,0,0,470.949,396.8V382.933h14.415A26.667,26.667,\
0,0,0,512,356.3V186.933A26.666,26.666,0,0,0,485.364,160.3ZM236.121,40.372A19.879,\
19.879,0,1,1,256,60.252,19.9,19.9,0,0,1,236.121,40.372ZM26.636,366.933A10.648,\
10.648,0,0,1,16,356.3V186.933A10.648,10.648,0,0,1,26.636,176.3H41.051V366.933\
ZM454.949,396.8A19.571,19.571,0,0,1,435.4,416.348H257.213a8,8,0,0,0-4,1.072l\
-118.18,68.229v-61.3a8,8,0,0,0-8-8H76.6A19.571,19.571,0,0,1,57.051,396.8V146.431\
A19.57,19.57,0,0,1,76.6,126.882H435.4a19.57,19.57,0,0,1,19.549,19.549ZM496,356.3\
a10.648,10.648,0,0,1-10.636,10.636H470.949V176.3h14.415A10.648,10.648,0,0,1,496,\
186.933Z'/>\
</svg>") no-repeat center/contain;
}

.user-message {
  background: var(--primary-color);
  color: white;
  text-align: right;
  align-self: flex-end;
  border-radius: 10px 10px 0 10px;
}

/* Input */
.chat-input {
  background: var(--header-bg);
  padding: 10px;
  display: flex;
  gap: 6px; /* weniger Abstand, damit nichts übersteht */
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.chat-input input {
  flex: 1;
  min-width: 0; /* verhindert Überlauf bei vielen Buttons */
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  background: white;
}

.chat-input button {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 16px;
}

.mic-button.recording {
  background: red;
}

#endBtn {
  background: var(--primary-color); /* gleiches Farbschema wie andere Buttons */
}

#endBtn:active {
  background: red;
}

.transcript-select {
  background: var(--header-bg);
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 0 0 10px 10px;
  font-size: 14px;
}

.transcript-select select {
  flex: 1;
  padding: 6px 10px;
  border-radius: 20px;
  border: 1px solid #ccc;
  background: white;
}

/* Loading Animation */
.loading {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 5px 0;
}

.loading-bar {
  width: 6px;
  height: 10px;
  background-color: var(--primary-color);
  border-radius: 3px;
  animation: jump 1s infinite;
}

.loading-bar:nth-child(1) {
  animation-delay: 0s;
}

.loading-bar:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-bar:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes jump {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Chat-Button offen */
.chat-button.open::after {
  display: none;
}

.chat-button.open .chat-icon-text {
  font-size: 32px;
  font-weight: bold;
  background: var(--chat-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  transition: transform 0.2s ease-in-out;
}

.chat-button:hover {
  transform: scale(1.06);
}
