/* MyFloridaIQ — Florida blue/orange theme */

:root {
  --bg:            #f3f6f9;
  --bg-card:       #ffffff;
  --bg-user-msg:   #003087;
  --text:          #111827;
  --text-muted:    #6b7280;
  --text-light:    #9ca3af;
  --accent:        #003087;
  --accent-hover:  #002070;
  --accent-light:  rgba(0, 48, 135, 0.07);
  --orange:        #F47B20;
  --orange-soft:   rgba(244, 123, 32, 0.1);
  --border:        rgba(0, 48, 135, 0.09);
  --border2:       rgba(0, 48, 135, 0.15);
  --shadow:        0 2px 16px rgba(0, 48, 135, 0.07);
  --shadow-lg:     0 8px 32px rgba(0, 48, 135, 0.10);
  --radius:        16px;
  --radius-sm:     10px;
  --font:          'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display:  'Lora', Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

/* ─── APP WRAPPER ─────────────────────────────────────────── */
.fiq-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── HEADER ──────────────────────────────────────────────── */
.fiq-header {
  background: var(--accent);
  border-bottom: 3px solid var(--orange);
  padding: 0.9rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

.fiq-header__inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.fiq-logo-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.fiq-logo__seal {
  flex-shrink: 0;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.25));
}

.fiq-logo__name {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.fiq-logo__tagline {
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-top: 1px;
}

.fiq-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.65rem;
  background: var(--orange-soft);
  border: 1px solid rgba(244, 123, 32, 0.35);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--orange);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ─── MAIN ────────────────────────────────────────────────── */
.fiq-main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 1.25rem 1rem 1rem;
}

.fiq-chat {
  width: 100%;
  max-width: 760px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 66vh;
}

.fiq-chat__shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.fiq-chat__center {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  scroll-behavior: smooth;
}

/* ─── TOPIC TREE (initial full view) ─────────────────────── */
.fiq-topics {
  padding-bottom: 0.25rem;
}

.fiq-topics__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}

.fiq-topics.is-hidden { display: none; }

/* 2-column grid of topic buttons */
.fiq-tree {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

.fiq-tree__btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.7rem;
  font-family: var(--font);
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  border: 1.5px solid var(--border2);
  border-radius: 9px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fiq-tree__btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.fiq-tree__btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,48,135,0.2);
}

.fiq-tree__btn-icon { font-size: 0.95rem; flex-shrink: 0; }
.fiq-tree__btn-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }

/* Question panel that spans full width below grid */
.fiq-tree__panel {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  padding: 0.1rem 0 0.1rem;
  animation: fiq-fade-in 0.18s ease;
}

.fiq-tree__q {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  line-height: 1.35;
  transition: all 0.15s ease;
}

.fiq-tree__q::before {
  content: '›';
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
  font-size: 1rem;
}

.fiq-tree__q:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── INLINE TOPICS (mid-conversation compact bar) ────────── */
.fiq-inline-topics {
  margin: -0.5rem 0 1.15rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
}

.fiq-inline-topics__toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.45rem 0.7rem;
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s, background 0.15s;
}

.fiq-inline-topics__toggle:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.fiq-inline-topics__toggle-icon { font-size: 0.85rem; }
.fiq-inline-topics__toggle-label { flex: 1; }

.fiq-inline-topics__chevron {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 0.8rem;
  opacity: 0.5;
}

.fiq-inline-topics__chevron.is-open {
  transform: rotate(90deg);
}

.fiq-inline-topics__body {
  display: none;
  padding: 0 0.6rem 0.6rem;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

.fiq-inline-topics__body.is-open { display: block; }

/* Same 2-col grid inside the inline body */
.fiq-inline-tree {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.28rem;
  padding-top: 0.5rem;
}

.fiq-inline-tree__btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.55rem;
  font-family: var(--font);
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px solid var(--border2);
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: all 0.15s;
}

.fiq-inline-tree__btn:hover,
.fiq-inline-tree__btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.fiq-inline-tree__panel {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  padding-top: 0.3rem;
  animation: fiq-fade-in 0.18s ease;
}

.fiq-inline-tree__q {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.65rem;
  font-family: var(--font);
  font-size: 0.8rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
  line-height: 1.3;
  transition: all 0.15s;
}

.fiq-inline-tree__q::before {
  content: '›';
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
}

.fiq-inline-tree__q:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── HERO ────────────────────────────────────────────────── */
.fiq-hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  text-align: center;
}

.fiq-hero__inner {
  max-width: 32ch;
}

.fiq-hero__text {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 500;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.55;
}

.fiq-hero.is-hidden { display: none; }

/* ─── MESSAGES ────────────────────────────────────────────── */
.fiq-messages {
  flex: 1;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.fiq-msg {
  margin-bottom: 1.15rem;
  animation: fiq-fade-in 0.28s ease;
}

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

.fiq-msg__wrap {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.fiq-msg--user .fiq-msg__wrap {
  justify-content: flex-end;
}

.fiq-msg__body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-width: 88%;
  min-width: 0;
}

.fiq-msg--user .fiq-msg__body {
  align-items: flex-end;
}

.fiq-msg__bubble {
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.93rem;
  line-height: 1.5;
  word-break: break-word;
}

.fiq-msg--assistant .fiq-msg__bubble {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
}

.fiq-msg--user .fiq-msg__bubble {
  background: var(--bg-user-msg);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm) 2px var(--radius-sm) var(--radius-sm);
}

/* ─── REPLY CONTENT FORMATTING ───────────────────────────── */
.fiq-reply {
  font-size: 0.93rem;
  line-height: 1.6;
  color: var(--text);
}

.fiq-reply h2 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 0.6rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--orange-soft);
}

.fiq-reply h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin: 0.75rem 0 0.3rem;
}

.fiq-reply p {
  margin: 0 0 0.5rem;
}

.fiq-reply p:last-child { margin-bottom: 0; }

.fiq-reply ul,
.fiq-reply ol {
  margin: 0.35rem 0 0.5rem;
  padding-left: 1.3rem;
}

.fiq-reply li {
  margin: 0.2rem 0;
}

.fiq-reply strong {
  font-weight: 600;
  color: var(--text);
}

.fiq-reply em {
  font-style: italic;
}

.fiq-reply a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(0,48,135,0.3);
  text-underline-offset: 2px;
  transition: color 0.15s;
}

.fiq-reply a:hover {
  color: var(--orange);
  text-decoration-color: var(--orange);
}

/* ─── SOURCES ─────────────────────────────────────────────── */
.fiq-sources {
  margin-top: 0.6rem;
}

.fiq-sources__label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.fiq-sources__list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.fiq-source-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  background: var(--accent-light);
  border: 1px solid var(--border2);
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  transition: all 0.15s ease;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fiq-source-link:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.fiq-source-link__icon {
  flex-shrink: 0;
  width: 11px;
  height: 11px;
  opacity: 0.6;
}

.fiq-source-link:hover .fiq-source-link__icon {
  opacity: 1;
}

/* ─── TYPING INDICATOR ────────────────────────────────────── */
.fiq-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 2px;
  height: 22px;
}

.fiq-typing__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: fiq-bounce 1.3s ease-in-out infinite both;
}

.fiq-typing__dot:nth-child(1) { animation-delay: -0.32s; }
.fiq-typing__dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes fiq-bounce {
  0%, 80%, 100% { transform: scale(0.55); opacity: 0.5; }
  40%           { transform: scale(1.0);  opacity: 1.0; }
}

/* ─── LOADING STATE ───────────────────────────────────────── */
.fiq-loading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.fiq-loading__spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: fiq-spin 0.75s linear infinite;
  flex-shrink: 0;
}

.fiq-loading__text {
  font-size: 0.88rem;
  color: var(--text-muted);
}

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

/* Searching web indicator pulse */
.fiq-loading__spinner--search {
  border-top-color: var(--orange);
}

/* ─── COMPOSER ────────────────────────────────────────────── */
.fiq-composer {
  padding: 0.85rem 1.5rem 1.1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

.fiq-form {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.fiq-inputwrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.45rem 0.45rem 0.4rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.fiq-inputwrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.fiq-input {
  flex: 1;
  min-height: 36px;
  max-height: 120px;
  padding: 0.4rem 0.25rem;
  font-family: var(--font);
  font-size: 0.93rem;
  line-height: 1.45;
  color: var(--text);
  background: transparent;
  border: none;
  resize: none;
  outline: none;
}

.fiq-input::placeholder {
  color: var(--text-light);
}

.fiq-send {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.18s, transform 0.1s;
}

.fiq-send:hover {
  background: var(--accent-hover);
  transform: scale(1.04);
}

.fiq-send:active {
  transform: scale(0.97);
}

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

.fiq-send svg {
  width: 18px;
  height: 18px;
}

.fiq-topics-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  padding: 0;
}

.fiq-topics-btn:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.fiq-topics-btn svg {
  width: 17px;
  height: 17px;
}

.fiq-disclaimer {
  font-size: 0.7rem;
  color: var(--text-light);
  text-align: center;
  line-height: 1.4;
}

/* ─── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .fiq-header {
    padding: 0.7rem 1rem;
  }

  .fiq-logo__name {
    font-size: 1.1rem;
  }

  .fiq-logo__tagline {
    display: none;
  }

  .fiq-main {
    padding: 0.35rem 0;
  }

  .fiq-chat {
    border-radius: 0;
    min-height: unset;
    border-left: none;
    border-right: none;
  }

  .fiq-chat__center {
    padding: 0.85rem 0.85rem 0;
    gap: 0.85rem;
  }

  /* Spacer fills the height of the fixed composer so the last message is never hidden */
  .fiq-spacer {
    flex-shrink: 0;
    height: calc(5.5rem + env(safe-area-inset-bottom));
  }

  .fiq-topics__chips {
    gap: 0.35rem;
  }

  .fiq-chip {
    font-size: 0.8rem;
    padding: 0.35rem 0.7rem;
  }

  .fiq-msg__body {
    max-width: 94%;
  }

  .fiq-composer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 14;
    padding: 0.6rem 0.85rem calc(0.85rem + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 18px rgba(0, 48, 135, 0.08);
  }
}
