:root {
  --euryka-primary: #6366f1;
  --euryka-primary-dark: #4f46e5;
  --euryka-text: #1e293b;
  --euryka-text-light: #64748b;
  --euryka-bg: #ffffff;
  --euryka-bg-alt: #f1f5f9;
  --euryka-border: #e2e8f0;
  --euryka-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  --euryka-radius: 16px;
}

/* Isolate widget from site styles */
.euryka-panel {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif !important;
  font-size: 14px !important;
  line-height: 1.5 !important;
  color: var(--euryka-text) !important;
  letter-spacing: normal !important;
  text-transform: none !important;
  -webkit-font-smoothing: antialiased !important;
  -moz-osx-font-smoothing: grayscale !important;
}

.euryka-panel *,
.euryka-panel *::before,
.euryka-panel *::after {
  box-sizing: border-box !important;
  letter-spacing: normal !important;
  text-transform: none !important;
  text-decoration: none;
}

.euryka-panel h1,
.euryka-panel h2,
.euryka-panel h3,
.euryka-panel h4,
.euryka-panel h5,
.euryka-panel h6 {
  font-size: inherit !important;
  font-weight: inherit !important;
  line-height: inherit !important;
  color: inherit !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: none !important;
  text-shadow: none !important;
}

.euryka-panel p {
  margin: 0 !important;
  padding: 0 !important;
  font-size: inherit !important;
  line-height: inherit !important;
}

.euryka-panel a {
  color: inherit;
}

.euryka-panel button,
.euryka-panel textarea,
.euryka-panel input {
  font-family: inherit !important;
}

/* Trigger button */
.euryka-trigger {
  position: fixed;
  z-index: 999998;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--euryka-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.euryka-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.5);
}

.euryka-trigger:focus-visible {
  outline: 3px solid var(--euryka-primary);
  outline-offset: 3px;
}

.euryka-trigger svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Position */
.euryka-trigger--bottom-right { bottom: 24px; right: 24px; }
.euryka-trigger--bottom-left  { bottom: 24px; left: 24px; }

/* Chat panel */
.euryka-panel {
  position: fixed;
  z-index: 999999;
  width: var(--euryka-panel-width, 380px);
  height: var(--euryka-panel-height, 520px);
  min-width: 300px;
  min-height: 360px;
  max-width: calc(100vw - 32px);
  max-height: 80vh;
  background: var(--euryka-bg);
  border-radius: var(--euryka-radius);
  box-shadow: var(--euryka-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.euryka-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

.euryka-panel--bottom-right { bottom: 92px; right: 24px; }
.euryka-panel--bottom-left  { bottom: 92px; left: 24px; }

/* Header */
.euryka-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--euryka-primary);
  color: #fff;
  flex-shrink: 0;
}

.euryka-header__left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.euryka-header__icon {
  width: 28px !important;
  height: 28px !important;
  border-radius: 6px !important;
  object-fit: cover !important;
  flex-shrink: 0;
}

.euryka-header__title {
  font-size: 15px !important;
  font-weight: 600 !important;
  margin: 0 !important;
  line-height: 1.4 !important;
  color: #fff !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.euryka-header__actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.euryka-header__btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.euryka-header__btn:hover { background: rgba(255,255,255,0.2); }

.euryka-header__btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Messages area */
.euryka-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Bubble */
.euryka-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.euryka-bubble--bot {
  align-self: flex-start;
  background: var(--euryka-bg-alt);
  color: var(--euryka-text);
  border-bottom-left-radius: 4px;
}

.euryka-bubble--user {
  align-self: flex-end;
  background: var(--euryka-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.euryka-bubble--bot ol,
.euryka-bubble--bot ul {
  margin: 6px 0 !important;
  padding-left: 20px !important;
  list-style-position: outside !important;
}

.euryka-bubble--bot ol { list-style-type: decimal !important; }
.euryka-bubble--bot ul { list-style-type: disc !important; }

.euryka-bubble--bot li {
  margin-bottom: 4px !important;
}

.euryka-bubble--bot .euryka-md-h {
  font-weight: 700 !important;
  line-height: 1.3 !important;
  margin: 10px 0 4px !important;
}
.euryka-bubble--bot .euryka-md-h:first-child {
  margin-top: 0 !important;
}
.euryka-bubble--bot .euryka-md-h1 { font-size: 1.15em !important; }
.euryka-bubble--bot .euryka-md-h2 { font-size: 1.08em !important; }
.euryka-bubble--bot .euryka-md-h3,
.euryka-bubble--bot .euryka-md-h4,
.euryka-bubble--bot .euryka-md-h5,
.euryka-bubble--bot .euryka-md-h6 { font-size: 1em !important; }

.euryka-bubble--bot .euryka-md-hr {
  border: 0 !important;
  border-top: 1px solid rgba(0, 0, 0, 0.12) !important;
  margin: 10px 0 !important;
}

.euryka-bubble--bot strong {
  font-weight: 600 !important;
}

.euryka-bubble--bot em {
  font-style: italic !important;
}

.euryka-bubble--bot a {
  color: var(--euryka-primary-dark) !important;
  text-decoration: underline !important;
}

/* Sources */
.euryka-sources {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--euryka-border);
}

.euryka-sources a {
  display: block;
  font-size: 12px;
  color: var(--euryka-primary);
  text-decoration: none;
  margin-bottom: 2px;
}

.euryka-sources a:hover { text-decoration: underline; }

/* Feedback */
.euryka-feedback {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.euryka-feedback__btn {
  background: none;
  border: 1px solid var(--euryka-border);
  border-radius: 6px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: background 0.15s;
}

.euryka-feedback__btn:hover { background: var(--euryka-bg-alt); }
.euryka-feedback__btn--active { border-color: var(--euryka-primary); background: var(--euryka-bg-alt); }

/* Typing indicator */
.euryka-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  align-self: flex-start;
  background: var(--euryka-bg-alt);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.euryka-typing__dot {
  width: 7px;
  height: 7px;
  background: var(--euryka-text-light);
  border-radius: 50%;
  animation: euryka-bounce 1.4s infinite ease-in-out;
}

.euryka-typing__dot:nth-child(1) { animation-delay: 0s; }
.euryka-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.euryka-typing__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes euryka-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input area */
.euryka-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--euryka-border);
  flex-shrink: 0;
}

.euryka-input {
  flex: 1;
  border: 1px solid var(--euryka-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color 0.15s;
}

.euryka-input:focus { border-color: var(--euryka-primary); }

.euryka-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--euryka-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.euryka-send:disabled { opacity: 0.4; cursor: not-allowed; }

.euryka-send svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Powered-by footer */
.euryka-footer {
  text-align: center;
  padding: 6px 16px;
  font-size: 11px;
  color: var(--euryka-text-light);
  flex-shrink: 0;
}

.euryka-footer a {
  color: var(--euryka-primary) !important;
  text-decoration: none !important;
  font-weight: 500;
}

.euryka-footer a:hover {
  text-decoration: underline !important;
}

/* Mobile */
@media (max-width: 480px) {
  .euryka-panel {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    max-height: 100%;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 0;
  }
  .euryka-panel--bottom-right,
  .euryka-panel--bottom-left {
    bottom: 0;
    right: 0;
    left: 0;
  }
}
