/* Chat widget styles */
:root {
   --chat-bg: #0f0f0f;
   --chat-panel: #111418;
   --chat-border: rgba(255, 255, 255, 0.14);
   --chat-accent: #11abb0;
   --chat-accent-strong: #0d8a8f;
   --chat-text: #f2f2f2;
   --chat-muted: #a8a8a8;
   --chat-glow: rgba(17, 171, 176, 0.35);
}

.chat-widget {
   position: fixed;
   right: 24px;
   bottom: 24px;
   z-index: 9999;
   font-family: 'opensans-regular', sans-serif;
}

.chat-dim {
   position: fixed;
   inset: 0;
   background: rgba(0, 0, 0, 0.35);
   opacity: 0;
   pointer-events: none;
   transition: opacity 0.3s ease;
   z-index: 1;
}

.chat-hint,
.chat-toggle,
.chat-panel {
   position: relative;
   z-index: 2;
}

.chat-hint {
   position: absolute;
   right: calc(100% + 12px);
   bottom: 4px;
   width: 240px;
   height: 150px;
   color: var(--chat-text);
   opacity: 0;
   transform: translateX(10px) translateY(6px) scale(0.98);
   pointer-events: none;
   transition: opacity 0.3s ease, transform 0.3s ease;
}

.chat-hint-text {
   position: absolute;
   right: calc(100% - 125px);
   top: 0;
   left: auto;
   bottom: auto;
   font-family: 'opensans-bold', sans-serif;
   font-size: 16px;
   letter-spacing: 0;
   text-transform: none;
   text-shadow: 0 3px 10px rgba(0, 0, 0, 0.55);
   text-align: right;
   white-space: nowrap;
}

.chat-hint-arrow {
   position: absolute;
   right: 0;
   bottom: 56px;
   width: 125px;
   height: 2px;
   background: var(--chat-text);
   transform-origin: right center;
   transform: rotate(18deg);
}

.chat-widget.show-hint .chat-hint {
   opacity: 1;
   transform: translateX(0) translateY(0) scale(1);
}

.chat-widget.show-hint .chat-dim {
   opacity: 1;
}

.chat-widget.show-hint .chat-hint-arrow {
   animation: hintArrow 1.6s ease-in-out infinite;
}

.chat-hint-arrow::after {
   content: '';
   position: absolute;
   right: -2px;
   top: 50%;
   width: 10px;
   height: 10px;
   border-top: 2px solid var(--chat-text);
   border-right: 2px solid var(--chat-text);
   transform: translateY(-50%) rotate(45deg);
}

.chat-toggle {
   display: inline-flex;
   align-items: center;
   gap: 12px;
   border: 1px solid rgba(255, 255, 255, 0.08);
   background: linear-gradient(135deg, rgba(17, 171, 176, 0.2) 0%, rgba(17, 171, 176, 0.05) 100%);
   color: #fff;
   padding: 10px 16px;
   border-radius: 999px;
   font-size: 14px;
   letter-spacing: 0.3px;
   cursor: pointer;
   box-shadow: 0 14px 30px rgba(0, 0, 0, 0.4);
   backdrop-filter: blur(12px);
   transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.chat-toggle:hover {
   transform: translateY(-2px);
   box-shadow: 0 18px 34px rgba(17, 171, 176, 0.3);
   border-color: rgba(17, 171, 176, 0.6);
}

.chat-toggle-avatar {
   display: inline-flex;
   align-items: center;
   justify-content: center;
   width: 36px;
   height: 36px;
   border-radius: 50%;
   overflow: hidden;
   border: 2px solid rgba(255, 255, 255, 0.2);
   box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.chat-toggle-avatar img {
   width: 100%;
   height: 100%;
   object-fit: cover;
}

.chat-toggle-text {
   display: flex;
   flex-direction: column;
   align-items: flex-start;
}

.chat-toggle-label {
   font-family: 'opensans-bold', sans-serif;
   font-size: 14px;
}

.chat-toggle-subtitle {
   font-size: 11px;
   color: rgba(255, 255, 255, 0.7);
}

.chat-toggle-indicator {
   width: 10px;
   height: 10px;
   border-radius: 50%;
   background: #7fffd6;
   box-shadow: 0 0 0 0 rgba(127, 255, 214, 0.6);
   animation: pulseDot 1.8s infinite;
}

@keyframes pulseDot {
   0% {
      box-shadow: 0 0 0 0 rgba(127, 255, 214, 0.6);
   }
   70% {
      box-shadow: 0 0 0 8px rgba(127, 255, 214, 0);
   }
   100% {
      box-shadow: 0 0 0 0 rgba(127, 255, 214, 0);
   }
}

.chat-panel {
   position: absolute;
   right: 0;
   bottom: 64px;
   width: 420px;
   max-width: calc(100vw - 48px);
   background: radial-gradient(circle at top, rgba(17, 171, 176, 0.12), transparent 45%),
      var(--chat-panel);
   border: 1px solid var(--chat-border);
   border-radius: 18px;
   box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55);
   overflow: hidden;
   opacity: 0;
   transform: translateY(16px) scale(0.98);
   pointer-events: none;
   transition: opacity 0.25s ease, transform 0.25s ease;
}

.chat-panel::before {
   content: '';
   position: absolute;
   inset: 0;
   border-radius: 18px;
   padding: 1px;
   background: linear-gradient(135deg, rgba(17, 171, 176, 0.6), rgba(255, 255, 255, 0));
   -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
   -webkit-mask-composite: xor;
   mask-composite: exclude;
   pointer-events: none;
}

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

.chat-header {
   display: flex;
   justify-content: space-between;
   align-items: center;
   padding: 16px 18px;
   border-bottom: 1px solid var(--chat-border);
   background: rgba(15, 15, 15, 0.6);
   backdrop-filter: blur(10px);
}

.chat-identity {
   display: flex;
   align-items: center;
   gap: 12px;
}

.chat-avatar {
   width: 42px;
   height: 42px;
   border-radius: 50%;
   object-fit: cover;
   border: 2px solid rgba(17, 171, 176, 0.5);
   box-shadow: 0 8px 18px rgba(17, 171, 176, 0.25);
}

.chat-title {
   font: 16px/1.2 'opensans-bold', sans-serif;
   color: var(--chat-text);
   margin: 0;
}

.chat-subtitle {
   margin: 4px 0 0;
   color: var(--chat-muted);
   font-size: 12px;
}

.chat-close {
   background: transparent;
   border: none;
   color: var(--chat-text);
   font-size: 20px;
   cursor: pointer;
   line-height: 1;
   padding: 4px 8px;
}

.chat-messages {
   padding: 18px;
   height: 320px;
   overflow-y: auto;
   display: flex;
   flex-direction: column;
   gap: 12px;
}

.chat-message {
   display: flex;
   animation: messageIn 0.25s ease both;
}

.chat-message.from-user {
   justify-content: flex-end;
}

.chat-bubble {
   max-width: 78%;
   padding: 12px 14px;
   border-radius: 14px;
   font-size: 13px;
   line-height: 1.5;
   color: var(--chat-text);
   background: rgba(22, 22, 22, 0.9);
   border: 1px solid rgba(255, 255, 255, 0.08);
   box-shadow: 0 10px 22px rgba(0, 0, 0, 0.25);
}

.chat-message.from-user .chat-bubble {
   background: linear-gradient(135deg, rgba(17, 171, 176, 0.3), rgba(17, 171, 176, 0.15));
   border-color: rgba(17, 171, 176, 0.5);
   box-shadow: 0 12px 24px rgba(17, 171, 176, 0.2);
}

.chat-message.is-typing .chat-bubble {
   color: var(--chat-muted);
   font-style: italic;
}

.chat-form {
   display: flex;
   gap: 8px;
   padding: 12px 18px 6px;
}

.chat-input {
   flex: 1;
   background: rgba(10, 10, 10, 0.8);
   border: 1px solid var(--chat-border);
   border-radius: 12px;
   color: var(--chat-text);
   padding: 10px 12px;
   font-size: 13px;
   outline: none;
}

.chat-input::placeholder {
   color: #ffffff;
}

.chat-input:focus {
   border-color: rgba(17, 171, 176, 0.6);
   box-shadow: 0 0 0 2px rgba(17, 171, 176, 0.15);
}

.chat-send {
   border: none;
   background: linear-gradient(135deg, var(--chat-accent), var(--chat-accent-strong));
   color: #fff;
   border-radius: 12px;
   padding: 0 14px;
   font-size: 13px;
   cursor: pointer;
   transition: background 0.2s ease;
}

.chat-send:hover {
   background: var(--chat-accent-strong);
}

.chat-send:disabled,
.chat-input:disabled {
   opacity: 0.6;
   cursor: not-allowed;
}

.chat-status {
   margin: 0;
   padding: 0 18px 14px;
   font-size: 12px;
   color: var(--chat-muted);
   min-height: 16px;
}

@keyframes messageIn {
   from {
      opacity: 0;
      transform: translateY(6px);
   }
   to {
      opacity: 1;
      transform: translateY(0);
   }
}

@keyframes hintArrow {
   0% {
      transform: rotate(30deg) translateX(0);
   }
   50% {
      transform: rotate(30deg) translateX(6px);
   }
   100% {
      transform: rotate(30deg) translateX(0);
   }
}

@media (max-width: 700px) {
   .chat-widget {
      right: 16px;
      left: 16px;
   }

   .chat-hint {
      right: calc(100% + 8px);
      bottom: 2px;
      width: 300px;
      height: 120px;
   }

   .chat-hint-text {
      font-size: 13px;
      top: 0;
      bottom: auto;
   }

   .chat-hint-arrow {
      width: 105px;
      bottom: 44px;
   }

   .chat-panel {
      width: calc(100vw - 32px);
      bottom: 62px;
   }
}

@media (prefers-reduced-motion: reduce) {
   .chat-toggle,
   .chat-panel,
   .chat-message,
   .chat-hint,
   .chat-hint-arrow,
   .chat-dim {
      transition: none;
      animation: none;
   }
}
