/**
 * Coparent Coach — Chat Widget Styles
 * Brand: Coparent Academy
 * Primary: #ef6243 (warm coral-orange)
 * Supporting palette: warm neutrals, soft blues for trust
 */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,600;1,400&family=Source+Sans+3:wght@300;400;500;600&display=swap');

/* ── CSS Variables ── */
#cpc-chat-container {
  --cpc-primary:       #ef6243;
  --cpc-primary-dark:  #d44f32;
  --cpc-primary-light: #fdf0ec;
  --cpc-accent:        #2a7f62;   /* calm green — trust, growth */
  --cpc-accent-light:  #e8f5f1;
  --cpc-text:          #2c2c2c;
  --cpc-text-muted:    #767676;
  --cpc-bg:            #faf9f7;
  --cpc-surface:       #ffffff;
  --cpc-border:        #e8e4df;
  --cpc-shadow:        0 4px 24px rgba(0,0,0,0.09);
  --cpc-shadow-sm:     0 2px 8px rgba(0,0,0,0.06);
  --cpc-radius:        16px;
  --cpc-radius-sm:     8px;
  --cpc-font-body:     'Source Sans 3', sans-serif;
  --cpc-font-display:  'Lora', Georgia, serif;
  --cpc-transition:    0.2s ease;
}

/* ── Container ── */
#cpc-chat-container {
  font-family: var(--cpc-font-body);
  font-size: 15px;
  color: var(--cpc-text);
  background: var(--cpc-bg);
  border: 1px solid var(--cpc-border);
  border-radius: var(--cpc-radius);
  box-shadow: var(--cpc-shadow);
  display: flex;
  flex-direction: column;
  max-width: 720px;
  width: 100%;
  height: 640px;
  margin: 0 auto;
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
}

*, *::before, *::after {
  box-sizing: inherit;
}

/* ── Header ── */
#cpc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: linear-gradient(135deg, #2c1a12 0%, #3d2518 100%);
  flex-shrink: 0;
}

#cpc-logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

#cpc-logo-icon {
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.3));
}

#cpc-title {
  font-family: var(--cpc-font-display);
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

#cpc-subtitle {
  font-size: 11px;
  font-weight: 500;
  color: var(--cpc-primary);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 2px;
}

#cpc-status {
  display: flex;
  align-items: center;
  gap: 7px;
}

#cpc-status-text {
  font-size: 12px;
  color: rgba(255,255,255,0.65);
  font-weight: 400;
}

#cpc-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background var(--cpc-transition);
}

#cpc-status-dot.online   { background: #4ade80; box-shadow: 0 0 6px rgba(74,222,128,0.5); }
#cpc-status-dot.thinking { background: var(--cpc-primary); animation: cpc-pulse 1s ease-in-out infinite; }

@keyframes cpc-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Messages ── */
#cpc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

#cpc-messages::-webkit-scrollbar { width: 5px; }
#cpc-messages::-webkit-scrollbar-track { background: transparent; }
#cpc-messages::-webkit-scrollbar-thumb { background: var(--cpc-border); border-radius: 3px; }

/* ── Message rows ── */
.cpc-message {
  display: flex;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.cpc-message.cpc-visible {
  opacity: 1;
  transform: translateY(0);
}

.cpc-message.cpc-user {
  justify-content: flex-end;
}

.cpc-message.cpc-assistant,
.cpc-message.cpc-error {
  justify-content: flex-start;
}

/* ── Bubbles ── */
.cpc-bubble {
  max-width: 78%;
  padding: 13px 18px;
  border-radius: 18px;
  line-height: 1.65;
  font-size: 14.5px;
}

.cpc-user .cpc-bubble {
  background: var(--cpc-primary);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  font-weight: 400;
}

.cpc-assistant .cpc-bubble {
  background: var(--cpc-surface);
  color: var(--cpc-text);
  border: 1px solid var(--cpc-border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--cpc-shadow-sm);
}

.cpc-error .cpc-bubble {
  background: #fff5f5;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  border-radius: 12px;
  font-size: 13.5px;
}

/* ── Bubble typography ── */
.cpc-bubble p {
  margin: 0 0 10px;
}
.cpc-bubble p:last-child {
  margin-bottom: 0;
}

.cpc-bubble strong {
  font-weight: 600;
}

.cpc-assistant .cpc-bubble strong {
  color: var(--cpc-primary-dark);
}

.cpc-bubble em {
  font-style: italic;
  color: var(--cpc-text-muted);
  display: block;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--cpc-border);
  font-size: 13px;
  line-height: 1.5;
}

.cpc-user .cpc-bubble em {
  color: rgba(255,255,255,0.8);
  border-top-color: rgba(255,255,255,0.25);
}

.cpc-ol {
  margin: 8px 0 8px 0;
  padding-left: 22px;
}

.cpc-list-item {
  margin: 6px 0;
  line-height: 1.6;
}

/* ── Disclaimer ── */
.cpc-disclaimer {
  font-size: 11.5px !important;
  color: var(--cpc-text-muted) !important;
  margin-top: 12px !important;
  padding-top: 10px !important;
  border-top: 1px solid var(--cpc-border) !important;
  font-style: italic;
}

/* ── Typing dots ── */
.cpc-typing-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 2px 0;
}

.cpc-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cpc-primary);
  animation: cpc-bounce 1.2s ease-in-out infinite;
}

.cpc-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.cpc-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes cpc-bounce {
  0%, 80%, 100% { transform: translateY(0);   opacity: 0.5; }
  40%            { transform: translateY(-6px); opacity: 1;   }
}

/* ── Input area ── */
#cpc-input-area {
  padding: 12px 16px 0;
  background: var(--cpc-surface);
  border-top: 1px solid var(--cpc-border);
  flex-shrink: 0;
}

#cpc-input {
  width: 100%;
  border: 1.5px solid var(--cpc-border);
  border-radius: var(--cpc-radius-sm);
  padding: 11px 14px;
  font-family: var(--cpc-font-body);
  font-size: 14.5px;
  color: var(--cpc-text);
  background: var(--cpc-bg);
  resize: none;
  outline: none;
  transition: border-color var(--cpc-transition), box-shadow var(--cpc-transition);
  display: block;
  line-height: 1.55;
}

#cpc-input::placeholder {
  color: #b0aa9f;
  font-style: italic;
}

#cpc-input:focus {
  border-color: var(--cpc-primary);
  box-shadow: 0 0 0 3px rgba(239,98,67,0.12);
  background: #ffffff;
}

#cpc-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#cpc-input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 2px 12px;
}

#cpc-char-count {
  font-size: 11.5px;
  color: var(--cpc-text-muted);
}

#cpc-char-count.cpc-near-limit {
  color: #d97706;
  font-weight: 600;
}

#cpc-send-btn {
  background: var(--cpc-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--cpc-radius-sm);
  padding: 9px 22px;
  font-family: var(--cpc-font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--cpc-transition), transform var(--cpc-transition), box-shadow var(--cpc-transition);
  letter-spacing: 0.02em;
  min-width: 88px;
}

#cpc-send-btn:hover:not(:disabled) {
  background: var(--cpc-primary-dark);
  box-shadow: 0 3px 12px rgba(239,98,67,0.35);
  transform: translateY(-1px);
}

#cpc-send-btn:active:not(:disabled) {
  transform: translateY(0);
}

#cpc-send-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

#cpc-send-spinner {
  letter-spacing: 3px;
  animation: cpc-pulse 0.8s ease-in-out infinite;
}

/* ── Footer ── */
#cpc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 14px;
  background: var(--cpc-surface);
}

#cpc-reset-btn {
  background: none;
  border: 1px solid var(--cpc-border);
  border-radius: 20px;
  padding: 5px 14px;
  font-family: var(--cpc-font-body);
  font-size: 12px;
  color: var(--cpc-text-muted);
  cursor: pointer;
  transition: all var(--cpc-transition);
}

#cpc-reset-btn:hover {
  border-color: var(--cpc-primary);
  color: var(--cpc-primary);
  background: var(--cpc-primary-light);
}

#cpc-powered-by {
  font-size: 11.5px;
  color: var(--cpc-text-muted);
}

#cpc-powered-by a {
  color: var(--cpc-primary);
  text-decoration: none;
  font-weight: 500;
}

#cpc-powered-by a:hover {
  text-decoration: underline;
}

/* ── Shake animation (empty submit) ── */
@keyframes cpc-shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

.cpc-shake {
  animation: cpc-shake 0.4s ease;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  #cpc-chat-container {
    height: calc(100vh - 40px);
    border-radius: var(--cpc-radius-sm);
    font-size: 14px;
  }

  #cpc-header {
    padding: 14px 16px;
  }

  #cpc-title {
    font-size: 16px;
  }

  .cpc-bubble {
    max-width: 90%;
    font-size: 14px;
    padding: 11px 14px;
  }

  #cpc-messages {
    padding: 16px 12px;
    gap: 12px;
  }

  #cpc-input-area {
    padding: 10px 12px 0;
  }

  #cpc-footer {
    padding: 8px 12px 12px;
  }
}

/* ── Dark mode support ── */
@media (prefers-color-scheme: dark) {
  #cpc-chat-container {
    --cpc-bg:      #1e1a17;
    --cpc-surface: #262119;
    --cpc-border:  #3a342c;
    --cpc-text:    #e8e2db;
    --cpc-text-muted: #9b9189;
    --cpc-primary-light: #2d1f19;
  }

  .cpc-assistant .cpc-bubble {
    box-shadow: none;
  }

  #cpc-input {
    color: var(--cpc-text);
  }

  #cpc-input::placeholder {
    color: #6b6158;
  }
}
