/* =========================================================================
   پنجره «طراحی هوشمند AI» — static/js/ai_design.js
   -------------------------------------------------------------------------
   با لمس دکمه «طراحی هوشمند AI» یک پنجره وسط صفحه باز می‌شود (نه زیر دکمه):
   جای نوشتن توضیح، چند ایده آماده و دکمه «بساز و اعمال کن».
   ========================================================================= */
.aid-overlay {
    position: fixed;
    inset: 0;
    z-index: 8000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: radial-gradient(120% 90% at 50% 30%, rgba(60, 20, 90, 0.55) 0%, rgba(0, 0, 0, 0.78) 70%);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.aid-overlay.show { opacity: 1; }

.aid-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: calc(100vh - 36px);
    overflow-y: auto;
    border-radius: 26px;
    padding: 26px 20px 20px;
    background: linear-gradient(160deg, #1f1a33 0%, #15131f 55%, #111018 100%);
    box-shadow: 0 30px 70px -20px rgba(124, 77, 255, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
    transform: translateY(26px) scale(0.94);
    opacity: 0;
    transition: transform 0.38s cubic-bezier(0.2, 1.3, 0.35, 1), opacity 0.25s ease;
    text-align: center;
    isolation: isolate;
}
.aid-overlay.show .aid-card { transform: translateY(0) scale(1); opacity: 1; }

/* حاشیه گرادیانی متحرک دور کارت */
.aid-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1.5px;
    background: linear-gradient(120deg, #FF0080, #7C4DFF, #00D7FF, #FF0080);
    background-size: 300% 300%;
    animation: aidBorder 6s linear infinite;
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: -1;
}
@keyframes aidBorder { to { background-position: 300% 0; } }

.aid-close {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.07);
    color: #c9c9d6;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
}
.aid-close:active { transform: scale(0.9); background: rgba(255, 255, 255, 0.14); }

.aid-orb {
    width: 64px;
    height: 64px;
    margin: 2px auto 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.65rem;
    color: #fff;
    background: linear-gradient(135deg, #FF0080 0%, #7C4DFF 60%, #00D7FF 100%);
    box-shadow: 0 10px 30px -6px rgba(255, 0, 128, 0.55), inset 0 0 0 3px rgba(255, 255, 255, 0.12);
    animation: aidOrb 2.6s ease-in-out infinite;
}
@keyframes aidOrb {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-4px) rotate(-6deg); }
}
.aid-title { font-size: 1.22rem; font-weight: 900; color: #fff; margin-bottom: 6px; }
.aid-sub { font-size: 0.82rem; color: #a9a6c0; line-height: 1.8; margin: 0 6px 16px; }

.aid-field { position: relative; text-align: right; }
.aid-field textarea {
    width: 100%;
    min-height: 112px;
    max-height: 220px;
    resize: none;
    margin: 0;
    padding: 14px 14px 26px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(255, 255, 255, 0.045);
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.9;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    user-select: text;
    -webkit-user-select: text;
}
.aid-field textarea::placeholder { color: #6f6b88; }
.aid-field textarea:focus {
    border-color: rgba(124, 77, 255, 0.75);
    background: rgba(124, 77, 255, 0.07);
    box-shadow: 0 0 0 4px rgba(124, 77, 255, 0.16);
}
.aid-count {
    position: absolute;
    left: 12px;
    bottom: 8px;
    font-size: 0.66rem;
    color: #6f6b88;
    pointer-events: none;
}
.aid-field.shake { animation: aidShake 0.4s ease; }
@keyframes aidShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-7px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(3px); }
}

.aid-chips-label {
    margin: 14px 2px 8px;
    font-size: 0.72rem;
    font-weight: 800;
    color: #8f8ba8;
    text-align: right;
}
.aid-chips { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-start; }
.aid-chip {
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(255, 255, 255, 0.05);
    color: #dcd9ee;
    border-radius: 999px;
    padding: 6px 12px;
    font-family: inherit;
    font-size: 0.74rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.12s, color 0.2s;
}
.aid-chip:active { transform: scale(0.95); }
.aid-chip.on {
    background: rgba(124, 77, 255, 0.22);
    border-color: rgba(124, 77, 255, 0.7);
    color: #fff;
}

.aid-error {
    display: none;
    margin-top: 12px;
    padding: 9px 12px;
    border-radius: 12px;
    background: rgba(255, 82, 82, 0.10);
    border: 1px solid rgba(255, 82, 82, 0.35);
    color: #ffb3b3;
    font-size: 0.78rem;
    line-height: 1.8;
    text-align: right;
}
.aid-error.show { display: block; }

.aid-go {
    margin-top: 16px !important;
    padding: 14px !important;
    border-radius: 16px !important;
    font-size: 1rem !important;
    font-weight: 900 !important;
    background: linear-gradient(90deg, #FF0080 0%, #7928CA 50%, #FF0080 100%) !important;
    background-size: 200% auto !important;
    animation: gradientMove 3s linear infinite;
    box-shadow: 0 10px 26px -10px rgba(255, 0, 128, 0.85);
    transition: transform 0.15s, opacity 0.2s;
}
.aid-go:active { transform: scale(0.97); }
.aid-go:disabled { opacity: 0.85; cursor: wait; }
.aid-go .aid-spin {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    animation: aidSpin 0.8s linear infinite;
}
@keyframes aidSpin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .aid-card::before, .aid-orb, .aid-go, .aid-go .aid-spin { animation: none; }
}
