/* Mitoto.Life - AI search chat UI (frontend only) */

.home-stage.is-ai-open {
    height: var(--home-stage-height, calc(100svh / var(--page-zoom, 0.9))) !important;
    min-height: var(--home-stage-height, calc(100svh / var(--page-zoom, 0.9))) !important;
    max-height: var(--home-stage-height, calc(100svh / var(--page-zoom, 0.9))) !important;
    padding-bottom: var(--home-stage-pad-bottom, 16px) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.home-stage.is-ai-open .home-stage__search[data-ai-idle],
.home-stage.is-ai-open [data-ai-idle] {
    display: none !important;
}

#najpopularniejsze.is-ai-hidden {
    display: none !important;
}

body.ai-search-open #home-promo {
    display: none !important;
}

.ai-product-rail {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 10px 2px 8px;
    max-width: 100%;
}

.ai-product-rail__item {
    flex: 0 0 min(220px, 72vw);
}


.home-stage.is-ai-open .ai-search {
    display: flex !important;
    flex: 1 1 auto;
    flex-direction: column;
    width: 100%;
    max-width: none;
    margin: 0;
    min-height: 0;
    max-height: 100%;
    height: auto;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    box-shadow: none;
    overflow: hidden;
    box-sizing: border-box;
}

.ai-search[hidden] { display: none !important; }

.ai-search__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px clamp(16px, 4vw, 40px);
    border-bottom: 1px solid var(--border-color, #e5e5ea);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    flex: 0 0 auto;
}

.ai-search__heading { display: flex; flex-direction: column; gap: 2px; min-width: 0; text-align: left; }
.ai-search__heading h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.2px; color: var(--text-primary, #1d1d1f); }
.ai-search__heading p { margin: 0; font-size: 12.5px; color: var(--text-secondary, #86868b); }

.ai-search__close {
    flex: 0 0 auto; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-color, #e5e5ea); border-radius: 12px; background: var(--bg-secondary, #f5f5f7);
    color: var(--text-secondary, #86868b); cursor: pointer;
}
.ai-search__close:hover { background: #fff; color: var(--text-primary, #1d1d1f); }
.ai-search__close svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2.2; fill: none; stroke-linecap: round; }

.ai-search__messages {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 24px clamp(16px, 4vw, 40px) 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    max-height: 100%;
    overflow-x: hidden;
    background:
        radial-gradient(1200px 240px at 50% -40%, rgba(0, 102, 204, 0.05), transparent 60%),
        var(--bg-color, #fbfbfd);
}

.ai-msg {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(720px, 100%);
    overflow: visible;
}

.ai-msg__bubble {
    animation: aiMsgIn 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-msg--user { align-self: flex-end; align-items: flex-end; }
.ai-msg--assistant { align-self: flex-start; align-items: flex-start; }
@keyframes aiMsgIn { from { opacity: 0; } to { opacity: 1; } }

.ai-msg__bubble { padding: 12px 14px; border-radius: 18px; font-size: 14.5px; line-height: 1.45; max-width: 100%; }
.ai-msg--user .ai-msg__bubble { background: var(--text-primary, #1d1d1f); color: #fff; border-bottom-right-radius: 8px; }
.ai-msg--assistant .ai-msg__bubble { background: #fff; color: var(--text-primary, #1d1d1f); border: 1px solid var(--border-color, #e5e5ea); border-bottom-left-radius: 8px; box-shadow: var(--shadow-sm); }
.ai-msg__text { margin: 0; white-space: pre-wrap; word-break: break-word; }
.ai-msg--typing .ai-msg__bubble { display: inline-flex; align-items: center; gap: 10px; }

.ai-typing { display: inline-flex; gap: 4px; }
.ai-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-tertiary, #a1a1a6); display: block; animation: aiDot 1.1s ease-in-out infinite; }
.ai-typing i:nth-child(2) { animation-delay: 0.15s; }
.ai-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes aiDot { 0%, 80%, 100% { opacity: 0.35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.ai-typing__label { font-size: 13px; color: var(--text-secondary, #86868b); font-weight: 500; }

.ai-search__guest-hint {
    margin: 0;
    padding: 8px clamp(16px, 4vw, 40px) 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text-secondary, #86868b);
    flex: 0 0 auto;
}
.ai-search__guest-hint.is-limit {
    color: #c62828;
    font-weight: 600;
}

.ai-search__composer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px clamp(16px, 4vw, 40px) 18px;
    border-top: 1px solid var(--border-color, #e5e5ea);
    background: #fff;
    flex: 0 0 auto;
}
.ai-search__composer-field {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
    background: var(--bg-secondary, #f5f5f7); border: 1px solid var(--border-color, #e5e5ea);
    border-radius: 999px; padding: 8px 8px 8px 16px;
}
.ai-search__composer-field:focus-within { background: #fff; border-color: rgba(0,102,204,.35); box-shadow: var(--focus-ring); }
.ai-search__composer-field input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font-size: 15px; font-family: inherit; }
.ai-search__send {
    flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; border: none;
    background: var(--text-primary, #1d1d1f); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.ai-search__send:hover { background: #333; }
.ai-search__send svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 768px) {
  .home-stage.is-ai-open .ai-search {
    min-height: 0;
  }
}
