.ai-assistant .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ai-assistant {
  position: fixed;
  z-index: 10000;
  right: 24px;
  left: auto;
  bottom: 24px;
  font-family: var(--font-body, 'Noto Kufi Arabic', sans-serif);
  font-size: 16px;
  font-weight: 400;
  color: var(--text-color, #262626);
  direction: rtl;
}

.ai-assistant *:not(.ai-assistant-fab) {
  border-radius: 0 !important;
}

.ai-assistant.is-open {
  top: var(--site-header-height, 72px);
  right: 0;
  bottom: 0;
  left: auto;
  z-index: 10000;
}

.ai-assistant-fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 28px;
  background: #19B36B;
  color: #fff;
  font-family: inherit;
  box-shadow: 0 4px 16px rgba(25, 179, 107, 0.35);
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  transition: width 0.2s ease, padding 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-assistant-fab-label {
  max-width: 0;
  margin: 0;
  opacity: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  transition: max-width 0.2s ease, opacity 0.2s ease, margin 0.2s ease;
}

.ai-assistant-fab:hover,
.ai-assistant-fab:focus {
  width: auto;
  padding: 0 18px 0 10px;
  transform: scale(1.04);
  box-shadow: 0 6px 20px rgba(25, 179, 107, 0.42);
  outline: none;
}

.ai-assistant-fab:hover .ai-assistant-fab-label,
.ai-assistant-fab:focus .ai-assistant-fab-label {
  max-width: 8em;
  margin-inline-start: 8px;
  opacity: 1;
}

.ai-assistant-fab svg {
  display: block;
  flex-shrink: 0;
}

.ai-assistant.is-open .ai-assistant-fab {
  display: none;
}

.ai-assistant-panel {
  display: none;
  flex-direction: column;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: min(560px, 70vh);
  background: #fff;
  border: 1px solid #e6e6e6;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.ai-assistant.is-open .ai-assistant-panel {
  display: flex;
  width: 400px;
  max-width: min(400px, 100vw);
  height: 100%;
  border-top: 0;
  border-bottom: 0;
  border-right: 0;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.05);
}

.ai-assistant-topbar {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 8px 12px 10px;
  background: #f4f5f4;
  border-bottom: 1px solid #e0e0e0;
}

.ai-assistant-topbar-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ai-assistant-brand {
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  color: #14965A;
}

.ai-assistant-topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-assistant-tool {
  padding: 0;
  border: 0;
  background: transparent;
  color: #14965A;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
}

.ai-assistant-tool:hover,
.ai-assistant-tool:focus,
.ai-assistant-history-back:hover,
.ai-assistant-history-back:focus {
  color: #0f7a48;
  text-decoration: underline;
  outline: none;
}

.ai-assistant-tool.is-active {
  color: #0f7a48;
  text-decoration: underline;
}

.ai-assistant-tool:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  text-decoration: none;
}

.ai-assistant-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #111;
  font-family: inherit;
  cursor: pointer;
}

.ai-assistant-close-icon {
  font-size: 22px;
  line-height: 1;
  color: #111;
}

.ai-assistant-close:hover,
.ai-assistant-close:focus {
  background: #e8e8e8;
  outline: none;
}

.ai-assistant-page {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 8px 12px 0;
  background: #fff;
}

.ai-assistant-page-name {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: #e8f6ee;
  color: #0f7a48;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.ai-assistant.history-open .ai-assistant-messages,
.ai-assistant.history-open .ai-assistant-typing,
.ai-assistant.history-open .ai-assistant-chips,
.ai-assistant.history-open .ai-assistant-error,
.ai-assistant.history-open .ai-assistant-page,
.ai-assistant.history-open .ai-assistant-composer {
  display: none !important;
}

.ai-assistant-history {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  background: #f7f8f7;
}

.ai-assistant-history:not([hidden]) {
  display: flex;
}

.ai-assistant-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 16px;
  font-weight: 700;
  color: #111;
}

.ai-assistant-history-back {
  padding: 0;
  border: 0;
  background: transparent;
  color: #14965A;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}

.ai-assistant-history-hint {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.6;
  color: #666;
}

.ai-assistant-history-empty {
  margin: 8px 0 0;
  padding: 14px 12px;
  background: #fff;
  border: 1px solid #ececec;
  color: #555;
}

.ai-assistant-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ai-assistant-history-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  margin-bottom: 8px;
  padding: 4px 4px 4px 8px;
  background: #fff;
  border: 1px solid #ececec;
}

.ai-assistant-history-item:hover,
.ai-assistant-history-item:focus-within {
  border-color: #14965A;
}

.ai-assistant-history-item.is-current {
  border-color: #14965A;
  background: #f3fbf7;
}

.ai-assistant-history-open {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 8px 8px 8px 4px;
  text-align: right;
  cursor: pointer;
  font-family: inherit;
}

.ai-assistant-history-open:focus {
  outline: none;
}

.ai-assistant-history-item-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  color: #262626;
}

.ai-assistant-history-item-meta {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  color: #777;
}

.ai-assistant-history-delete {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: #888;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 0 0;
}

.ai-assistant-history-delete:hover,
.ai-assistant-history-delete:focus {
  color: #b91c1c;
  outline: none;
}

.ai-assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: #f7f8f7;
}

.ai-assistant-welcome,
.ai-assistant-msg {
  margin-bottom: 10px;
}

.ai-assistant-welcome,
.ai-assistant-msg-assistant {
  background: #fff;
  border: 1px solid #ececec;
  padding: 10px 12px;
  font-size: 16px;
  line-height: 1.7;
  color: #262626;
  overflow-wrap: anywhere;
}

.ai-assistant-msg-user {
  background: #eef2f0;
  color: #262626;
  border: 1px solid #e2e6e4;
  padding: 10px 12px;
  font-size: 16px;
  line-height: 1.7;
  margin-right: 28px;
}

.ai-assistant-apply {
  margin-top: 8px;
  padding: 8px;
  border: 1px dashed #b7e0cb;
  background: #f3fbf7;
}

.ai-assistant-apply-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f7a48;
  margin-bottom: 6px;
}

.ai-assistant-apply-list {
  margin: 0 0 8px 0;
  padding: 0 18px 0 0;
  font-size: 16px;
}

.ai-assistant-apply-list li {
  margin-bottom: 4px;
}

.ai-assistant-apply-desc {
  list-style: none;
  margin-right: -18px;
}

.ai-assistant-apply-description {
  margin-top: 6px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #d9e8df;
  font-weight: 400;
  line-height: 1.7;
  white-space: normal;
}

.ai-assistant-apply-btn,
.ai-assistant-apply-done {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: 0;
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  font-weight: 600;
}

.ai-assistant-apply-btn {
  background: #14965A;
  color: #fff;
  cursor: pointer;
}

.ai-assistant-apply-btn:hover,
.ai-assistant-apply-btn:focus {
  background: #0f7a48;
  outline: none;
}

.ai-assistant-apply-done {
  background: #e8f6ee;
  color: #0f7a48;
}

.ai-assistant-typing {
  display: none;
  gap: 4px;
  padding: 8px 4px;
}

.ai-assistant-typing.is-visible {
  display: flex;
}

.ai-assistant-typing span {
  width: 6px;
  height: 6px;
  background: #14965A;
  opacity: 0.35;
  animation: ai-assistant-dot 1s infinite;
}

.ai-assistant-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.ai-assistant-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes ai-assistant-dot {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

.ai-assistant-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 0;
  background: #fff;
  border-top: 1px solid #eee;
}

.ai-assistant-chips[hidden] {
  display: none;
}

.ai-assistant-chip {
  border: 1px solid #d9e8df;
  background: #f4fbf8;
  color: #1a5c3d;
  padding: 6px 12px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
}

.ai-assistant-chip:hover,
.ai-assistant-chip:focus {
  background: #e5f5ec;
  outline: none;
}

.ai-assistant-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px 12px;
  background: #fff;
}

.ai-assistant-composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 96px;
  resize: none;
  border: 1px solid #d7d7d7;
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  line-height: 1.6;
  color: var(--text-color, #262626);
}

.ai-assistant-composer textarea:focus {
  border-color: #14965A;
  outline: none;
}

.ai-assistant-send {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border: 0;
  background: #14965A;
  color: #fff;
  cursor: pointer;
}

.ai-assistant-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-assistant-error {
  color: #b91c1c;
  font-size: 14px;
  padding: 0 12px 8px;
  background: #fff;
}

.ai-field-applied {
  box-shadow: 0 0 0 2px rgba(20, 150, 90, 0.45) !important;
  transition: box-shadow 0.2s ease;
}

html.ai-assistant-open {
  overflow-x: hidden;
}

html.ai-assistant-open body {
  box-sizing: border-box;
  width: 100%;
  padding-right: var(--ai-assistant-panel-width, 400px);
  transition: padding-right 0.2s ease;
}

@media (max-width: 575px) {
  .ai-assistant {
    right: 16px;
    left: auto;
    bottom: 18px;
  }

  .ai-assistant.is-open {
    top: var(--site-header-height, 72px);
    right: 0;
    bottom: 0;
    left: auto;
  }

  .ai-assistant-fab {
    width: 52px;
    height: 52px;
  }

  .ai-assistant.is-open .ai-assistant-panel {
    width: min(100vw, 400px);
    max-width: 100vw;
    height: 100%;
  }
}
