.ros-ai-widget {
  --ros-ai-primary: #1f5fa8;
  --ros-ai-bg: rgba(255, 255, 255, 0.85);
  --ros-ai-border: rgba(255, 255, 255, 0.4);
  --ros-ai-shadow: 0 20px 60px rgba(15, 23, 42, 0.18);
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99998;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.ros-ai-widget.ros-ai--left { right: auto; left: 24px; }

.ros-ai-button {
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, var(--ros-ai-primary), #2980b9);
  color: #fff; border: none;
  box-shadow: 0 8px 24px rgba(31, 95, 168, 0.45);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}
.ros-ai-button::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ros-ai-primary), #2980b9);
  opacity: 0.3;
  z-index: -1;
  animation: ros-ai-pulse 2.5s ease-out infinite;
}
@keyframes ros-ai-pulse {
  0% { transform: scale(1); opacity: 0.4; }
  100% { transform: scale(1.4); opacity: 0; }
}
.ros-ai-button:hover { transform: scale(1.08); box-shadow: 0 12px 32px rgba(31, 95, 168, 0.55); }

.ros-ai-window {
  position: fixed; bottom: 96px; right: 24px;
  width: 400px; max-width: calc(100vw - 32px);
  height: 600px; max-height: calc(100vh - 120px);
  background: var(--ros-ai-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--ros-ai-border);
  border-radius: 20px;
  box-shadow: var(--ros-ai-shadow);
  z-index: 99999; display: none; flex-direction: column; overflow: hidden;
  font-size: 14px; line-height: 1.55; color: #0f172a;
  transform-origin: bottom right;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.ros-ai-widget.ros-ai--left .ros-ai-window { right: auto; left: 24px; transform-origin: bottom left; }
.ros-ai-window.is-open { display: flex; animation: ros-ai-slide-up 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
.ros-ai-window.is-minimized { height: 60px; }
.ros-ai-window.is-minimized .ros-ai-messages,
.ros-ai-window.is-minimized .ros-ai-input-area,
.ros-ai-window.is-minimized .ros-ai-status { display: none; }
@keyframes ros-ai-slide-up {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ros-ai-header {
  background: linear-gradient(135deg, var(--ros-ai-primary), #2980b9);
  color: #fff !important;
  padding: 14px 18px;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}
.ros-ai-header h3 { margin: 0; font-size: 16px; font-weight: 600; color: #fff !important; }
.ros-ai-header h3, .ros-ai-header { color: #fff !important; }
.ros-ai-header-actions { display: flex; gap: 4px; align-items: center; }
.ros-ai-header-actions button {
  background: rgba(255, 255, 255, 0.15);
  border: none; color: #fff !important;
  cursor: pointer; padding: 6px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.ros-ai-header-actions button:hover { background: rgba(255, 255, 255, 0.28); }
.ros-ai-close { font-size: 20px !important; line-height: 1 !important; padding: 4px 8px !important; }
.ros-ai-header-actions svg { display: block; }

.ros-ai-status {
  padding: 0 14px;
  font-size: 11px;
  color: #64748b;
  min-height: 0;
  transition: min-height 0.2s, padding 0.2s;
  overflow: hidden;
}
.ros-ai-status:not(:empty) {
  min-height: 28px;
  padding: 6px 14px;
  background: rgba(31, 95, 168, 0.06);
  color: var(--ros-ai-primary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ros-ai-status::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ros-ai-primary);
  animation: ros-ai-blink 1.4s ease-in-out infinite;
}

.ros-ai-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}
.ros-ai-messages::-webkit-scrollbar { width: 6px; }
.ros-ai-messages::-webkit-scrollbar-track { background: transparent; }
.ros-ai-messages::-webkit-scrollbar-thumb { background: rgba(31, 95, 168, 0.2); border-radius: 3px; }

.ros-ai-msg { display: flex; max-width: 85%; animation: ros-ai-msg-in 0.3s ease-out; }
@keyframes ros-ai-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.ros-ai-msg-bot { align-self: flex-start; }
.ros-ai-msg-user { align-self: flex-end; }
.ros-ai-bubble {
  padding: 10px 14px; border-radius: 18px; word-wrap: break-word;
  white-space: pre-wrap; line-height: 1.55;
}
.ros-ai-msg-user .ros-ai-bubble {
  background: linear-gradient(135deg, var(--ros-ai-primary), #2980b9);
  color: #fff; border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(31, 95, 168, 0.25);
}
.ros-ai-msg-bot .ros-ai-bubble {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.ros-ai-input-area {
  padding: 12px; background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(226, 232, 240, 0.6);
  display: flex; gap: 8px;
  flex-shrink: 0;
}
.ros-ai-input {
  flex: 1; padding: 10px 14px; border: 1px solid #e2e8f0; border-radius: 12px;
  font: inherit; resize: none; max-height: 100px;
  background: rgba(255, 255, 255, 0.9);
  transition: all 0.2s;
}
.ros-ai-input:focus {
  outline: none; border-color: var(--ros-ai-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(31, 95, 168, 0.15);
}
.ros-ai-send {
  background: linear-gradient(135deg, var(--ros-ai-primary), #2980b9);
  color: #fff !important; border: none; border-radius: 12px;
  width: 44px; height: 44px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0; flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(31, 95, 168, 0.3);
}
.ros-ai-send:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(31, 95, 168, 0.45);
}
.ros-ai-send:disabled { opacity: 0.5; cursor: not-allowed; }
.ros-ai-send svg { display: block; margin: 0 auto; }

.ros-ai-typing { display: inline-flex; gap: 4px; padding: 14px 18px; }
.ros-ai-typing span { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; animation: ros-ai-blink 1.4s infinite; }
.ros-ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ros-ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ros-ai-blink { 0%, 60%, 100% { opacity: 0.3; } 30% { opacity: 1; } }

.ros-ai-lead-form {
  background: linear-gradient(135deg, #fff8e1 0%, #fff3c4 100%);
  border: 1px solid #fbbf24; padding: 14px;
  border-radius: 12px; align-self: stretch; max-width: 100%;
  box-shadow: 0 2px 8px rgba(251, 191, 36, 0.15);
}
.ros-ai-lead-form input {
  display: block; width: 100%; padding: 8px 10px;
  margin-bottom: 8px; border: 1px solid #ddd; border-radius: 8px;
  font: inherit; box-sizing: border-box;
  background: #fff;
  transition: border-color 0.2s;
}
.ros-ai-lead-form input:focus {
  outline: none; border-color: #f59e0b;
}
.ros-ai-lead-form button {
  width: 100%; padding: 10px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff !important; border: none; border-radius: 8px;
  font-weight: 600; cursor: pointer;
  transition: all 0.2s;
}
.ros-ai-lead-form button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.ros-ai-err {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: #991b1b; padding: 8px 12px; border-radius: 10px;
  font-size: 13px; align-self: stretch;
  border: 1px solid #fca5a5;
}

@media (max-width: 480px) {
  .ros-ai-widget { bottom: 16px; right: 16px; }
  .ros-ai-widget.ros-ai--left { left: 16px; }
  .ros-ai-window {
    bottom: 0; right: 0; left: 0; width: 100%; max-width: 100vw;
    height: 100%; max-height: 100vh; border-radius: 0;
  }
  .ros-ai-widget.ros-ai--left .ros-ai-window { left: 0; }
  .ros-ai-button { width: 54px; height: 54px; }
}