/* oksi4 v2.02 — ai-assistant.css */

/* ─── AI button in header ──────────────────────────────────────── */
#btn-ai { color: var(--text-muted); }
#btn-ai:hover { color: var(--text); }
#btn-ai svg { overflow: visible; }

/* Зірка — синя, пульсує */
.ai-star-pulse {
  transform-origin: 19.5px 6.5px;
  animation: ai-star-anim 2.8s ease-in-out infinite;
  filter: drop-shadow(0 0 3px rgba(37,99,235,0.8));
}
@keyframes ai-star-anim {
  0%,100% { opacity:1;   transform: scale(1)    rotate(0deg);   }
  35%      { opacity:0.5; transform: scale(0.6)  rotate(-22deg); }
  65%      { opacity:1;   transform: scale(1.25) rotate(14deg);  }
}

/* ─── Overlay ──────────────────────────────────────────────────── */
#ai-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 350;
  backdrop-filter: blur(2px);
}
#ai-overlay.open { display: block; }

/* ─── Modal ────────────────────────────────────────────────────── */
#ai-modal {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: 560px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 360;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(16px);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
#ai-modal.open {
  display: flex;
  transform: translateY(0);
  opacity: 1;
}

/* ─── Header ───────────────────────────────────────────────────── */
.ai-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 11px;
  background: var(--bg-3);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-header-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  flex-shrink: 0;
  color: var(--text-muted);  /* той самий колір що й хедер-кнопка */
}
.ai-header-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
  flex: 1;
  letter-spacing: 0.05em;
}
.ai-remaining {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}
.ai-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  border-radius: 4px;
  transition: color var(--tr);
}
.ai-close-btn:hover { color: var(--text); }
.ai-close-btn [data-lucide] { width: 15px; height: 15px; }

/* ─── Messages ─────────────────────────────────────────────────── */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.ai-messages::-webkit-scrollbar { width: 3px; }
.ai-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.ai-msg {
  display: flex;
  max-width: 88%;
  animation: ai-fadein 0.25s ease;
}
@keyframes ai-fadein {
  from { opacity:0; transform:translateY(5px); }
  to   { opacity:1; transform:none; }
}
.ai-msg-user { align-self: flex-end; }
.ai-msg-ai   { align-self: flex-start; }

.ai-bubble {
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
}
.ai-msg-ai .ai-bubble {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
}
.ai-msg-user .ai-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-msg-ai .ai-bubble strong { color: var(--accent); }

/* ─── Typing dots ──────────────────────────────────────────────── */
.ai-dots { display: inline-flex; gap: 4px; align-items: center; height: 16px; }
.ai-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: ai-bounce 1.2s infinite;
}
.ai-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-bounce {
  0%,60%,100% { transform: translateY(0); }
  30%         { transform: translateY(-5px); }
}

/* ─── Product cards ────────────────────────────────────────────── */
.ai-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.ai-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  transition: border-color 0.12s;
  cursor: pointer;
}
.ai-card:hover { border-color: var(--accent); }
.ai-card-model {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  margin-bottom: 2px;
}
.ai-card-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
  margin-bottom: 5px;
}
.ai-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ai-card-price {
  font-size: 12px;
  font-weight: 700;
  color: var(--warning, #d29922);
}

/* ─── Quick prompts ────────────────────────────────────────────── */
.ai-quick {
  padding: 0 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ai-quick-btn {
  text-align: left;
  padding: 6px 10px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s;
  font-family: inherit;
}
.ai-quick-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* ─── Input area ───────────────────────────────────────────────── */
.ai-input-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px;
  /* iPhone safe area — піднімаємо над home bar */
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg-3);
  flex-shrink: 0;
}
.ai-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 36px;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color 0.12s;
}
.ai-input:focus { border-color: var(--accent); }
.ai-input::placeholder { color: var(--text-muted); }

.ai-send-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.12s;
}
.ai-send-btn:hover { background: var(--accent-hover); }
.ai-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ai-send-btn [data-lucide] { width: 14px; height: 14px; color: #fff; }

/* ─── Light theme ──────────────────────────────────────────────── */
[data-theme="light"] .ai-msg-ai .ai-bubble {
  background: #f0f4f8;
  border-color: var(--border);
}
[data-theme="light"] .ai-card { background: #fff; }

/* ─── Mobile portrait ──────────────────────────────────────────── */
@media (max-width: 768px) {
  #ai-modal {
    bottom: 0; right: 0; left: 0;
    width: 100%; max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 80vh;
  }
  .ai-messages { padding: 12px; gap: 8px; }
  .ai-bubble   { font-size: 14px; padding: 10px 13px; }
}

/* ─── Landscape (телефони) ──────────────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
  /* Модаль — права половина екрану */
  #ai-modal {
    top: 42px; bottom: 0;
    right: 0; left: auto;       /* права сторона */
    width: 50%;                  /* половина ширини */
    max-width: 420px;
    max-height: calc(100vh - 42px);
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }

  /* Overlay — тільки ліва половина (не блокує каталог) */
  #ai-overlay {
    right: 50%;                  /* overlay тільки зліва */
  }

  /* Компактний хедер */
  .ai-header        { padding: 6px 12px; flex-shrink: 0; }
  .ai-header-title  { font-size: 12px; }
  .ai-remaining     { font-size: 10px; }

  /* Quick prompts — сховати */
  .ai-quick { display: none; }

  /* Повідомлення */
  .ai-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 12px;
    gap: 8px;
  }
  .ai-bubble       { font-size: 13px; padding: 8px 11px; }
  .ai-msg          { max-width: 95%; }

  /* Input */
  .ai-input-wrap   { flex-shrink: 0; padding: 7px 10px; }
  .ai-input        { font-size: 13px; min-height: 32px; }
  .ai-send-btn     { width: 32px; height: 32px; }
}

/* ─── Orientation change — reset modal size ─────────────────────── */
@media (orientation: portrait) {
  #ai-modal.open {
    /* При поверненні в portrait — знімаємо landscape стилі */
    top: auto;
    max-height: 80vh;
    border-radius: 16px 16px 0 0;
  }
}

/* deploy: 2026-06-01 */
/* @oksi4-v2.02 */
