/* ==========================================================================
   TOC + Chat Widget Styles
   Matches template-chat-partner.php design
   ========================================================================== */

/* Resources list styles */
.otslr-resources-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.otslr-resources-list li {
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.otslr-resources-list a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #363C33;
  text-decoration: none;
  font-family: 'TT Commons Pro', system-ui, sans-serif;
  font-weight: 500;
  transition: color 0.2s ease;
}

.otslr-resources-list a:hover {
  color: #74806D;
}

/* Resource icons */
.otslr-resource-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  transition: color 0.2s ease;
}

.otslr-resource-icon--pdf {
  color: #D26B5E; /* Coral color for PDFs */
}

.otslr-resource-icon--video {
  color: #74806D; /* Alt green for videos */
}

.otslr-resources-list li:hover .otslr-resource-icon--pdf {
  color: #b85a4f;
}

.otslr-resources-list li:hover .otslr-resource-icon--video {
  color: #363C33;
}

.otslr-download-icon {
  flex-shrink: 0;
  color: #74806D;
}

.otslr-resources-list a:hover .otslr-download-icon {
  color: #363C33;
}

/* ==========================================================================
   Chat Widget - Partner For Care Branded
   ========================================================================== */

.otslr-chat-widget {
  --pfc-prime: #363C33;
  --pfc-alt-new: #74806D;
  --pfc-light-green: #9ecc8b;
  --pfc-white: #ffffff;
  --pfc-white-alt: #F2F4F1;
  --pfc-grey-light: #e5e5e5;
  --pfc-grey-medium: #9ca3af;
  --pfc-black-text: #121212;
  --pfc-border-radius: 12px;
  --pfc-border-radius-lg: 16px;
  --pfc-header-font: 'Aeonik', system-ui, sans-serif;
  --pfc-body-font: 'TT Commons Pro', system-ui, sans-serif;
}

/* --------------------------------------------------------------------------
   Thread Container
   -------------------------------------------------------------------------- */
.otslr-chat-widget .otslr-chat-thread {
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 1rem;
  scrollbar-width: thin;
  background: 
    radial-gradient(circle at 20% 80%, rgba(158, 204, 139, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(116, 128, 109, 0.08) 0%, transparent 50%);
}

.otslr-chat-widget .otslr-chat-thread::-webkit-scrollbar { 
  width: 6px; 
}

.otslr-chat-widget .otslr-chat-thread::-webkit-scrollbar-thumb { 
  background: var(--pfc-grey-light); 
  border-radius: 3px;
}

.otslr-chat-widget .otslr-chat-thread::-webkit-scrollbar-thumb:hover { 
  background: var(--pfc-grey-medium);
}

/* --------------------------------------------------------------------------
   Message Rows - matches .pfc-message from template-chat-partner.php
   -------------------------------------------------------------------------- */
.otslr-chat-widget .otslr-chat-row { 
  display: flex;
  margin-bottom: 1.5rem;
  align-items: flex-start;
  gap: 0.75rem;
}

.otslr-chat-widget .otslr-chat-row.user { 
  flex-direction: row-reverse;
}

/* --------------------------------------------------------------------------
   Avatar - matches .pfc-message-avatar from template-chat-partner.php
   -------------------------------------------------------------------------- */
.otslr-chat-widget .otslr-chat-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 600;
  font-family: var(--pfc-header-font);
  flex-shrink: 0;
  text-transform: uppercase;
}

.otslr-chat-widget .otslr-chat-row.user .otslr-chat-avatar {
  background: var(--pfc-light-green);
  color: var(--pfc-prime);
}

.otslr-chat-widget .otslr-chat-row.assistant .otslr-chat-avatar {
  background: var(--pfc-alt-new);
  color: var(--pfc-white);
}

/* --------------------------------------------------------------------------
   Message Bubble - matches .pfc-message-content from template-chat-partner.php
   -------------------------------------------------------------------------- */
.otslr-chat-widget .otslr-chat-bubble {
  max-width: 70%;
  padding: 1rem 1.25rem;
  border-radius: var(--pfc-border-radius-lg);
  line-height: 1.5;
  position: relative;
  font-family: var(--pfc-body-font);
  font-weight: 500;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: otslr-chat-pop 0.2s ease-out;
}

/* User bubble - light green with tail on bottom-right */
.otslr-chat-widget .otslr-chat-row.user .otslr-chat-bubble {
  background: var(--pfc-light-green);
  color: var(--pfc-black-text);
  border-bottom-right-radius: 0.25rem;
}

/* Assistant bubble - white with border, tail on bottom-left */
.otslr-chat-widget .otslr-chat-row.assistant .otslr-chat-bubble {
  background: var(--pfc-white);
  color: var(--pfc-black-text);
  border: 1px solid var(--pfc-grey-light);
  border-bottom-left-radius: 0.25rem;
}

/* Enhanced formatting for assistant responses */
.otslr-chat-widget .otslr-chat-row.assistant .otslr-chat-bubble p {
  margin: 0 0 0.75rem 0;
}

.otslr-chat-widget .otslr-chat-row.assistant .otslr-chat-bubble p:last-child {
  margin-bottom: 0;
}

.otslr-chat-widget .otslr-chat-row.assistant .otslr-chat-bubble strong {
  font-weight: 600;
  color: var(--pfc-alt-new);
}

.otslr-chat-widget .otslr-chat-row.assistant .otslr-chat-bubble em {
  font-style: italic;
  color: var(--pfc-grey-medium);
}

/* Error styling */
.otslr-chat-widget .otslr-chat-bubble.is-error { 
  background: #ffe4e6;
  color: #7f1d1d;
  border: 1px solid #fecaca;
  align-self: center;
  max-width: 90%;
}

/* --------------------------------------------------------------------------
   Typing/Thinking Indicator - matches .pfc-typing from template-chat-partner.php
   -------------------------------------------------------------------------- */
.otslr-chat-widget .otslr-chat-row.assistant.ghost .otslr-chat-bubble {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  background: var(--pfc-white);
  border: 1px solid var(--pfc-grey-light);
  border-radius: var(--pfc-border-radius-lg);
  border-bottom-left-radius: 0.25rem;
  max-width: 70%;
}

/* "Thinking" text label */
.otslr-chat-widget .thinking-text {
  font-family: var(--pfc-body-font);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--pfc-alt-new);
}

/* Dot container - matches .pfc-typing-dots */
.otslr-chat-widget .otslr-typing-dots {
  display: flex;
  gap: 0.25rem;
}

.otslr-chat-widget .dot {
  width: 0.5rem;
  height: 0.5rem;
  background: var(--pfc-alt-new);
  border-radius: 50%;
  animation: otslr-chat-typing 1.4s infinite ease-in-out;
}

.otslr-chat-widget .dot:nth-child(2) { 
  animation-delay: 0.2s; 
}

.otslr-chat-widget .dot:nth-child(3) { 
  animation-delay: 0.4s; 
}

@keyframes otslr-chat-typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-0.5rem);
    opacity: 1;
  }
}

@keyframes otslr-chat-pop { 
  from { 
    transform: scale(0.95); 
    opacity: 0;
  } 
  to { 
    transform: scale(1); 
    opacity: 1;
  } 
}

/* --------------------------------------------------------------------------
   Composer/Input Area - matches .pfc-input-form from template-chat-partner.php
   -------------------------------------------------------------------------- */
.otslr-chat-widget .otslr-chat-composer { 
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  padding: 0.75rem;
  margin: 1rem;
  margin-top: 0;
  background: var(--pfc-white);
  border: 1px solid var(--pfc-grey-light);
  border-radius: var(--pfc-border-radius-lg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.otslr-chat-widget .otslr-chat-composer:focus-within {
  border-color: var(--pfc-alt-new);
  box-shadow: 0 0 0 3px rgba(116, 128, 109, 0.1);
}

/* Input field - matches .pfc-message-input */
.otslr-chat-widget #otslr-chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: var(--pfc-body-font);
  font-size: 1rem;
  line-height: 1.5;
  padding: 0.25rem 0;
  color: var(--pfc-black-text);
}

.otslr-chat-widget #otslr-chat-input::placeholder {
  color: var(--pfc-grey-medium);
}

/* --------------------------------------------------------------------------
   Send Button - matches .pfc-send-button from template-chat-partner.php
   -------------------------------------------------------------------------- */
.otslr-chat-widget #otslr-chat-send {
  background: var(--pfc-alt-new);
  color: var(--pfc-white);
  border: none;
  border-radius: var(--pfc-border-radius);
  padding: 0.5rem 1rem;
  min-width: 2.5rem;
  height: 2.5rem;
  font-weight: 600;
  font-family: var(--pfc-body-font);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.otslr-chat-widget #otslr-chat-send:hover:not(:disabled) { 
  background: var(--pfc-prime);
  transform: translateY(-1px);
}

.otslr-chat-widget #otslr-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.otslr-chat-widget #otslr-chat-send:active {
  transform: translateY(0);
}

.otslr-chat-widget .otslr-btn.is-busy { 
  opacity: 0.7;
  cursor: progress;
}

/* --------------------------------------------------------------------------
   Mobile Responsiveness
   -------------------------------------------------------------------------- */
@media (max-width: 560px) { 
  .otslr-chat-widget .otslr-chat-bubble { 
    max-width: 85%;
  }
  
  .otslr-chat-widget .otslr-chat-row.assistant.ghost .otslr-chat-bubble {
    max-width: 85%;
  }
}
