/**
 * Cyber UXcellence Awards - Chat Widget Styles
 * Floating AI assistant for the awards site
 */

/* --------------------------------------------------
 * CHAT WIDGET CONTAINER
 * -------------------------------------------------- */
.chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 5000;
  font-family: var(--font-primary);
}

/* --------------------------------------------------
 * TOGGLE BUTTON
 * -------------------------------------------------- */
.chat-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--mg-orange);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(244, 113, 20, 0.4);
  transition: all var(--transition-normal);
  position: relative;
}

.chat-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(244, 113, 20, 0.5);
}

.chat-toggle svg {
  width: 28px;
  height: 28px;
  color: var(--white);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.chat-toggle .chat-icon {
  opacity: 1;
  transform: scale(1);
}

.chat-toggle .close-icon {
  position: absolute;
  opacity: 0;
  transform: scale(0.5);
}

.chat-widget.open .chat-toggle .chat-icon {
  opacity: 0;
  transform: scale(0.5);
}

.chat-widget.open .chat-toggle .close-icon {
  opacity: 1;
  transform: scale(1);
}

/* --------------------------------------------------
 * CHAT PANEL
 * -------------------------------------------------- */
.chat-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--white);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all var(--transition-normal);
}

.chat-widget.open .chat-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* --------------------------------------------------
 * CHAT HEADER
 * -------------------------------------------------- */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--mg-dark-purple);
  color: var(--white);
}

.chat-header-info {
  display: flex;
  flex-direction: column;
}

.chat-title {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.2;
}

.chat-subtitle {
  font-size: 0.8rem;
  opacity: 0.8;
}

.chat-settings {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background var(--transition-fast);
}

.chat-settings:hover {
  background: rgba(255, 255, 255, 0.15);
}

.chat-settings svg {
  width: 20px;
  height: 20px;
  color: var(--white);
}

/* --------------------------------------------------
 * MODEL SELECTION SCREEN
 * -------------------------------------------------- */
.chat-model-select {
  display: none;
  flex-direction: column;
  padding: 24px 20px;
  flex: 1;
  overflow-y: auto;
}

.chat-model-select.active {
  display: flex;
}

.chat-model-select h3 {
  font-size: 1.25rem;
  color: var(--mg-dark-purple);
  margin-bottom: 8px;
}

.chat-model-select > p {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.model-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.model-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 16px;
  border: 2px solid #e0e0e0;
  border-radius: var(--border-radius-md);
  background: var(--white);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.model-option:hover {
  border-color: var(--mg-orange);
  background: #fff8f5;
}

.model-option.recommended {
  border-color: var(--mg-dark-purple);
  position: relative;
}

.model-option.recommended:hover {
  border-color: var(--mg-orange);
}

.model-badge {
  background: var(--mg-dark-purple);
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.model-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--mg-nearly-black);
  margin-bottom: 4px;
}

.model-size {
  font-size: 0.85rem;
  color: var(--mg-orange);
  font-weight: 500;
  margin-bottom: 4px;
}

.model-desc {
  font-size: 0.85rem;
  color: #666;
  line-height: 1.4;
}

/* --------------------------------------------------
 * LOADING SCREEN
 * -------------------------------------------------- */
.chat-loading {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  flex: 1;
  text-align: center;
}

.chat-loading.active {
  display: flex;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e0e0e0;
  border-top-color: var(--mg-orange);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--mg-dark-purple);
  margin-bottom: 16px;
}

.loading-progress {
  width: 100%;
  max-width: 240px;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}

.loading-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--mg-orange), var(--mg-red));
  border-radius: 4px;
  transition: width 0.3s ease;
}

.loading-status {
  font-size: 0.85rem;
  color: #666;
}

/* --------------------------------------------------
 * MESSAGES AREA
 * -------------------------------------------------- */
.chat-messages {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  gap: 12px;
  background: #f8f9fa;
}

.chat-messages.active {
  display: flex;
}

.message {
  display: flex;
  max-width: 85%;
}

.message.user {
  align-self: flex-end;
}

.message.assistant {
  align-self: flex-start;
}

.message-content {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.message.user .message-content {
  background: var(--mg-dark-purple);
  color: var(--white);
  border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
  background: var(--white);
  color: var(--mg-nearly-black);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Typing indicator */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--mg-orange);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* --------------------------------------------------
 * INPUT AREA
 * -------------------------------------------------- */
.chat-input-area {
  display: none;
  align-items: flex-end;
  padding: 12px 16px;
  background: var(--white);
  border-top: 1px solid #e0e0e0;
  gap: 12px;
}

.chat-input-area.active {
  display: flex;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 24px;
  font-family: var(--font-primary);
  font-size: 0.95rem;
  resize: none;
  outline: none;
  max-height: 120px;
  transition: border-color var(--transition-fast);
}

.chat-input:focus {
  border-color: var(--mg-orange);
}

.chat-input::placeholder {
  color: #999;
}

.chat-send {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--mg-red);
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.chat-send:hover:not(:disabled) {
  background: #b7131d;
  transform: scale(1.05);
}

.chat-send:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.chat-send svg {
  width: 20px;
  height: 20px;
}

/* --------------------------------------------------
 * WARNING / UNSUPPORTED
 * -------------------------------------------------- */
.chat-warning {
  display: none;
  padding: 16px;
  background: #fff3cd;
  color: #856404;
  text-align: center;
  font-size: 0.85rem;
}

.chat-warning p {
  margin: 0;
}

/* --------------------------------------------------
 * MOBILE RESPONSIVE
 * -------------------------------------------------- */
@media (max-width: 768px) {
  .chat-widget {
    bottom: 16px;
    right: 16px;
  }

  .chat-toggle {
    width: 56px;
    height: 56px;
  }

  .chat-toggle svg {
    width: 24px;
    height: 24px;
  }

  .chat-panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    max-height: calc(100vh - 100px);
    bottom: 68px;
    right: -8px;
  }

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

  .chat-title {
    font-size: 1rem;
  }

  .chat-messages {
    padding: 12px;
  }

  .message-content {
    font-size: 0.9rem;
    padding: 10px 14px;
  }

  .chat-input-area {
    padding: 10px 12px;
  }

  .chat-input {
    padding: 10px 14px;
    font-size: 0.9rem;
  }

  .chat-send {
    width: 40px;
    height: 40px;
  }

  .chat-send svg {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 480px) {
  .chat-panel {
    border-radius: var(--border-radius-md);
  }

  .model-option {
    padding: 14px;
  }

  .model-name {
    font-size: 0.95rem;
  }

  .model-desc {
    font-size: 0.8rem;
  }
}

/* --------------------------------------------------
 * SCROLLBAR STYLING
 * -------------------------------------------------- */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* --------------------------------------------------
 * ANIMATION FOR INITIAL APPEARANCE
 * -------------------------------------------------- */
@keyframes chatWidgetFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-widget {
  animation: chatWidgetFadeIn 0.5s ease 1s both;
}
