/* ===========================================
   AI CHATBOT STYLES - Sanlam Theme
   Fresh Design v2
   =========================================== */

/* Global box-sizing for AI components */
.ai-chat-window *,
.ai-chat-window *::before,
.ai-chat-window *::after {
  box-sizing: border-box;
}

/* Chat Button - Pill shape with gradient */
.ai-chat-button {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: linear-gradient(135deg, #0075c9 0%, #004d87 100%);
  color: white;
  border: none;
  cursor: pointer;
  z-index: 99999999;
  box-shadow:
    0 8px 24px rgba(0, 117, 201, 0.35),
    0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-chat-button:hover {
  transform: translateY(-2px);
  box-shadow:
    0 12px 32px rgba(0, 117, 201, 0.4),
    0 4px 12px rgba(0, 0, 0, 0.15);
}

.ai-chat-button:active {
  transform: translateY(0);
}

/* Chat Window - Card with top accent */
.ai-chat-window {
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100svh - 140px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow:
    0 25px 80px rgba(0, 0, 0, 0.12),
    0 10px 30px rgba(0, 0, 0, 0.08);
  z-index: 999999999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(0, 117, 201, 0.08);
}

.ai-chat-window--expanded {
  width: 520px;
  height: 75svh;
}

/* Header - Clean with subtle gradient */
.ai-chat-header {
  padding: 18px 20px;
  background: linear-gradient(135deg, #0075c9 0%, #0066b3 100%);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  position: relative;
}

.ai-chat-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: rgba(255, 255, 255, 0.15);
}

.ai-chat-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-chat-header-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.2px;
}

.ai-chat-header-subtitle {
  font-size: 12px;
  opacity: 0.85;
  margin: 0;
  font-weight: 400;
}

.ai-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.ai-chat-header-btn {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.ai-chat-header-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* Chat Options */
.ai-chat-options {
  position: relative;
}

.ai-chat-options-trigger {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.ai-chat-options-trigger:hover {
  background: rgba(255, 255, 255, 0.18);
}

.ai-chat-options-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.12),
    0 2px 8px rgba(0, 0, 0, 0.08);
  min-width: 190px;
  z-index: 100;
  overflow: hidden;
  border: 1px solid rgba(0, 117, 201, 0.1);
}

.ai-chat-options-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-family: "Allianz Neo", "Segoe UI", sans-serif;
  color: #1b2a4e;
  transition: all 0.15s ease;
}

.ai-chat-options-item:hover {
  background: #f0f6fc;
}

/* Messages Area - Subtle background pattern */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  scroll-behavior: smooth;
}

.ai-chat-messages-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Message Row */
.ai-message-row {
  display: flex;
  width: 100%;
  animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-message-row--left {
  justify-content: flex-start;
}

.ai-message-row--right {
  justify-content: flex-end;
}

/* Message Bubbles - Refined shapes */
.ai-message {
  max-width: 82%;
  padding: 12px 16px;
  border-radius: 18px;
  position: relative;
}

.ai-message--user {
  background: linear-gradient(135deg, #0075c9 0%, #0066b3 100%);
  color: white;
  border-bottom-right-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 117, 201, 0.25);
}

.ai-message--assistant {
  background: #ffffff;
  color: #1b2a4e;
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 117, 201, 0.08);
}

.ai-message-content {
  font-size: 14px;
  line-height: 1.55;
}

.ai-message-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-message-timestamp {
  font-size: 10px;
  opacity: 0.6;
  margin: 6px 0 0;
  text-align: right;
}

.ai-message-special {
  max-width: 88%;
  width: 88%;
  box-sizing: border-box;
}

/* Text Formatting */
.ai-text-formatting {
  font-size: 14px;
  line-height: 1.6;
}

.ai-text-formatting p {
  margin: 0 0 8px;
}

.ai-text-formatting p:last-child {
  margin-bottom: 0;
}

.ai-text-formatting ul,
.ai-text-formatting ol {
  margin: 8px 0;
  padding-left: 20px;
}

.ai-text-formatting code {
  background: rgba(0, 117, 201, 0.08);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 13px;
}

.ai-text-formatting pre {
  background: #f5f8fa;
  padding: 12px;
  border-radius: 10px;
  overflow-x: auto;
}

/* Input Area - Floating style */
.ai-chat-footer {
  padding: 16px 20px 20px;
  background: #ffffff;
  flex-shrink: 0;
  border-top: 1px solid rgba(0, 117, 201, 0.06);
}

.ai-chat-form {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #f5f8fb;
  border-radius: 14px;
  padding: 6px 6px 6px 16px;
  border: 1px solid rgba(0, 117, 201, 0.12);
  transition: all 0.2s ease;
}

.ai-chat-form:focus-within {
  border-color: #0075c9;
  box-shadow: 0 0 0 3px rgba(0, 117, 201, 0.1);
  background: #ffffff;
}

.ai-chat-input {
  flex: 1;
  padding: 10px 0;
  border: none;
  background: transparent;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  color: #1b2a4e;
}

.ai-chat-input::placeholder {
  color: rgba(27, 42, 78, 0.45);
}

.ai-send-button {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0075c9 0%, #0066b3 100%);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.ai-send-button:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 117, 201, 0.35);
}

.ai-send-button--disabled,
.ai-send-button:disabled {
  background: #d1d9e0;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Typing Indicator - Simple dots */
.ai-typing-container {
  display: flex;
  justify-content: flex-start;
  padding: 4px 0;
}

.ai-typing {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px 4px;
}

.ai-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0075c9;
  opacity: 0.5;
  animation: typingPulse 1.5s ease-in-out infinite;
}

.ai-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.ai-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingPulse {
  0%, 60%, 100% {
    transform: scale(1);
    opacity: 0.5;
  }
  30% {
    transform: scale(1.15);
    opacity: 1;
  }
}

/* Empty State */
.ai-empty-state {
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  text-align: center;
}

.ai-empty-intro {
  color: #1b2a4e;
  margin-bottom: 20px;
  font-size: 15px;
  line-height: 1.5;
}

.ai-empty-ask {
  font-size: 13px;
  color: rgba(27, 42, 78, 0.65);
  margin-bottom: 12px;
}

.ai-empty-label {
  font-size: 12px;
  color: rgba(27, 42, 78, 0.5);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.ai-empty-list {
  font-size: 13px;
  color: rgba(27, 42, 78, 0.6);
  padding-left: 0;
  margin: 0;
  list-style: none;
  text-align: left;
}

.ai-empty-list li {
  margin-bottom: 6px;
  padding-left: 16px;
  position: relative;
}

.ai-empty-list li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: #0075c9;
}

/* Component Cards - Clean elevated style */
.ai-component-card {
  background: #ffffff;
  border: 1px solid rgba(0, 117, 201, 0.12);
  border-radius: 16px;
  padding: 18px;
  box-sizing: border-box;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.ai-component-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.ai-component-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, rgba(0, 117, 201, 0.12) 0%, rgba(0, 117, 201, 0.06) 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0075c9;
  flex-shrink: 0;
}

.ai-component-title {
  font-size: 15px;
  font-weight: 600;
  color: #0b1f3a;
  margin: 0;
}

.ai-component-subtitle {
  font-size: 12px;
  color: rgba(27, 42, 78, 0.55);
  margin: 2px 0 0;
}

.ai-component-content {
  background: #f8fafc;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
  box-sizing: border-box;
}

.ai-component-entry {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 13px;
}

.ai-component-entry-label {
  color: rgba(27, 42, 78, 0.55);
}

.ai-component-entry-value {
  font-weight: 600;
  color: #1b2a4e;
}

.ai-component-button {
  width: 100%;
  padding: 12px 18px;
  background: linear-gradient(135deg, #0075c9 0%, #0066b3 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  font-size: 13px;
  font-family: "Allianz Neo", "Segoe UI", sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.ai-component-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 117, 201, 0.3);
}

.ai-component-note {
  font-size: 11px;
  color: rgba(27, 42, 78, 0.45);
  text-align: center;
  margin: 10px 0 0;
}

/* Upload Progress */
.ai-upload-progress {
  margin-bottom: 14px;
}

.ai-upload-progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.ai-upload-progress-label {
  font-size: 12px;
  color: rgba(27, 42, 78, 0.55);
}

.ai-upload-progress-count {
  font-size: 12px;
  font-weight: 600;
  color: #1b2a4e;
}

.ai-progress-bar {
  height: 6px;
  background: #e8eff5;
  border-radius: 3px;
  overflow: hidden;
}

.ai-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #0075c9 0%, #00a0e3 100%);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 3px;
}

.ai-upload-required {
  margin-top: 14px;
}

.ai-upload-required-label {
  font-size: 12px;
  font-weight: 600;
  color: #1b2a4e;
  margin: 0 0 10px;
}

.ai-upload-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border-radius: 10px;
  padding: 12px 14px;
}

.ai-upload-file-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-upload-file-icon {
  color: #0075c9;
}

.ai-upload-file-name {
  font-size: 13px;
  color: #1b2a4e;
}

.ai-upload-badge {
  font-size: 10px;
  padding: 4px 10px;
  background: linear-gradient(135deg, rgba(0, 117, 201, 0.12) 0%, rgba(0, 117, 201, 0.06) 100%);
  color: #0075c9;
  border-radius: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Dialog Overlay */
.ai-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 31, 58, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9999999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: overlayFade 0.2s ease-out;
}

@keyframes overlayFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ai-dialog {
  background: white;
  border-radius: 20px;
  padding: 28px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.2);
  animation: dialogSlide 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes dialogSlide {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.ai-dialog-title {
  font-size: 19px;
  font-weight: 700;
  font-family: "Allianz Neo", "Segoe UI", sans-serif;
  color: #0b1f3a;
  margin: 0 0 8px;
}

.ai-dialog-description {
  font-size: 14px;
  font-family: "Allianz Neo", "Segoe UI", sans-serif;
  color: rgba(27, 42, 78, 0.65);
  margin: 0 0 24px;
  line-height: 1.5;
}

.ai-dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.ai-dialog-button {
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: "Allianz Neo", "Segoe UI", sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ai-dialog-button--cancel {
  background: #f5f8fb;
  border: 1px solid rgba(0, 117, 201, 0.15);
  color: #1b2a4e;
}

.ai-dialog-button--cancel:hover {
  background: #edf2f7;
}

.ai-dialog-button--destructive {
  background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
  border: none;
  color: white;
}

.ai-dialog-button--destructive:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.35);
}

/* Responsive */
@media (max-width: 500px) {
  .ai-chat-window {
    right: 10px;
    left: 10px;
    bottom: 94px;
    width: auto;
    max-width: none;
    height: calc(100svh - 130px);
    border-radius: 16px;
  }

  .ai-chat-button {
    bottom: 20px;
    right: 16px;
    width: 54px;
    height: 54px;
    border-radius: 14px;
  }

  .ai-chat-header {
    padding: 16px;
  }

  .ai-chat-messages {
    padding: 16px;
  }

  .ai-chat-footer {
    padding: 12px 16px 16px;
  }
}
