/* Tektra AI Assistant */
.assistant-widget { position: fixed; right: 7px; bottom: 65px; z-index: 9990; font-family: var(--default-font, "Roboto", sans-serif); }

.assistant-launcher {
  position: relative; width: 56px; height: 56px; border: 0; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-color), color-mix(in srgb, var(--accent-color), #7a3cff 45%));
  color: #fff; font-size: 24px; cursor: pointer;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent-color), transparent 55%);
  transition: transform .2s ease, box-shadow .2s ease;
}
.assistant-launcher:hover { transform: translateY(-2px) scale(1.05); }
.assistant-launcher:focus-visible, .assistant-panel button:focus-visible, .assistant-form textarea:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.assistant-launcher::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--accent-color); opacity: 0; animation: assistant-pulse 2.6s ease-out 3;
}
@keyframes assistant-pulse { 0% { transform: scale(1); opacity: .6; } 100% { transform: scale(1.6); opacity: 0; } }

.assistant-panel {
  position: absolute; right: 0; bottom: 70px; width: 390px; max-width: calc(100vw - 24px);
  height: min(580px, max(0px, calc(100vh - 160px)));
  height: min(580px, max(0px, calc(100dvh - 160px)));
  max-height: max(0px, calc(100vh - 160px));
  max-height: max(0px, calc(100dvh - 160px));
  display: flex; flex-direction: column;
  background: var(--surface-color); color: var(--default-color); border-radius: 18px; overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--default-color), transparent 88%);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .3); transform-origin: bottom right;
  animation: assistant-open .22s ease-out;
}
.assistant-panel[hidden] { display: none; }
@keyframes assistant-open { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }

.assistant-header {
  display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; color: #fff;
  background: linear-gradient(135deg, var(--accent-color), color-mix(in srgb, var(--accent-color), #7a3cff 45%));
}
.assistant-identity { display: flex; align-items: center; gap: 12px; }
.assistant-identity strong { display: block; font-size: 15px; font-weight: 600; }
.assistant-identity small { display: flex; align-items: center; gap: 6px; opacity: .9; font-size: 12px; }
.assistant-identity small::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #4ade80; }
.assistant-avatar { width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.2); display: grid; place-items: center; font-size: 18px; flex-shrink: 0; }
.assistant-actions { display: flex; gap: 4px; }
.assistant-actions button { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: #fff; font-size: 15px; cursor: pointer; transition: background .15s; }
.assistant-actions button:hover { background: rgba(255,255,255,.2); }

.assistant-conversation { flex: 1; overflow-y: auto; padding: 16px; scroll-behavior: smooth; background: color-mix(in srgb, var(--default-color), transparent 97%); }
.assistant-messages { display: flex; flex-direction: column; gap: 14px; }

.assistant-message { display: flex; gap: 8px; max-width: 92%; animation: assistant-in .2s ease-out; }
@keyframes assistant-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.assistant-message-user { align-self: flex-end; flex-direction: row-reverse; }
.assistant-message-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-color); color: #fff; display: grid; place-items: center; font-size: 13px; flex-shrink: 0; }
.assistant-message-body { min-width: 0; }
.assistant-bubble {
  padding: 10px 13px; border-radius: 14px 14px 14px 4px; font-size: 14px; line-height: 1.5;
  background: var(--surface-color); border: 1px solid color-mix(in srgb, var(--default-color), transparent 88%);
  overflow-wrap: anywhere;
}
.assistant-message-user .assistant-bubble { border-radius: 14px 14px 4px 14px; background: var(--accent-color); border-color: transparent; color: #fff; }
.assistant-bubble p { margin: 0 0 8px; }
.assistant-bubble p:last-child, .assistant-bubble ul:last-child { margin-bottom: 0; }
.assistant-bubble ul { margin: 0 0 8px; padding-left: 18px; }
.assistant-bubble a { color: var(--accent-color); text-decoration: underline; }
.assistant-message-user .assistant-bubble a { color: #fff; }
.assistant-time { display: block; margin-top: 3px; font-size: 11px; opacity: .55; }
.assistant-message-user .assistant-time { text-align: right; }

.assistant-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.assistant-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--default-color); opacity: .4; animation: assistant-bounce 1.2s infinite; }
.assistant-typing span:nth-child(2) { animation-delay: .15s; }
.assistant-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes assistant-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }

.assistant-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.assistant-suggestions[hidden] { display: none; }
.assistant-suggestions span { width: 100%; font-size: 12px; opacity: .65; }
.assistant-suggestions button {
  display: inline-flex; align-items: center; gap: 6px; text-align: left; padding: 7px 12px; font-size: 13px; cursor: pointer;
  color: var(--accent-color); background: var(--surface-color); border: 1px solid color-mix(in srgb, var(--accent-color), transparent 55%);
  border-radius: 999px; transition: background .15s, color .15s;
}
.assistant-suggestions button:hover { background: var(--accent-color); color: #fff; }

.assistant-status { min-height: 0; margin-top: 8px; font-size: 12px; color: #d93025; }
.assistant-status:empty { display: none; }

.assistant-composer { padding: 12px 14px 10px; background: var(--surface-color); border-top: 1px solid color-mix(in srgb, var(--default-color), transparent 88%); }
.assistant-form { display: flex; gap: 8px; align-items: flex-end; }
.assistant-form textarea {
  flex: 1; resize: none; max-height: 100px; padding: 9px 12px; font: inherit; font-size: 14px; line-height: 1.4;
  color: var(--default-color); background: var(--background-color);
  border: 1px solid color-mix(in srgb, var(--default-color), transparent 80%); border-radius: 12px;
}
.assistant-form textarea:disabled { opacity: .7; }
.assistant-form button { width: 38px; height: 38px; flex-shrink: 0; border: 0; border-radius: 50%; background: var(--accent-color); color: #fff; cursor: pointer; transition: opacity .15s, transform .15s; }
.assistant-form button:hover:not(:disabled) { transform: scale(1.06); }
.assistant-form button:disabled { opacity: .4; cursor: not-allowed; }
.assistant-disclaimer { margin: 8px 0 0; font-size: 11px; text-align: center; opacity: .6; }

@media (max-width: 480px) {
  .assistant-panel {
    width: min(390px, calc(100vw - 24px));
  }
}
@media (max-height: 520px) {
  .assistant-panel {
    height: calc(100vh - 140px);
    height: calc(100dvh - 140px);
    max-height: none;
    bottom: 60px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .assistant-widget * { animation: none !important; transition: none !important; }
}
