/* صفحه هوش مصنوعی (/AI) به شکل گفتگو؛ رنگ‌ها و کتابخانه عکس و انتخاب مدل از pm-generator.css می‌آید */

.aic-page {
    max-width: 860px;
    margin: 0 auto;
    padding-top: 1.5rem;
    padding-bottom: 2rem;
}

.aic-hero {
    text-align: center;
    margin-bottom: 16px;
}

    .aic-hero h1 {
        margin: 0 0 6px;
        font-size: 24px;
        line-height: 1.6;
        color: #0f172b;
    }

    .aic-hero p {
        margin: 0 auto;
        max-width: 620px;
        font-size: 14px;
        line-height: 1.9;
        color: #64748b;
    }

/* ---------- کادر گفتگو ---------- */
.aic {
    display: flex;
    flex-direction: column;
}

.aic-thread {
    padding: 18px 16px 6px;
    min-height: 340px;
    max-height: min(62vh, 640px);
    overflow-y: auto;
    background: linear-gradient(180deg, #fbfcff 0%, #fff 60%);
}

    /* تا پیامی نیست، کادر گفتگو اسکرول داخلی نداشته باشد و اسکرول به صفحه برسد */
    .aic-thread.is-empty {
        overflow: visible;
    }

.aic-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 14px;
}

    .aic-msg.is-user {
        justify-content: flex-end;
    }

.aic-avatar {
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--pmg-accent-soft);
    display: grid;
    place-items: center;
    font-size: 15px;
}

.aic-bubble {
    max-width: min(560px, 84%);
    padding: 10px 14px;
    border-radius: 18px;
    line-height: 1.9;
    font-size: 14px;
    word-wrap: break-word;
}

    .aic-bubble p {
        margin: 0 0 6px;
    }

        .aic-bubble p:last-child {
            margin-bottom: 0;
        }

.is-bot .aic-bubble {
    background: #fff;
    border: 1px solid var(--pmg-line);
    border-bottom-right-radius: 6px;
}

.is-user .aic-bubble {
    background: var(--pmg-accent);
    color: #fff;
    border-bottom-left-radius: 6px;
}

    .is-user .aic-bubble p {
        white-space: pre-wrap;
    }

.aic-muted {
    color: var(--pmg-muted);
    font-size: 12.5px;
}

.aic-inline-icon {
    display: inline-block;
    padding: 0 4px;
    border-radius: 6px;
    background: var(--pmg-soft);
}

.aic-msg-meta {
    display: block;
    margin-top: 6px;
    font-size: 11.5px;
    color: var(--pmg-muted);
}

.aic-user-imgs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

    .aic-user-imgs img {
        width: 64px;
        height: 64px;
        object-fit: cover;
        border-radius: 10px;
        border: 2px solid rgba(255, 255, 255, .5);
    }

.aic-working {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    margin-bottom: 4px;
}

.aic-result {
    display: block;
    margin-bottom: 8px;
}

    .aic-result img {
        display: block;
        max-width: 100%;
        max-height: 440px;
        border-radius: 12px;
        background: var(--pmg-soft);
    }

.aic-acts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.aic-act {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--pmg-line);
    background: #fff;
    color: var(--pmg-ink);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
    text-decoration: none;
}

    .aic-act:hover {
        border-color: var(--pmg-accent);
        color: var(--pmg-accent);
    }

    .aic-act.is-primary {
        background: var(--pmg-accent);
        border-color: var(--pmg-accent);
        color: #fff;
    }

.aic-guest {
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--pmg-accent-soft);
    font-size: 13px;
}

    .aic-guest .aic-act {
        margin-top: 8px;
    }

/* ---------- پنل عکس‌ها و تنظیمات مدل (بالای کادر پیام) ---------- */
.aic-panel {
    border-top: 1px solid var(--pmg-line);
    background: var(--pmg-soft);
    max-height: 55vh;
    overflow-y: auto;
}

    .aic-panel .pmg-step {
        border-bottom: 0;
        padding-bottom: 8px;
    }

    .aic-panel .pmg-num,
    .aic-panel .pmg-cta .pmg-btn,
    .aic-panel .pmg-cta-meta > span {
        display: none;
    }

    .aic-panel .pmg-cta {
        padding: 0 18px 4px;
        border: 0;
        background: none;
    }

.aic-panel-done {
    display: block;
    margin: 4px 18px 14px auto;
    padding: 8px 22px;
    border-radius: 999px;
    border: 0;
    background: var(--pmg-ink);
    color: #fff;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

/* ---------- پنجره پاپ‌آپ انتخاب مدل ---------- */
.aic-panel.aic-modal {
    position: fixed;
    inset: 0;
    z-index: 1040;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    border: 0;
    background: none;
    max-height: none;
    overflow: visible;
}

.aic-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 43, .5);
    animation: aic-fade .15s ease-out;
}

.aic-modal-box {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(620px, 100%);
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(15, 23, 43, .25);
    overflow: hidden;
    animation: aic-pop .18s ease-out;
}

.aic-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

    .aic-modal-body .pmg-step-head {
        padding-left: 40px;
    }

.aic-modal-close {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 10px rgba(15, 23, 43, .12);
    color: var(--pmg-muted);
    cursor: pointer;
}

    .aic-modal-close:hover {
        background: var(--pmg-line);
        color: var(--pmg-ink);
    }

.aic-modal-foot {
    flex: none;
    border-top: 1px solid var(--pmg-line);
    background: #fff;
}

    .aic-modal-foot .aic-panel-done {
        margin: 12px 18px;
        margin-right: auto;
    }

body.aic-modal-open {
    overflow: hidden;
}

@keyframes aic-fade {
    from { opacity: 0; }
}

@keyframes aic-pop {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
}

/* ---------- کادر پیام ---------- */
.aic-composer {
    border-top: 1px solid var(--pmg-line);
    padding: 12px 14px 10px;
    background: #fff;
}

.aic-attached {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.aic-att {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

    .aic-att img {
        width: 48px;
        height: 48px;
        object-fit: cover;
        border-radius: 10px;
        border: 1px solid var(--pmg-line);
    }

    .aic-att.is-source {
        padding-left: 30px;
        border-radius: 12px;
        background: var(--pmg-accent-soft);
        font-size: 12.5px;
        color: var(--pmg-accent);
        font-weight: bold;
    }

    .aic-att button {
        position: absolute;
        top: -6px;
        left: -6px;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        border: 0;
        background: var(--pmg-ink);
        color: #fff;
        font-size: 13px;
        line-height: 20px;
        padding: 0;
        cursor: pointer;
    }

    .aic-att.is-source button {
        top: 50%;
        left: 4px;
        transform: translateY(-50%);
    }

.aic-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.aic-input {
    flex: 1;
    min-width: 0;
    resize: none;
    max-height: 160px;
    padding: 11px 14px;
    border: 1px solid var(--pmg-line);
    border-radius: 22px;
    background: var(--pmg-soft);
    color: var(--pmg-ink);
    font: inherit;
    font-size: 16px; /* زیر ۱۶ پیکسل آیفون صفحه را زوم می‌کند */
    line-height: 1.6;
    outline: none;
}

    .aic-input:focus {
        border-color: var(--pmg-accent);
        background: #fff;
    }

.aic-icon-btn,
.aic-send {
    position: relative;
    flex: none;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 0;
    display: grid;
    place-items: center;
    cursor: pointer;
}

.aic-icon-btn {
    background: var(--pmg-soft);
    color: var(--pmg-ink);
    border: 1px solid var(--pmg-line);
}

    .aic-icon-btn.is-active {
        background: var(--pmg-accent-soft);
        color: var(--pmg-accent);
        border-color: var(--pmg-accent);
    }

.aic-send {
    background: var(--pmg-accent);
    color: #fff;
}

    .aic-send svg {
        transform: scaleX(-1); /* فلش به سمت چپ در صفحه راست‌به‌چپ */
    }

    .aic-send:disabled {
        opacity: .5;
        cursor: wait;
    }

.aic-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--pmg-teal);
    color: #fff;
    font-size: 11px;
    line-height: 19px;
    font-weight: bold;
}

.aic-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    margin-top: 8px;
    font-size: 12.5px;
    color: var(--pmg-muted);
}

.aic-model {
    flex: 1 1 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 14px;
    border-radius: 14px;
    border: 1px solid var(--pmg-line);
    background: var(--pmg-soft);
    color: var(--pmg-ink);
    font: inherit;
    text-align: right;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

    .aic-model:hover,
    .aic-model.is-active {
        border-color: var(--pmg-accent);
        background: var(--pmg-accent-soft);
    }

.aic-model-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid var(--pmg-line);
    font-size: 16px;
}

.aic-model-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

.aic-model-cap {
    font-size: 11.5px;
    color: var(--pmg-muted);
}

.aic-model-val {
    font-size: 14px;
    font-weight: bold;
    color: var(--pmg-ink);
    white-space: normal;
    overflow-wrap: anywhere;
}

.aic-model-change {
    flex: none;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--pmg-accent);
    color: #fff;
    font-size: 12px;
    font-weight: bold;
}

.aic-balance {
    margin-right: auto;
    border: 0;
    background: none;
    padding: 0;
    color: var(--pmg-accent);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
    text-decoration: none;
}

/* ---------- متن راهنما و سؤالات ---------- */
.aic-guide {
    margin-top: 28px;
    padding: 22px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 14px;
    line-height: 2;
    color: #334155;
}

    .aic-guide h2 {
        margin: 18px 0 6px;
        font-size: 18px;
        color: #0f172b;
    }

        .aic-guide h2:first-child {
            margin-top: 0;
        }

    .aic-guide p {
        margin: 0 0 8px;
    }

    .aic-guide a {
        color: #4f46e5;
    }

.aic-steps,
.aic-examples {
    margin: 0;
    padding-right: 20px;
}

.aic-faq details {
    border-bottom: 1px solid #e2e8f0;
    padding: 10px 0;
}

    .aic-faq details:last-child {
        border-bottom: 0;
    }

.aic-faq summary {
    cursor: pointer;
    font-weight: bold;
    color: #0f172b;
}

.aic-faq details p {
    margin: 6px 0 0;
}

@media (max-width: 600px) {
    .aic-page {
        padding-top: 1rem;
    }

    .aic-hero h1 {
        font-size: 20px;
    }

    .aic-thread {
        padding: 14px 10px 4px;
        min-height: 300px;
        max-height: 58vh;
    }

    .aic-bubble {
        max-width: 88%;
    }

    .aic-composer {
        padding: 10px;
    }

    .aic-guide {
        padding: 16px;
    }

    /* در موبایل پنجره انتخاب مدل از پایین صفحه بالا می‌آید */
    .aic-panel.aic-modal {
        align-items: flex-end;
        padding: 0;
    }

    .aic-modal-box {
        width: 100%;
        max-height: 88vh;
        max-height: 88dvh;
        border-radius: 20px 20px 0 0;
        animation-name: aic-sheet;
    }

    .aic-modal-foot .aic-panel-done {
        width: calc(100% - 28px);
        margin: 10px 14px calc(10px + env(safe-area-inset-bottom));
        padding: 11px 22px;
        font-size: 14px;
    }
}

@keyframes aic-sheet {
    from { transform: translateY(100%); }
}
