/* Chat Drawer - Desktop Mode Side Panel */

/* Drawer container (hidden on mobile) */
.chat-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  pointer-events: none;
  display: none; /* Hidden on mobile by default */
}

/* Show drawer only on desktop (1024px+) */
@media (min-width: 1024px) {
  .chat-drawer {
    display: block;
  }
}

.chat-drawer.open {
  pointer-events: all;
}

/* Overlay (darker background) */
.chat-drawer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.chat-drawer.open .chat-drawer-overlay {
  opacity: 1;
  pointer-events: all;
}

/* Drawer panel (slides in from right) */
.chat-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 480px;
  max-width: 90vw;
  height: 100%;
  background: var(--brokerly-secondary-background);
  border-left: 1px solid var(--brokerly-border-medium);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12), -2px 0 8px rgba(0, 0, 0, 0.08);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Animated gradient border on left edge */
.chat-drawer-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 100%;
  background: linear-gradient(180deg, 
    #FF6B6B 0%,
    #FFD93D 12.5%,
    #6BCF7F 25%,
    #4D96FF 37.5%,
    #9D4EDD 50%,
    #FF6B9D 62.5%,
    #FFB347 75%,
    #7B68EE 87.5%,
    #FF6B6B 100%
  );
  background-size: 100% 200%;
  opacity: 0;
  transition: opacity 0.3s ease;
  animation: gradient-slide 4s ease-in-out infinite;
  box-shadow: 0 0 20px rgba(157, 78, 221, 0.4);
  filter: blur(0.3px);
}

.chat-drawer.open .chat-drawer-panel::before {
  opacity: 0.8;
  animation: gradient-slide 4s ease-in-out infinite, gradient-glow 4s ease-in-out infinite;
}

@keyframes gradient-slide {
  0%, 100% {
    background-position: 0% 0%;
  }
  50% {
    background-position: 0% 100%;
  }
}

@keyframes gradient-glow {
  0%, 100% {
    box-shadow: 
      0 0 15px rgba(255, 107, 107, 0.5),
      0 0 30px rgba(255, 107, 107, 0.3),
      0 0 45px rgba(255, 107, 107, 0.1);
  }
  25% {
    box-shadow: 
      0 0 15px rgba(77, 150, 255, 0.5),
      0 0 30px rgba(77, 150, 255, 0.3),
      0 0 45px rgba(77, 150, 255, 0.1);
  }
  50% {
    box-shadow: 
      0 0 15px rgba(157, 78, 221, 0.5),
      0 0 30px rgba(157, 78, 221, 0.3),
      0 0 45px rgba(157, 78, 221, 0.1);
  }
  75% {
    box-shadow: 
      0 0 15px rgba(255, 182, 71, 0.5),
      0 0 30px rgba(255, 182, 71, 0.3),
      0 0 45px rgba(255, 182, 71, 0.1);
  }
}

.chat-drawer.open .chat-drawer-panel {
  transform: translateX(0);
}

/* Drawer Header */
.chat-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  background: var(--brokerly-secondary-background);
}

.chat-drawer-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-broker-avatar-small {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 2px;
  background: linear-gradient(135deg, 
    #FF6B6B 0%,
    #FFD93D 12.5%,
    #6BCF7F 25%,
    #4D96FF 37.5%,
    #9D4EDD 50%,
    #FF6B9D 62.5%,
    #FFB347 75%,
    #7B68EE 87.5%,
    #FF6B6B 100%
  );
}

.avatar-circle-32 {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brokerly-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-circle-32 .avatar-initial {
  font-size: 16px;
  font-weight: 500;
  color: white;
}

.drawer-title-info {
  display: flex;
  flex-direction: column;
}

.drawer-title-info h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--brokerly-text-primary);
}

.drawer-subtitle {
  font-size: 13px;
  color: var(--brokerly-text-secondary);
}

.chat-drawer-close {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--brokerly-text-secondary);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.chat-drawer-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--brokerly-text-primary);
}

/* Drawer Messages Area */
.chat-drawer-messages {
  flex: 1;
  overflow-y: auto;
  background: var(--brokerly-section-background);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Reuse message styles from chat-ios.css */
.chat-drawer-messages .message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
}

.chat-drawer-messages .user-message {
  flex-direction: row-reverse;
  margin-left: 40px;
}

.chat-drawer-messages .ai-message {
  flex-direction: column;
  align-items: flex-start;
  margin-right: 40px;
}

/* Drawer Input Area */
.chat-drawer-input {
  background: var(--brokerly-secondary-background);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.chat-drawer-input .input-divider {
  height: 0.5px;
  background: rgba(60, 60, 67, 0.29);
}

.chat-drawer-input .input-container {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.chat-drawer-input .text-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  height: 44px;
  background: var(--brokerly-input-background);
  border: 1px solid var(--brokerly-border-subtle);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-drawer-input .chat-text-input {
  flex: 1;
  height: 100%;
  border: none;
  background: transparent;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 400;
  color: var(--brokerly-text-primary);
  outline: none;
  position: relative;
  z-index: 2;
}

.chat-drawer-input .chat-text-input::placeholder {
  color: var(--brokerly-text-tertiary);
}

/* Waveform Container - 24 bars (for voice input) */
.chat-drawer-input .waveform-container {
  position: absolute;
  left: 16px;
  right: 48px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  z-index: 1;
  pointer-events: none;
}

.chat-drawer-input .waveform-bar {
  flex: 1;
  background: var(--brokerly-primary);
  border-radius: 2px;
  min-height: 2px;
  transition: height 0.05s ease-out;
}

/* Clear Button - X icon */
.chat-drawer-input .clear-button {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--brokerly-text-tertiary);
  cursor: pointer;
  padding: 0;
  display: none;
  z-index: 2;
}

.chat-drawer-input .clear-button:hover {
  color: var(--brokerly-text-secondary);
}

/* Voice and Send Buttons */
.chat-drawer-input .voice-button,
.chat-drawer-input .send-button-ios {
  width: 44px;
  height: 44px;
  border-radius: 22px;
  border: none;
  background: var(--brokerly-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chat-drawer-input .voice-button:hover,
.chat-drawer-input .send-button-ios:hover:not(:disabled) {
  background: var(--brokerly-primary-dark);
  transform: scale(1.05);
}

.chat-drawer-input .send-button-ios:disabled {
  background: var(--brokerly-text-tertiary);
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-drawer-input .voice-button.recording {
  background: #FF3B30;
  animation: pulse-recording 1.5s ease-in-out infinite;
}

@keyframes pulse-recording {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.9;
  }
}

/* Smaller screens (tablets) */
@media (max-width: 1280px) and (min-width: 1024px) {
  .chat-drawer-panel {
    width: 400px;
  }
}

/* Very small desktop */
@media (max-width: 1024px) {
  .chat-drawer-panel {
    width: 360px;
  }
}

/* Mobile: Hide drawer completely */
@media (max-width: 1023px) {
  .chat-drawer {
    display: none !important;
  }
}

/* Smooth animations */
@media (prefers-reduced-motion: reduce) {
  .chat-drawer-panel,
  .chat-drawer-overlay {
    transition: none;
  }
}

