.ai-sys-panel {
    margin: 0 0 16px;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid #93c5fd;
    background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.ai-sys-panel__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.ai-sys-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 700;
    user-select: none;
}

.ai-sys-toggle input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.ai-page {
    max-width: 920px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

.ai-page__head {
    margin-bottom: 20px;
}

.ai-page__title {
    margin: 0 0 6px;
    font-size: 1.5rem;
    font-weight: 700;
}

.ai-page__sub {
    margin: 0;
    color: #64748b;
    font-size: 0.95rem;
}

.ai-page__sub-ar {
    margin: 4px 0 0;
    color: #475569;
    font-size: 0.9rem;
    direction: rtl;
    text-align: right;
}

.ai-setup {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 12px;
    padding: 20px;
    color: #9a3412;
}

.ai-setup code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
}

.ai-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: #64748b;
}

.ai-chat {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    min-height: 420px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.ai-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: min(58vh, 520px);
}

.ai-msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 0.95rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-msg--user {
    align-self: flex-end;
    background: #1e3a5f;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-msg--assistant {
    align-self: flex-start;
    background: #f1f5f9;
    color: #0f172a;
    border-bottom-left-radius: 4px;
}

.ai-msg--system {
    align-self: center;
    background: transparent;
    color: #64748b;
    font-size: 0.85rem;
    text-align: center;
    max-width: 100%;
}

.ai-chat__composer {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.ai-chat__input {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    resize: vertical;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
}

.ai-msg-extras {
    margin: 0.35rem 0 0.75rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.ai-action-link {
    display: inline-block;
    font-size: 0.9rem;
    color: var(--primary, #2563eb);
    text-decoration: underline;
}

.ai-pending-action {
    margin: 0.35rem 0 0.75rem 0.75rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid rgba(234, 179, 8, 0.45);
    border-radius: 8px;
    background: rgba(234, 179, 8, 0.08);
    max-width: 520px;
}

.ai-pending-action p {
    margin: 0 0 0.5rem;
    font-size: 0.88rem;
}

.ai-confirm-btn {
    font-size: 0.85rem;
    padding: 0.35rem 0.75rem;
}

.ai-chat__actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-btn {
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 600;
    cursor: pointer;
    font: inherit;
}

.ai-btn--primary {
    background: #1e3a5f;
    color: #fff;
}

.ai-btn--primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.ai-btn--ghost {
    background: #e2e8f0;
    color: #334155;
}

html[data-theme="dark"] .ai-chat,
html.dark-theme .ai-chat {
    background: #1e293b;
    border-color: #334155;
}

html[data-theme="dark"] .ai-msg--assistant,
html.dark-theme .ai-msg--assistant {
    background: #334155;
    color: #f1f5f9;
}

html[data-theme="dark"] .ai-chat__composer,
html.dark-theme .ai-chat__composer {
    background: #0f172a;
    border-color: #334155;
}

html[data-theme="dark"] .ai-chat__input,
html.dark-theme .ai-chat__input {
    background: #1e293b;
    color: #f8fafc;
    border-color: #475569;
}
