/* ==========================================================================
   AI assistant page (ai.html)
   ========================================================================== */

/* From 1200px the chat and history fill the viewport under the 72px topbar
   and scroll internally; below that the page scrolls normally. */
@media (min-width: 1200px) {
  .ai-shell {
    height: calc(100dvh - 72px - 64px);
    min-height: 600px;
  }
  .ai-chat,
  .ai-history {
    min-height: 0;
  }
}
@media (max-width: 1199.98px) {
  .ai-chat {
    min-height: calc(100dvh - 72px - 40px);
  }
}

/* mode dropdown */
.ai-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  width: 240px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition:
    opacity 0.15s,
    transform 0.15s,
    visibility 0.15s;
}
.ai-menu.open {
  opacity: 1;
  visibility: visible;
  transform: none;
}
.ai-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border-radius: 10px;
}
.ai-menu button:hover {
  background: #f4f6f8;
}
.ai-menu b {
  display: block;
  font-size: 14px;
  font-weight: 600;
}
.ai-menu span {
  display: block;
  font-size: 12.5px;
  color: var(--mut);
}

/* suggestion cards */
.ai-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  border-radius: 20px;
  padding: 24px;
  min-height: 200px;
  transition:
    transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.2s;
}
.ai-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 30px -18px rgba(16, 24, 40, 0.3);
}
.ai-card--amber {
  background: #fff4e5;
}
.ai-card--violet {
  background: #f4ebfd;
}
.ai-card--green {
  background: #e3f8ea;
}
.ai-card-title {
  font-family: "Inter Tight", "Inter", sans-serif;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.ai-card-text {
  margin-top: 10px;
  font-size: 14.5px;
  line-height: 1.5;
  color: #3e4652;
}
.ai-card-ic {
  margin-top: auto;
  padding-top: 0;
  display: grid;
  place-items: center;
  height: 40px;
  width: 40px;
  border-radius: 12px;
  color: #fff;
}
.ai-card-text + .ai-card-ic {
  margin-top: 28px;
}
@media (min-width: 768px) {
  .ai-card {
    min-height: 260px;
  }
  .ai-card-text + .ai-card-ic {
    margin-top: auto;
  }
}

/* composer */
.ai-input {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 8px 0 10px;
  border-radius: 9999px;
  background: #f4f6f8;
  border: 1px solid transparent;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.ai-input:focus-within {
  background: #fff;
  border-color: #d0d6df;
}
.ai-input-dot {
  display: grid;
  place-items: center;
  height: 30px;
  width: 30px;
  border-radius: 9999px;
  background: var(--ink);
  color: #fff;
  flex: none;
}
.ai-send {
  display: grid;
  place-items: center;
  height: 42px;
  width: 42px;
  border-radius: 9999px;
  background: #2563eb;
  color: #fff;
  flex: none;
  transition:
    background 0.15s,
    transform 0.15s;
}
.ai-send:hover {
  background: #1d4ed8;
}
.ai-send:active {
  transform: scale(0.94);
}

/* messages */
.ai-bubble {
  max-width: min(640px, 88%);
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.55;
}
.ai-bubble--user {
  background: var(--ink);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.ai-bubble--bot {
  background: #f6f7f9;
  color: var(--ink);
  border-top-left-radius: 6px;
}
.ai-avatar {
  flex: none;
  display: grid;
  place-items: center;
  height: 32px;
  width: 32px;
  border-radius: 9999px;
  background: var(--ink);
  color: #fff;
}
.ai-dots {
  display: inline-flex;
  gap: 4px;
}
.ai-dots i {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: #98a2b3;
  animation: aiDot 1s infinite ease-in-out;
}
.ai-dots i:nth-child(2) {
  animation-delay: 0.15s;
}
.ai-dots i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes aiDot {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* history */
.ai-hist {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border-radius: 14px;
  transition:
    background 0.15s,
    box-shadow 0.15s;
}
.ai-hist:hover {
  background: #fafbfc;
}
.ai-hist.on {
  background: #fff;
  box-shadow:
    0 0 0 1px var(--line),
    0 6px 18px -12px rgba(16, 24, 40, 0.25);
}
.ai-hist-sub {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--mut);
}

/* below 1200px the history becomes a slide-over from the right */
@media (max-width: 1199.98px) {
  .ai-history {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    width: min(380px, 100vw);
    border-radius: 0;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .ai-history.open {
    transform: none;
  }
  .ai-overlay {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(11, 15, 20, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }
  .ai-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }
}

.ai-toast {
  animation: fadeUp 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

/* 1200–1399px: chat column is ~480px, so cards become compact rows */
@media (min-width: 1200px) and (max-width: 1399.98px) {
  .ai-card {
    min-height: 0;
    padding: 16px 18px 16px 72px;
  }
  .ai-card-ic {
    position: absolute;
    left: 18px;
    top: 18px;
    margin: 0 !important;
  }
  .ai-card-text {
    margin-top: 4px;
  }
}

/* The rounded wrappers show focus (see .ai-input:focus-within), so drop the
   browser's own rectangular outline on the inputs inside them. */
#prompt:focus,
#prompt:focus-visible,
#historySearch:focus,
#historySearch:focus-visible {
  outline: none;
}

