:root {
  --sorena-primary: #2196F3;
  --sorena-accent: #1976D2;
  --sorena-bg: #ffffff;
  --sorena-surface: #f5f5f5;
  --sorena-text: #212121;
  --sorena-text-secondary: #757575;
  --sorena-border: #e0e0e0;
  --sorena-shadow-1: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
  --sorena-shadow-2: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
  --sorena-shadow-3: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
  --sorena-shadow-4: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
  --sorena-radius: 24px;
  --sorena-radius-sm: 16px;
  --sorena-radius-xs: 12px;
  --sorena-transition: cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

.sorena-chatbot-widget-v2 {
  position: fixed;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Vazir', sans-serif;
  direction: rtl;
}

.sorena-chatbot-widget-v2.position-bottom-right {
  bottom: 24px;
  right: 24px;
}

.sorena-chatbot-widget-v2.position-bottom-left {
  bottom: 24px;
  left: 24px;
}

.sorena-chatbot-widget-v2.position-top-right {
  top: 24px;
  right: 24px;
}

.sorena-chatbot-widget-v2.position-top-left {
  top: 24px;
  left: 24px;
}

.sorena-chatbot-bubble {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sorena-primary), var(--sorena-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--sorena-shadow-3);
  transition: all 0.3s var(--sorena-transition);
  color: white;
  animation: fadeInUp 0.5s var(--sorena-transition);
  position: relative;
  overflow: hidden;
}

.sorena-chatbot-bubble::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.sorena-chatbot-bubble:hover {
  transform: scale(1.08);
  box-shadow: var(--sorena-shadow-4);
}

.sorena-chatbot-bubble:active::before {
  width: 200%;
  height: 200%;
}

.sorena-chatbot-bubble svg {
  width: 32px;
  height: 32px;
  position: relative;
  z-index: 1;
}

.sorena-chatbot-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  background: #f44336;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--sorena-shadow-2);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sorena-chatbot-window {
  position: absolute;
  bottom: 88px;
  right: 0;
  width: 420px;
  height: 640px;
  background: var(--sorena-bg);
  border-radius: var(--sorena-radius);
  box-shadow: var(--sorena-shadow-4);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: slideInUp 0.4s var(--sorena-transition);
}

.sorena-chatbot-widget-v2.position-bottom-left .sorena-chatbot-window {
  right: auto;
  left: 0;
}

.sorena-chatbot-widget-v2.position-top-right .sorena-chatbot-window,
.sorena-chatbot-widget-v2.position-top-left .sorena-chatbot-window {
  bottom: auto;
  top: 88px;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.sorena-chatbot-window.open {
  display: flex;
}

.sorena-chatbot-header {
  background: linear-gradient(135deg, var(--sorena-primary), var(--sorena-accent));
  color: white;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--sorena-shadow-2);
  position: relative;
  z-index: 10;
}

.sorena-chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sorena-chatbot-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--sorena-shadow-1);
}

.sorena-chatbot-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.sorena-chatbot-title h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.sorena-chatbot-status {
  font-size: 13px;
  opacity: 0.95;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4caf50;
  animation: pulse 2s infinite;
}

.sorena-chatbot-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  cursor: pointer;
  padding: 10px;
  border-radius: var(--sorena-radius-xs);
  transition: all 0.2s var(--sorena-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.sorena-chatbot-close::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.4s, height 0.4s;
}

.sorena-chatbot-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sorena-chatbot-close:active::before {
  width: 200%;
  height: 200%;
}

.sorena-chatbot-auth-form {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.auth-form-content {
  background: white;
  border-radius: var(--sorena-radius);
  padding: 40px 32px;
  box-shadow: var(--sorena-shadow-3);
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.auth-form-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sorena-primary), var(--sorena-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--sorena-shadow-2);
}

.auth-form-content h3 {
  margin: 0 0 12px 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--sorena-text);
}

.auth-form-content > p {
  margin: 0 0 32px 0;
  color: var(--sorena-text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

.auth-form-fields {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.form-field {
  position: relative;
  text-align: right;
}

.form-field input {
  width: 100%;
  padding: 16px 16px 8px 16px;
  border: 2px solid var(--sorena-border);
  border-radius: var(--sorena-radius-xs);
  font-size: 16px;
  font-family: inherit;
  transition: all 0.3s var(--sorena-transition);
  background: var(--sorena-surface);
}

.form-field input:focus {
  outline: none;
  border-color: var(--sorena-primary);
  background: white;
  box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.1);
}

.form-field label {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 14px;
  color: var(--sorena-text-secondary);
  pointer-events: none;
  transition: all 0.3s var(--sorena-transition);
}

.form-field input:focus + label,
.form-field input:not(:placeholder-shown) + label {
  top: 6px;
  font-size: 11px;
  color: var(--sorena-primary);
  font-weight: 600;
}

.field-hint {
  display: block;
  font-size: 12px;
  color: var(--sorena-text-secondary);
  margin-top: 6px;
  text-align: right;
}

.auth-submit-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--sorena-primary), var(--sorena-accent));
  color: white;
  border: none;
  border-radius: var(--sorena-radius-xs);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: var(--sorena-shadow-2);
  transition: all 0.3s var(--sorena-transition);
  position: relative;
  overflow: hidden;
}

.auth-submit-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.auth-submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--sorena-shadow-3);
}

.auth-submit-btn:active::before {
  width: 300%;
  height: 300%;
}

.auth-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.auth-privacy-note {
  margin-top: 24px;
  padding: 12px;
  background: rgba(76, 175, 80, 0.1);
  border-radius: var(--sorena-radius-xs);
  color: #2e7d32;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.sorena-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--sorena-surface);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sorena-chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.sorena-chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.sorena-chatbot-messages::-webkit-scrollbar-thumb {
  background: #bdbdbd;
  border-radius: 3px;
}

.sorena-chatbot-message {
  display: flex;
  gap: 12px;
  animation: messageSlideIn 0.4s var(--sorena-transition);
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sorena-chatbot-message.user-message {
  flex-direction: row-reverse;
}

.sorena-chatbot-message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sorena-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  box-shadow: var(--sorena-shadow-1);
}

.sorena-chatbot-message.user-message .sorena-chatbot-message-avatar {
  background: #4caf50;
}

.sorena-chatbot-message-content {
  flex: 1;
  max-width: 75%;
}

.sorena-chatbot-message-bubble {
  background: white;
  padding: 14px 18px;
  border-radius: var(--sorena-radius-sm);
  box-shadow: var(--sorena-shadow-1);
  color: var(--sorena-text);
  line-height: 1.6;
  word-wrap: break-word;
  position: relative;
}

.sorena-chatbot-message.user-message .sorena-chatbot-message-bubble {
  background: linear-gradient(135deg, var(--sorena-primary), var(--sorena-accent));
  color: white;
}

.sorena-chatbot-message-time {
  font-size: 11px;
  color: var(--sorena-text-secondary);
  margin-top: 6px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sorena-chatbot-typing {
  display: flex;
  gap: 6px;
  padding: 14px 18px;
}

.sorena-chatbot-typing span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--sorena-text-secondary);
  animation: typingDot 1.4s infinite;
}

.sorena-chatbot-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.sorena-chatbot-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingDot {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  30% {
    opacity: 1;
    transform: scale(1.2);
  }
}

.sorena-chatbot-card {
  background: white;
  border-radius: var(--sorena-radius-sm);
  overflow: hidden;
  margin-top: 12px;
  box-shadow: var(--sorena-shadow-2);
  transition: all 0.3s var(--sorena-transition);
}

.sorena-chatbot-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--sorena-shadow-3);
}

.sorena-chatbot-card-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: var(--sorena-surface);
}

.sorena-chatbot-card-content {
  padding: 16px;
}

.sorena-chatbot-card-title {
  font-weight: 700;
  font-size: 16px;
  margin: 0 0 8px 0;
  color: var(--sorena-text);
}

.sorena-chatbot-card-description {
  font-size: 14px;
  color: var(--sorena-text-secondary);
  margin: 0 0 12px 0;
  line-height: 1.6;
}

.sorena-chatbot-card-price {
  font-weight: 700;
  color: var(--sorena-primary);
  font-size: 16px;
  margin-bottom: 12px;
}

.sorena-chatbot-card-button {
  display: inline-block;
  background: linear-gradient(135deg, var(--sorena-primary), var(--sorena-accent));
  color: white;
  padding: 10px 20px;
  border-radius: var(--sorena-radius-xs);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s var(--sorena-transition);
  box-shadow: var(--sorena-shadow-1);
  position: relative;
  overflow: hidden;
}

.sorena-chatbot-card-button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.sorena-chatbot-card-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--sorena-shadow-2);
}

.sorena-chatbot-card-button:active::before {
  width: 300%;
  height: 300%;
}

.sorena-chatbot-quick-replies {
  padding: 12px 24px;
  background: white;
  border-top: 1px solid var(--sorena-border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sorena-chatbot-quick-reply {
  background: white;
  border: 2px solid var(--sorena-primary);
  color: var(--sorena-primary);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s var(--sorena-transition);
  position: relative;
  overflow: hidden;
}

.sorena-chatbot-quick-reply::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: var(--sorena-primary);
  transform: translate(-50%, -50%);
  transition: width 0.4s, height 0.4s;
  z-index: 0;
}

.sorena-chatbot-quick-reply:hover {
  background: var(--sorena-primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--sorena-shadow-1);
}

.sorena-chatbot-quick-reply:active::before {
  width: 300%;
  height: 300%;
}

.sorena-chatbot-input-area {
  background: white;
  border-top: 1px solid var(--sorena-border);
  padding: 16px 20px;
}

.sorena-chatbot-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--sorena-surface);
  border-radius: var(--sorena-radius-sm);
  padding: 10px;
}

.sorena-chatbot-attach-btn,
.sorena-chatbot-send-btn {
  background: transparent;
  border: none;
  color: var(--sorena-primary);
  cursor: pointer;
  padding: 10px;
  border-radius: var(--sorena-radius-xs);
  transition: all 0.2s var(--sorena-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.sorena-chatbot-attach-btn::before,
.sorena-chatbot-send-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(33, 150, 243, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.4s, height 0.4s;
}

.sorena-chatbot-attach-btn:hover,
.sorena-chatbot-send-btn:hover {
  background: rgba(33, 150, 243, 0.1);
}

.sorena-chatbot-attach-btn:active::before,
.sorena-chatbot-send-btn:active::before {
  width: 200%;
  height: 200%;
}

.sorena-chatbot-send-btn {
  background: linear-gradient(135deg, var(--sorena-primary), var(--sorena-accent));
  color: white;
}

.sorena-chatbot-send-btn::before {
  background: rgba(255, 255, 255, 0.3);
}

.sorena-chatbot-send-btn:hover {
  background: linear-gradient(135deg, var(--sorena-accent), var(--sorena-primary));
  transform: scale(1.05);
}

.sorena-chatbot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.sorena-chatbot-input {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  padding: 10px;
  max-height: 120px;
  color: var(--sorena-text);
}

.sorena-chatbot-input::placeholder {
  color: var(--sorena-text-secondary);
}

.sorena-chatbot-footer {
  background: var(--sorena-surface);
  padding: 12px 20px;
  border-top: 1px solid var(--sorena-border);
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.footer-contact {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--sorena-text-secondary);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.2s;
}

.footer-contact:hover {
  color: var(--sorena-primary);
}

.sorena-chatbot-image-preview {
  position: relative;
  display: inline-block;
  margin: 8px 0;
}

.sorena-chatbot-image-preview img {
  max-width: 220px;
  max-height: 220px;
  border-radius: var(--sorena-radius-sm);
  display: block;
  box-shadow: var(--sorena-shadow-2);
}

.sorena-chatbot-image-preview-remove {
  position: absolute;
  top: -10px;
  right: -10px;
  background: #f44336;
  color: white;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  box-shadow: var(--sorena-shadow-2);
  transition: transform 0.2s;
}

.sorena-chatbot-image-preview-remove:hover {
  transform: scale(1.1);
}

@media (max-width: 768px) {
  .sorena-chatbot-widget-v2.mobile-fullscreen .sorena-chatbot-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    max-width: none;
  }
  
  .sorena-chatbot-window {
    width: 100%;
    max-width: 420px;
    height: 580px;
  }
}

@media (max-width: 480px) {
  .sorena-chatbot-bubble {
    width: 60px;
    height: 60px;
  }
  
  .sorena-chatbot-widget-v2 {
    bottom: 20px;
    right: 20px;
  }
  
  .sorena-chatbot-window {
    width: calc(100vw - 40px);
    height: calc(100vh - 120px);
  }
}

.sorena-chatbot-error {
  background: #ffebee;
  color: #c62828;
  padding: 14px 18px;
  border-radius: var(--sorena-radius-sm);
  font-size: 14px;
  margin: 8px 0;
  box-shadow: var(--sorena-shadow-1);
  border-right: 4px solid #f44336;
}

.sorena-chatbot-loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
