/* ============================================================
   aiconsole_embed
   ------------------------------------------------------------
   Two concerns in this file:

   1. Host-page styles (.aic-embed-wrap, .aic-embed-iframe,
      .aic-embed-guest*) — applied to whatever Web Page hosts
      the aiconsole_embed Web Template block.

   2. In-iframe toggles (.aic-embed-mode[data-show-*])  — applied
      *inside* the iframe; live alongside the existing portal
      styles in the same bundle.
   ============================================================ */

/* ── 1. Host-page wrapper + guest placeholder ──────────────── */

.aic-embed-wrap {
    width: 100%;
    display: block;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #f5f6f7;
}

.aic-embed-iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.aic-embed-guest {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    padding: 2rem;
    text-align: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #1f2937;
}

.aic-embed-guest-img {
    max-width: 60%;
    max-height: 60%;
    object-fit: contain;
    opacity: 0.85;
}

.aic-embed-guest-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.aic-embed-guest-text {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    color: #374151;
}

.aic-embed-guest-cta {
    min-width: 9rem;
}

/* ── 2. In-iframe component toggles ────────────────────────── */

/* Embed mode runs without the site chrome and without the aiconsole
   top-bar; collapse the outer padding so the chat fills the iframe. */
.aiconsole-portal.aic-embed-mode {
    padding: 0;
    margin: 0;
    height: 100vh;
}

/* Full height chain: the iframe body → the portal wrapper → the chat
   container → the main column → the messages area must ALL be able to
   shrink to their parent. Without min-height:0 at every flex step,
   flex-1 falls back to min-content and the whole thing overflows.
   `:has()` walks up to html/body since we can't add classes there. */
html:has(> body .aiconsole-portal.aic-embed-mode),
body:has(> .aiconsole-portal.aic-embed-mode),
body:has(.aiconsole-portal.aic-embed-mode) {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    margin: 0;
}
.aiconsole-portal.aic-embed-mode {
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.aiconsole-portal.aic-embed-mode .aic-chat-container {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    max-height: 100%;
    border-radius: 0;
    border: 0;
}
.aiconsole-portal.aic-embed-mode .aic-main {
    min-height: 0;       /* let the flex column shrink */
}
.aiconsole-portal.aic-embed-mode .aic-messages {
    min-height: 0;       /* let flex-1 actually be constrained */
    overflow-y: auto;
}
.aiconsole-portal.aic-embed-mode .aic-input-area {
    flex: 0 0 auto;      /* pin the composer to the bottom */
}
/* Welcome hero eats vertical space and pushes the input off screen
   on tight tiles. Shrink it heavily in embed-mode. */
.aiconsole-portal.aic-embed-mode .aic-welcome {
    padding: 12px 8px !important;
}
.aiconsole-portal.aic-embed-mode .aic-welcome .aic-title {
    font-size: 1rem;
    margin: 0 0 4px;
}
.aiconsole-portal.aic-embed-mode .aic-welcome .aic-subtitle {
    font-size: 0.85rem;
    margin: 0;
}
/* Header pickers keep their default padding — trim them so the
   remaining height goes to messages. */
.aiconsole-portal.aic-embed-mode .aic-chat-header {
    padding: 6px 10px;
}

/* Sidebar (Recent / New Chat) */
.aiconsole-portal[data-show-sidebar="0"] .aic-sidebar {
    display: none !important;
}

/* Header pickers */
.aiconsole-portal[data-show-llm-picker="0"] #aic-llm-select {
    display: none !important;
}
.aiconsole-portal[data-show-project-picker="0"] #aic-project-select {
    display: none !important;
}

/* Input row (composer + mic) */
.aiconsole-portal[data-show-input="0"] .aic-input-area {
    display: none !important;
}

/* In-input toolbar (mic, attachments etc.) — keep the textarea, drop the actions column */
.aiconsole-portal[data-show-toolbar="0"] .aic-input-actions {
    display: none !important;
}
