/* ============================================================
   Competitive Research Widget — competitive-research.css
   Chat-style widget for portfolio.html
   ============================================================ */

/* === CONTAINER ============================================= */
.crw-container {
  max-width: 720px;
  margin: 0 auto;
}

/* === INTRO CARD ============================================ */
.crw-intro {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 2rem;
}

/* === CHAT AREA ============================================= */
.crw-chat {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* === BUBBLES =============================================== */
.crw-bubble {
  max-width: 85%;
  font-size: 0.95rem;
  line-height: 1.6;
  animation: crw-fade-in 0.25s ease;
}

@keyframes crw-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.crw-bubble.bot {
  align-self: flex-start;
  background: #EFEFEB;
  padding: 12px 16px;
  border-radius: 18px 18px 18px 6px;
  color: var(--text);
}

.crw-bubble.user {
  align-self: flex-end;
  background: #3D6BB5;
  color: #fff;
  padding: 12px 16px;
  border-radius: 18px 18px 6px 18px;
}

/* === INPUT ROW ============================================= */
.crw-input-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.crw-input {
  flex: 1;
  min-width: 180px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-white);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}
.crw-input:focus {
  border-color: var(--accent);
}
.crw-input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

/* === BUTTON ================================================ */
.crw-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.75rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}
.crw-button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}
.crw-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* === NAICS AUTOCOMPLETE ==================================== */
.crw-naics-wrap {
  position: relative;
  flex: 1;
  min-width: 180px;
}

.crw-naics-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 280px;
  overflow: auto;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 6px;
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  margin-top: 4px;
}

.crw-naics-item {
  padding: 0.6rem 0.9rem;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition);
}
.crw-naics-item:hover,
.crw-naics-item.active {
  background: #f5f5f5;
}

.crw-naics-category {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.5rem 0.9rem 0.25rem;
  background: #F8F7F5;
  position: sticky;
  top: 0;
}

/* === RADIUS SLIDER ========================================= */
.crw-radius-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.25rem;
}

.crw-radius-slider {
  flex: 1;
  accent-color: #3D6BB5;
  cursor: pointer;
}

.crw-radius-value {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  min-width: 5ch;
  text-align: right;
}

/* === RESULTS =============================================== */
.crw-results {
  margin-top: 2rem;
}

/* === COMPETITOR CARDS ====================================== */
.crw-competitor-card {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: var(--bg-white);
}

.crw-competitor-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.crw-competitor-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.crw-competitor-rating {
  font-size: 0.85rem;
  color: var(--accent);
  margin-top: 0.15rem;
}

/* === ANALYSIS (Markdown) =================================== */
.crw-analysis {
  margin-top: 1.5rem;
  line-height: 1.7;
}

.crw-analysis h1 {
  font-size: 1.5rem;
  margin: 1.5rem 0 0.75rem;
}
.crw-analysis h2 {
  font-size: 1.25rem;
  margin: 1.25rem 0 0.6rem;
}
.crw-analysis h3 {
  font-size: 1.1rem;
  margin: 1rem 0 0.5rem;
}

.crw-analysis p {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-muted);
  max-width: none;
  margin-bottom: 0.75rem;
}

.crw-analysis ul {
  list-style: disc;
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
}
.crw-analysis ul li {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.crw-analysis ol {
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
}
.crw-analysis ol li {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.crw-analysis strong {
  font-weight: 500;
  color: var(--text);
}

.crw-analysis blockquote {
  border-left: 3px solid #3D6BB5;
  font-style: italic;
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  color: var(--text-muted);
}

.crw-analysis table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border-light);
  margin: 1rem 0;
}
.crw-analysis th,
.crw-analysis td {
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border-light);
  font-size: 0.9rem;
  text-align: left;
}
.crw-analysis th {
  background: var(--bg-alt);
  font-weight: 500;
  color: var(--text);
}
.crw-analysis td {
  color: var(--text-muted);
}

/* === CTA =================================================== */
.crw-cta {
  text-align: center;
  margin-top: 2.5rem;
}
.crw-cta p {
  max-width: none;
  margin-bottom: 1rem;
}

/* === LOADING =============================================== */
.crw-loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 12px 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.crw-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: crw-spin 0.7s linear infinite;
}

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

/* === ERROR ================================================= */
.crw-error {
  color: #DC2626;
  padding: 1rem;
  background: #FEF2F2;
  border-left: 3px solid #DC2626;
  border-radius: 4px;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* === EMAIL FORM ============================================ */
.crw-email-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* === RESPONSIVE ============================================ */
@media (max-width: 640px) {
  .crw-bubble {
    max-width: 95%;
  }
  .crw-input-row {
    flex-direction: column;
  }
  .crw-input {
    min-width: 0;
  }
  .crw-radius-row {
    flex-direction: column;
    align-items: stretch;
  }
  .crw-radius-value {
    text-align: left;
  }
  .crw-competitor-card {
    padding: 0.75rem;
  }
}
