/**
 * @stylesheet   chat-companion.css
 * @description  AI Wellness Companion chatbot styles. Covers the floating
 *               trigger button, slide-in chat panel, message bubbles, crisis
 *               banner, typing indicator, chip suggestions, and input area.
 * @project      MindBalance -- Mental Health Education Platform
 * @competition  TSA Webmaster 2025-26 | BPA Website Design Team Event #435, 2025-26
 * @topic        Mental Health Wellness
 * @author       [Your Name / Team Name]
 * @version      2.5.0
 * @since        January 29, 2026
 * @updated      March 16, 2026
 * @license      All Rights Reserved -- Educational Competition Use
 */

.cc-trigger {
  position: fixed;
  bottom: 140px;
  right: 30px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--user-accent, #f2c200);
  color: #fff;
  border: 3px solid rgba(255, 255, 255, 0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25), 0 0 0 4px rgba(var(--user-accent-rgb, 175, 145, 109), 0.2);
  z-index: 9990;
  transition: transform 0.2s ease, box-shadow 0.2s ease, bottom 0.3s ease;
}

.cc-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.35), 0 0 0 6px rgba(var(--user-accent-rgb, 175, 145, 109), 0.25);
}

.cc-trigger:active {
  transform: scale(0.95);
}

.cc-trigger__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: #e05252;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
}

.cc-trigger__badge.is-visible {
  display: block;
}

.cc-trigger.has-pulse {
  animation: ccPulse 2s ease-in-out 3;
}

@keyframes ccPulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18); }
  50% { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18), 0 0 0 12px rgba(242, 194, 0, 0.2); }
}

.cc-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  z-index: 9990;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  overflow: hidden;
}

.cc-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.cc-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #111 0%, #222 100%);
  color: #fff;
  flex-shrink: 0;
}

.cc-header__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--user-accent, #f2c200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.cc-header__info {
  flex: 1;
  min-width: 0;
}

.cc-header__name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

.cc-header__status {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  gap: 5px;
}

.cc-header__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
}

.cc-header__close {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.6);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}

.cc-header__close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.cc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.cc-messages::-webkit-scrollbar {
  width: 4px;
}

.cc-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 2px;
}

.cc-msg {
  max-width: 85%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cc-msg--user {
  align-self: flex-end;
}

.cc-msg--ai {
  align-self: flex-start;
}

.cc-msg__bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.65;
  word-wrap: break-word;
  letter-spacing: 0.01em;
}

.cc-msg--user .cc-msg__bubble {
  background: var(--user-accent, #f2c200);
  color: #111;
  border-bottom-right-radius: 4px;
}

.cc-msg--ai .cc-msg__bubble {
  background: #f3f4f6;
  color: #111;
  border-bottom-left-radius: 4px;
}

.cc-msg__time {
  font-size: 10px;
  color: #9ca3af;
  padding: 0 4px;
}

.cc-msg--user .cc-msg__time {
  text-align: right;
}

.cc-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  background: #f3f4f6;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.cc-typing__dot {
  width: 7px;
  height: 7px;
  background: #9ca3af;
  border-radius: 50%;
  animation: ccTypingBounce 1.4s ease-in-out infinite;
}

.cc-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.cc-typing__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ccTypingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

.cc-crisis {
  margin: 0 16px 8px;
  padding: 12px 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  font-size: 12.5px;
  color: #991b1b;
  line-height: 1.6;
  display: none;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.cc-crisis.is-visible {
  display: block;
}

.cc-crisis * {
  display: inline !important;
  float: none !important;
}

.cc-crisis a {
  color: #991b1b;
  font-weight: 700;
  text-decoration: underline;
}

.cc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px 4px;
  flex-shrink: 0;
}

.cc-chip {
  padding: 6px 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  font-size: 12px;
  color: #374151;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.cc-chip:hover {
  background: #f3f4f6;
  border-color: var(--user-accent, #f2c200);
}

.cc-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.cc-input__field {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  font-size: 13.5px;
  background: #f9fafb;
  color: #111;
  outline: none;
  transition: border-color 0.2s ease;
  font-family: inherit;
}

.cc-input__field::placeholder {
  color: #9ca3af;
}

.cc-input__field:focus {
  border-color: var(--user-accent, #f2c200);
}

.cc-input__send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--user-accent, #f2c200);
  color: #fff;
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  flex-shrink: 0;
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.cc-input__send ion-icon {
  font-size: 19px;
  color: #fff;
}

.cc-input__send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.cc-input__send:not(:disabled):hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cc-input__send:not(:disabled):active {
  transform: scale(0.95);
}

.cc-disclaimer {
  padding: 4px 16px 8px;
  font-size: 10px;
  color: #9ca3af;
  text-align: center;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .cc-panel {
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    height: calc(100dvh - 80px);
    max-height: calc(100dvh - 80px);
    border-radius: 16px;
  }

  .cc-trigger {
    bottom: 140px;
    right: 30px;
    width: 50px;
    height: 50px;
    font-size: 22px;
  }
}

[data-theme="dark"] .cc-trigger {
  background: var(--user-accent, #c9a84c);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(var(--user-accent-rgb, 175, 145, 109), 0.25);
}

[data-theme="dark"] .cc-trigger__badge {
  border-color: #1a1a1a;
}

[data-theme="dark"] .cc-panel {
  background: var(--bg-primary, #1a1a1a);
  border-color: var(--border-color, #333);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .cc-header {
  background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
}

[data-theme="dark"] .cc-msg--ai .cc-msg__bubble {
  background: var(--bg-tertiary, #2a2a2a);
  color: var(--text-primary, #e5e7eb);
}

[data-theme="dark"] .cc-msg__time {
  color: var(--text-muted, #6b7280);
}

[data-theme="dark"] .cc-typing {
  background: var(--bg-tertiary, #2a2a2a);
}

[data-theme="dark"] .cc-typing__dot {
  background: var(--text-muted, #6b7280);
}

[data-theme="dark"] .cc-crisis {
  background: #3b1111;
  border-color: #7f1d1d;
  color: #fca5a5;
}

[data-theme="dark"] .cc-crisis a {
  color: #fca5a5;
}

[data-theme="dark"] .cc-chip {
  background: var(--bg-tertiary, #2a2a2a);
  border-color: var(--border-color, #333);
  color: var(--text-secondary, #9ca3af);
}

[data-theme="dark"] .cc-chip:hover {
  background: var(--bg-secondary, #333);
}

[data-theme="dark"] .cc-input {
  border-top-color: var(--border-color, #333);
}

[data-theme="dark"] .cc-input__field {
  background: var(--bg-tertiary, #2a2a2a);
  border-color: var(--border-color, #333);
  color: var(--text-primary, #e5e7eb);
}

[data-theme="dark"] .cc-input__field::placeholder {
  color: var(--text-muted, #6b7280);
}

[data-theme="dark"] .cc-disclaimer {
  color: var(--text-muted, #6b7280);
}

[data-theme="dark"] .cc-messages::-webkit-scrollbar-thumb {
  background: var(--border-color, #444);
}

@media (prefers-reduced-motion: reduce) {
  .cc-trigger.has-pulse {
    animation: none;
  }

  .cc-panel {
    transition: opacity 0.1s ease;
    transform: none !important;
  }

  .cc-panel.is-open {
    transform: none !important;
  }

  .cc-typing__dot {
    animation: none;
  }
}

[data-reduced-motion="true"] .cc-trigger.has-pulse {
  animation: none;
}

[data-reduced-motion="true"] .cc-panel {
  transition: opacity 0.1s ease;
}

[data-reduced-motion="true"] .cc-typing__dot {
  animation: none;
}

.cc-trigger:focus-visible,
.cc-header__close:focus-visible,
.cc-chip:focus-visible,
.cc-input__send:focus-visible {
  outline: 2px solid var(--user-accent, #f2c200);
  outline-offset: 2px;
}

.cc-input__field:focus-visible {
  border-color: var(--user-accent, #f2c200);
  box-shadow: 0 0 0 3px rgba(242, 194, 0, 0.2);
}

[data-high-contrast="true"] .cc-msg--ai .cc-msg__bubble {
  border: 2px solid #000;
}

[data-high-contrast="true"] .cc-chip {
  border: 2px solid #000;
}

[data-dyslexia-font="true"] .cc-msg__bubble,
[data-dyslexia-font="true"] .cc-input__field,
[data-dyslexia-font="true"] .cc-chip {
  font-family: 'OpenDyslexic', sans-serif;
}
