/* Chat modal styles - follows existing modal patterns from about.css */

/* Modal overlay with semi-transparent background (matches services modal) */


.chat-modal-overlay {
  align-items: center;
  justify-content: center;
}

/* Modal dialog container */

.chat-modal {
  display: flex;
  flex-direction: column;
  padding: 0;
  min-height: 75vh;
  max-height: 85vh;
}

/* Header */
.chat-header {
  padding: 16px 20px 8px;
}

.chat-header-icon {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-header-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.chat-header .hero-header__text {
  align-items: flex-start;
  text-align: left;
}

.chat-title {
  font-size: 2em;
  font-weight: 600;
  color: var(--primary);
  margin: 0;
}

.chat-subtitle {
  margin: 0.25em 0 0;
  color: var(--accent);
  font-size: 1.2em;
}

.chat-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 400;
  transition: all 0.2s ease;
}

.chat-close:hover {
  background: var(--accent);
  color: var(--bg);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.chat-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Context Section (collapsible wrapper) */
.chat-context-section {
  position: relative;
}

/* Context Toggle Button (hidden on desktop, shown on mobile) */
.chat-context-toggle {
  display: none;
}

/* Service Chips Bar */
.chat-chip-bar {
  padding: 12px 18px;
  display: flex;
  gap: 0.6em;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.service-chip {
  padding: 0.5em 1em;
  border-radius: 1em;
  border: 1px solid var(--secondary);
  background: transparent;
  color: var(--secondary);
  cursor: pointer;
  font-size: 1em;
  white-space: nowrap;
  transition: all 0.2s;
  font-family: inherit;
  position: relative;
  z-index: 1;
}

.service-chip:hover {
  background: var(--secondary);
  color: white;
  transform: translateY(-1px);
  z-index: 10000;
}

.service-chip.selected {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.service-chip:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85em;
  white-space: normal;
  width: 200px;
  z-index: 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  animation: tooltip-fade-in 0.2s ease 0.5s forwards;
  opacity: 0;
}

@keyframes tooltip-fade-in {
  to {
    opacity: 1;
  }
}

/* Modal Body */
.chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  overflow: hidden;
}

/* Context Pills Display */
.context-pills {
  padding: 8px 14px;
  display: flex;
  gap: 0.6em;
  flex-wrap: wrap;
  align-items: flex-start;
  font-size: 1em;
  margin-bottom: 16px;
}

.context-pills-label {
  color: var(--ink-muted);
  font-size: 1em;
}

#chat-context-pills {
  display: flex;
  gap: 0.6em;
  flex-wrap: wrap;
  align-items: flex-start;
}

.context-pill {
  padding: 0.5em 1em;
  border-radius: 1em;
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  font-size: 0.75em;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  cursor: pointer;
  transition: all 0.2s;
}

.context-pill:hover {
  opacity: 0.9;
}

.context-pill::after {
  content: "×";
  font-weight: bold;
  opacity: 0.6;
}

.context-pill:hover::after {
  opacity: 1;
}

/* Chat Window (scrollable area) */
.chat-window {
  flex: 1;
  background: var(--surface-variant);
  border: 1px solid var(--surface-variant);
  border-radius: 8px;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Modern Mac-style scrollbar */
.chat-window::-webkit-scrollbar {
  width: 8px;
}

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

.chat-window::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.chat-window::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
  background-clip: padding-box;
}

body.dark-mode .chat-window::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  background-clip: padding-box;
}

body.dark-mode .chat-window::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
  background-clip: padding-box;
}

/* Instructional Text (not a message bubble) */
.chat-instructions {
  color: var(--ink-muted);
  font-size: 1em;
  line-height: 1.6;
  padding: 16px;
  background: rgba(var(--primary-rgb), 0.05);
  border-radius: 8px;
  border: 1px solid rgba(var(--primary-rgb), 0.1);
}

.chat-instructions p {
  margin: 0 0 1em 0;
}

.chat-instructions p:last-child {
  margin-bottom: 0;
}

/* Chat Messages */
.chat-message {
  display: flex;
  margin-bottom: 12px;
}

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

.chat-message--bot {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 75%;
  padding: 14px 18px;
  border-radius: 18px;
  line-height: 1.6;
  font-size: 1em;
}

.chat-message--user .message-bubble {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message--bot .message-bubble {
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.6);
  color: rgba(0, 0, 0, 0.6);
  border-bottom-left-radius: 4px;
}

/* Citations */
.message-citations {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.citation-pill {
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 0.8em;
  border: 1px solid var(--secondary);
  color: var(--secondary);
  background: transparent;
  cursor: default;
}

/* Loading Indicator */
.chat-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-muted);
  font-style: italic;
  padding: 14px 18px;
}

.chat-loading::before {
  content: "⋯";
  font-size: 1.5em;
  animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
  0%, 20% { opacity: 0.2; }
  40% { opacity: 1; }
  100% { opacity: 0.2; }
}

/* Input Footer */
.chat-footer {
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.chat-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--ink-muted);
  border-radius: 28px;
  font-size: 1em;
  font-family: inherit;
  transition: all 0.2s;
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.1);
}

.chat-input::placeholder {
  color: var(--ink-muted);
}

.chat-send {
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: var(--bg);
  cursor: pointer;
  font-weight: 700;
  font-size: 1.2em;
  font-family: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.chat-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--shadow);
}

.chat-send:active {
  transform: translateY(0);
}

.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Floating Chat Button */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  z-index: 9998;
}

.chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.chat-fab:active {
  transform: scale(1.05);
}

/* Hidden state */
.hidden {
  display: none !important;
}

/* Tablet Responsive */
@media (max-width: 1024px) {
  .chat-modal {
    min-height: 75vh;
    max-height: 90vh;
  }

  .chat-title {
    font-size: 1.8em;
  }
}

/* Mobile Responsive */
@media (max-width: 767px) {
  .chat-modal-overlay {
    padding: 1rem;
  }

  .chat-modal {
    font-size: 1em;
    min-height: auto;
    max-height: 95vh;
  }

  .chat-header {
    padding: 12px 16px 8px;
  }

  .chat-title {
    font-size: 1.5em;
    text-align: left;
  }

  /* Show collapsible toggle button on mobile */
  .chat-context-section {
    margin-top: -4px;
  }

  .chat-context-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 90%;
    margin: 0 auto;
    padding: 10px 14px;
    background: var(--surface-variant);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--ink);
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
  }

  .chat-context-toggle:hover {
    background: var(--surface);
  }

  .chat-context-toggle-icon {
    transition: transform 0.2s;
    font-size: 0.8em;
  }

  .chat-context-toggle[aria-expanded="true"] .chat-context-toggle-icon {
    transform: rotate(180deg);
  }

  /* Chip bar starts collapsed on mobile */
  .chat-chip-bar--collapsible {
    max-height: 0;
    overflow: hidden;
    padding: 0 16px;
    transition: max-height 0.3s ease, padding 0.3s ease;
  }

  .chat-chip-bar--collapsible.chat-chip-bar--expanded {
    max-height: 500px;
    padding: 12px 16px;
  }

  .service-chip {
    font-size: 0.9em;
    padding: 0.4em 0.8em;
  }

  .chat-body {
    padding: 16px;
  }

  .context-pills {
    padding: 6px 10px;
    margin-bottom: 8px;
    gap: 0.4em;
  }

  .context-pills-label {
    font-size: 0.85em;
  }

  .context-pill {
    font-size: 0.7em;
    padding: 0.35em 0.7em;
    gap: 0.3em;
  }

  .chat-footer {
    padding: 16px;
  }

  .chat-close {
    width: 32px;
    height: 32px;
    font-size: 18px;
  }
}

/* Mobile Landscape - Override to horizontal layout */
@media (max-width: 767px) and (orientation: landscape) {
  .chat-header {
    flex-direction: row;
    align-items: flex-start;
  }

  .chat-title {
    text-align: left;
  }
}
