/* ==========================================================================
   المساعد الذكي — صفحة المحادثة (أصناف ai-*)
   تعتمد توكنز Modernize (base.css/dark.css) فيتكيف مع الوضع الليلي تلقائياً.
   ========================================================================== */

.ai-shell {
    display: flex;
    flex-direction: row;
    min-height: 0;
    flex: 1;
    gap: 14px;
    align-items: stretch;
}

/* ---- تقييد ارتفاع الصفحة بارتفاع الشاشة ----
   منطقة الرسائل تملك overflow-y:auto لكنها flex:1 داخل بطاقة داخل صفحة بلا
   ارتفاع مقيد — فتمتد الصفحة كلها للأسفل مع كل رسالة والتمرير يقع على body
   لا على منطقة الرسائل. تقييد الصفحة هنا يفعّل سلسلة flex (صفحة ← shell ←
   بطاقة ← جسم الرسائل) فيصبح التمرير داخل الدردشة وحدها والكومبوزر مثبّت
   أسفلها دائماً. */
#assistantPage {
    height: calc(100vh - 40px); /* ديسكتوب: padding المضيف 20px×2 */
    min-height: 480px;
}
@supports (height: 100dvh) {
    #assistantPage {
        height: calc(100dvh - 40px); /* شريط عناوين الجوال الديناميكي */
    }
}
/* تابلت: المضيف بهامش 16px بدل padding 20px */
@media (max-width: 900px) and (min-width: 701px) {
    #assistantPage {
        height: calc(100vh - 32px);
    }
    @supports (height: 100dvh) {
        #assistantPage {
            height: calc(100dvh - 32px);
        }
    }
}
/* جوال: الصفحة تملأ الشاشة من الحافة للحافة (لا هامش مضيف) */
@media (max-width: 700px) {
    #assistantPage {
        height: 100vh;
        min-height: 0;
    }
    @supports (height: 100dvh) {
        #assistantPage {
            height: 100dvh;
        }
    }
}

/* ---- لوحة الجلسات المحفوظة ---- */
.ai-sessions {
    display: flex;
    flex-direction: column;
    width: 230px;
    flex: none;
    min-height: 0;
    background: var(--surface-main);
    border: 1px solid var(--border-main);
    border-radius: var(--pane-radius, 8px);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.ai-sessions-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-main);
    font-size: 13px;
}
.ai-sessions-close {
    display: none; /* زرّ الجوال فقط — الديسكتوب اللوحة ثابتة */
    border: 0;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 6px;
}
.ai-sessions-close:hover {
    background: var(--surface-hover, rgba(0, 0, 0, 0.05));
    color: var(--text-main);
}
.ai-sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ai-sessions-empty {
    padding: 14px 10px;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.6;
}
.ai-session-item {
    display: flex;
    align-items: stretch;
    gap: 2px;
    border-radius: 8px;
    transition: background 0.12s ease;
}
.ai-session-item:hover {
    background: var(--surface-hover, rgba(0, 0, 0, 0.05));
}
.ai-session-item.is-active {
    background: color-mix(in srgb, var(--primary) 12%, transparent);
}
.ai-session-open {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border: 0;
    background: none;
    text-align: start;
    font-family: inherit;
    cursor: pointer;
    border-radius: 8px;
}
.ai-session-title {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ai-session-meta {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ai-session-del {
    flex: none;
    align-self: center;
    border: 0;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    line-height: 0;
}
.ai-session-del:hover {
    color: var(--danger, #ef4444);
    background: color-mix(in srgb, var(--danger, #ef4444) 10%, transparent);
}
.ai-session-ren {
    flex: none;
    align-self: center;
    border: 0;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    line-height: 0;
}
.ai-session-ren:hover {
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
}
/* زرّ «الجلسات» في الترويسة — للجوال فقط (اللوحة مخفية هناك افتراضياً) */
.ai-sessions-toggle {
    display: none;
}

@media (max-width: 860px) {
    .ai-shell {
        flex-direction: column;
    }
    .ai-sessions {
        display: none;
        width: 100%;
        max-height: 260px;
    }
    .ai-sessions.is-open {
        display: flex;
    }
    .ai-sessions-close {
        display: inline-block;
    }
    .ai-sessions-toggle {
        display: inline-flex;
    }
}

.ai-balance-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--surface-solid, #fff);
    border: 1px solid var(--border-main);
    color: var(--text-main);
    font-size: 12.5px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.ai-balance-chip svg {
    color: var(--primary);
    flex: none;
}
.ai-balance-chip.is-low {
    color: var(--danger, #d0021b);
    border-color: currentColor;
}

/* ---- زرّ «الوضع الكامل» (نطاق اطّلاع المساعد الزمني) ---- */
.ai-fullaccess-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--surface-solid, #fff);
    border: 1px solid var(--border-main);
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    transition:
        border-color 0.15s ease,
        color 0.15s ease,
        background 0.15s ease;
    font-family: inherit;
}
.ai-fullaccess-chip svg {
    flex: none;
}
.ai-fullaccess-chip:hover {
    border-color: var(--primary);
    color: var(--text-main);
}
.ai-fullaccess-chip.is-on {
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    border-color: var(--primary);
    color: var(--primary);
}
.ai-fullaccess-chip:disabled {
    opacity: 0.6;
    cursor: wait;
}

@media (max-width: 768px) {
    .ai-fullaccess-chip span {
        font-size: 11.5px;
    }
}

.ai-chat-card {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background: var(--surface-main);
    border: 1px solid var(--border-main);
    border-radius: var(--pane-radius, 8px);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* ---- شريط الحالة والبانرات ---- */
.ai-status-note {
    padding: 10px 16px;
    font-size: 13px;
    line-height: 1.5;
    background: color-mix(in srgb, var(--warning, #f59e0b) 12%, transparent);
    border-bottom: 1px solid var(--border-main);
    color: var(--text-main);
}
.ai-status-note.is-error {
    background: color-mix(in srgb, var(--danger, #ef4444) 10%, transparent);
}
.ai-exhausted {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-main);
    background: color-mix(in srgb, var(--danger, #ef4444) 8%, transparent);
    font-size: 13px;
    color: var(--text-main);
}
.ai-exhausted strong {
    font-size: 14px;
}

/* 🔐 `display` الصريح أعلاه كان يتغلب على نمط المتصفّح [hidden]{display:none}
   فيظهر بانر «انتهى الرصيد» دائماً رغم إخفائه المنطقي — قاعدة اللغة الوحيدة
   الموثوقة هي !important هنا. تحرسها من الانحدار:tests/assistant-budget.test.js */
.ai-exhausted[hidden],
.ai-status-note[hidden] {
    display: none !important;
}

/* ---- منطقة الرسائل ---- */
.ai-chat-body {
    flex: 1;
    min-height: 240px;
    overflow-y: auto;
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

.ai-empty {
    margin: auto;
    max-width: 520px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 28px 12px;
}
.ai-empty-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--primary);
}
.ai-empty h2 {
    margin: 0;
    font-size: 17px;
    color: var(--text-main);
}
.ai-empty p {
    margin: 0;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-secondary);
}
.ai-suggestions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
    width: 100%;
    margin-top: 8px;
}
.ai-suggestion {
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--border-main);
    background: transparent;
    color: var(--text-main);
    font-size: 12.5px;
    line-height: 1.5;
    text-align: right;
    cursor: pointer;
    transition:
        border-color 0.15s ease,
        background 0.15s ease;
    font-family: inherit;
}
.ai-suggestion:hover {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 6%, transparent);
}

/* ---- الفقاعات ---- */
.ai-msg {
    display: flex;
    gap: 10px;
    max-width: min(78%, 640px);
    align-items: flex-start;
}
.ai-msg.is-user {
    align-self: flex-start;
    flex-direction: row-reverse;
}
.ai-msg.is-assistant {
    align-self: stretch;
    max-width: 100%;
}

.ai-msg-avatar {
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 800;
    margin-top: 2px;
}
.ai-msg.is-user .ai-msg-avatar {
    background: var(--primary);
    color: var(--on-primary, var(--text-light));
}
.ai-msg.is-assistant .ai-msg-avatar {
    background: color-mix(in srgb, var(--primary) 14%, transparent);
    color: var(--primary);
}

.ai-msg-bubble {
    padding: 11px 15px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
}
.ai-msg.is-user .ai-msg-bubble {
    background: var(--primary);
    color: var(--on-primary, var(--text-light));
    border-bottom-right-radius: 6px;
}
.ai-msg.is-assistant .ai-msg-bubble {
    background: var(--surface-solid, #fff);
    border: 1px solid var(--border-main);
    border-bottom-right-radius: 16px;
    border-top-left-radius: 6px;
    color: var(--text-main);
}
.ai-msg-bubble strong {
    font-weight: 800;
}

/* مؤشّر الكتابة */
.ai-typing {
    display: inline-flex;
    gap: 5px;
    padding: 4px 2px;
}
.ai-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: aiBounce 1.2s infinite ease-in-out;
}
.ai-typing span:nth-child(2) {
    animation-delay: 0.15s;
}
.ai-typing span:nth-child(3) {
    animation-delay: 0.3s;
}
@keyframes aiBounce {
    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* ---- المحرّر ---- */
.ai-composer {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid var(--border-main);
    background: var(--surface-solid, #fff);
}
.ai-composer-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--border-main);
    border-radius: 14px;
    background: transparent;
    color: var(--text-main);
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.6;
    padding: 10px 14px;
    max-height: 140px;
    outline: none;
    transition: border-color 0.15s ease;
}
.ai-composer-input:focus {
    border-color: var(--primary);
}
.ai-composer-input:disabled {
    opacity: 0.6;
}
.ai-composer-send {
    flex: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: var(--on-primary, var(--text-light));
    display: grid;
    place-items: center;
    cursor: pointer;
    box-shadow: var(--shadow-primary, 0 6px 16px color-mix(in srgb, var(--primary) 35%, transparent));
    transition:
        transform 0.15s ease,
        opacity 0.15s ease;
}
.ai-composer-send:hover:not(:disabled) {
    transform: translateY(-1px);
}
.ai-composer-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-composer-note {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px 16px;
    font-size: 11px;
    color: var(--text-secondary);
    border-top: 1px dashed var(--border-main);
    background: var(--surface-solid, #fff);
}
.ai-cost-note {
    font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
    .ai-typing span {
        animation: none;
    }
    .ai-composer-send,
    .ai-suggestion {
        transition: none;
    }
}

/* ---- الجوال: فقاعات أعرض وهوامش أضيق ---- */
@media (max-width: 768px) {
    .ai-chat-body {
        padding: 14px 10px;
    }
    .ai-msg {
        max-width: 92%;
    }
    .ai-composer {
        padding: 10px;
    }
    .ai-suggestions {
        grid-template-columns: 1fr;
    }
    .ai-topup-menu {
        width: calc(100vw - 32px);
        right: 16px;
    }
}

/* ==========================================================================
   تعبئة رصيد المساعد — قائمة منسدلة من زرّ الرصيد
   ========================================================================== */
.ai-balance-wrap {
    position: relative;
    display: inline-flex;
}

/* سهم صغير بجانب قيمة الرصيد يدلّ على أن الشريحة زرّ قابل للنقر */
.ai-balance-caret {
    margin-right: 2px;
    opacity: 0.65;
    transition: transform 0.18s ease;
}
.ai-balance-wrap.is-open .ai-balance-caret {
    transform: rotate(180deg);
}

.ai-topup-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 90;
    width: 320px;
    max-width: calc(100vw - 32px);
    background: var(--surface-solid, #fff);
    border: 1px solid var(--border-main);
    border-radius: 14px;
    box-shadow: 0 18px 40px -16px rgba(15, 23, 42, 0.3);
    padding: 14px;
    animation: ai-topup-in 0.16s ease;
}
@keyframes ai-topup-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.ai-topup-head {
    margin-bottom: 12px;
}
.ai-topup-head strong {
    display: block;
    font-size: 14px;
    font-weight: 800;
    color: var(--text-main);
}
.ai-topup-sub {
    display: block;
    font-size: 11.5px;
    color: var(--text-secondary);
    margin-top: 2px;
    line-height: 1.5;
}

.ai-topup-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.ai-topup-pkg {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 14px 10px;
    border-radius: 10px;
    background: var(--surface-soft, #f7f8fa);
    border: 1.5px solid var(--border-main);
    color: var(--text-main);
    font-family: inherit;
    font-weight: 800;
    cursor: pointer;
    transition:
        border-color 0.15s ease,
        transform 0.12s ease,
        background 0.15s ease;
    min-height: 64px;
}
.ai-topup-pkg:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}
.ai-topup-pkg:active {
    transform: translateY(0);
}
.ai-topup-pkg:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}
.ai-topup-pkg .pkg-amt {
    font-size: 18px;
    font-variant-numeric: tabular-nums;
}
.ai-topup-pkg .pkg-lbl {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 700;
}

/* قسم الطلبات المعلّقة — أسفل القائمة */
.ai-topup-pending {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border-main);
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
}
/* نفس بعثة [hidden] — display:flex أعلاه يغلبها فيظهر القسم الفاضي */
.ai-topup-pending[hidden] {
    display: none;
}
.ai-topup-pending-head {
    font-size: 11.5px;
    font-weight: 800;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.ai-topup-req {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--surface-soft, #f7f8fa);
    font-size: 12.5px;
}
.ai-topup-req .ai-amt {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.ai-topup-req .ai-st {
    margin-right: auto;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 800;
}
.ai-topup-req .ai-st-pending {
    background: var(--amber-soft, #fef3c7);
    color: var(--amber, #b45309);
}
.ai-topup-req .ai-st-approved {
    background: var(--green-soft, #dcfce7);
    color: var(--green, #15803d);
}
.ai-topup-req .ai-st-rejected {
    background: var(--red-soft, #fee2e2);
    color: var(--red, #b91c1c);
}

/* toast صغير لتأكيد إرسال الطلب — معاد استخدام تصميم .ai-status-note بحدود أخف */
.ai-topup-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 100;
    background: var(--surface-solid, #fff);
    color: var(--text-main);
    border: 1px solid var(--border-main);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 10px 30px -14px rgba(15, 23, 42, 0.25);
    animation: ai-topup-toast-in 0.2s ease;
}
.ai-topup-toast.ok {
    border-color: var(--green, #15803d);
    color: var(--green, #15803d);
}
.ai-topup-toast.err {
    border-color: var(--red, #b91c1c);
    color: var(--red, #b91c1c);
}
@keyframes ai-topup-toast-in {
    from {
        transform: translateY(8px);
        opacity: 0;
    }
    to {
        transform: none;
        opacity: 1;
    }
}

/* ==========================================================================
   صفحة الدفع — طبقة كاملة عند اختيار باقة التعبئة (أصناف ai-pay-*)
   تدفّق: باقة → طريقة دفع → تعليمات + رقم الإيصال → إرسال. مبنية على قائمة
   طرق ديناميكية جاهزة لاستقبال بوابة إلكترونية لاحقاً دون تغيير البنية.
   ========================================================================== */
.ai-pay-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    animation: ai-topup-in 0.16s ease;
}
/* ⚠️ إلزامي: display أعلاه يغلب [hidden] الافتراضي فتظهر الطبقة مفتوحة دائماً
   رغم سمة hidden بالماركب — نفس بعثة CSS المعروفة (انظر تعليق ai-exhausted). */
.ai-pay-overlay[hidden] {
    display: none;
}

.ai-pay-card {
    width: 460px;
    max-width: 100%;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: var(--surface-solid, #fff);
    border: 1px solid var(--border-main);
    border-radius: 16px;
    box-shadow: 0 24px 60px -20px rgba(15, 23, 42, 0.4);
    padding: 20px;
}

.ai-pay-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.ai-pay-head strong {
    display: block;
    font-size: 15px;
    font-weight: 800;
    color: var(--text-main);
}
.ai-pay-sub {
    display: block;
    font-size: 11.5px;
    color: var(--text-secondary);
    margin-top: 3px;
    line-height: 1.5;
}
.ai-pay-close {
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border-main);
    background: var(--surface-soft, #f7f8fa);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition:
        border-color 0.15s ease,
        color 0.15s ease;
}
.ai-pay-close:hover {
    border-color: var(--danger, #d0021b);
    color: var(--danger, #d0021b);
}

/* شريط المبلغ — هيرو الصفحة */
.ai-pay-amount {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--primary) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
    margin-bottom: 14px;
}
.ai-pay-amount span {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 700;
}
.ai-pay-amount strong {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    direction: ltr;
}

.ai-pay-label {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 8px;
}

.ai-pay-methods {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}
.ai-pay-method {
    padding: 10px 8px;
    border-radius: 10px;
    background: var(--surface-soft, #f7f8fa);
    border: 1.5px solid var(--border-main);
    color: var(--text-main);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    transition:
        border-color 0.15s ease,
        background 0.15s ease;
}
.ai-pay-method:hover {
    border-color: var(--primary);
}
.ai-pay-method.is-selected {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.ai-pay-instructions {
    font-size: 12px;
    line-height: 1.7;
    color: var(--text-secondary);
    background: var(--surface-soft, #f7f8fa);
    border: 1px solid var(--border-main);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
}

.ai-pay-field {
    margin-bottom: 12px;
}
.ai-pay-field label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
}
.ai-pay-req {
    color: var(--danger, #d0021b);
    font-size: 11px;
    margin-right: 4px;
}
.ai-pay-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border-main);
    background: var(--surface-solid, #fff);
    color: var(--text-main);
    font-family: inherit;
    font-size: 13px;
    transition: border-color 0.15s ease;
}
.ai-pay-input:focus {
    outline: none;
    border-color: var(--primary);
}

.ai-pay-error {
    font-size: 12px;
    color: var(--danger, #d0021b);
    background: color-mix(in srgb, var(--danger, #d0021b) 8%, transparent);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 12px;
}

.ai-pay-submit {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: none;
    background: var(--primary);
    color: var(--on-primary, var(--text-light));
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 800;
    cursor: pointer;
    transition: filter 0.15s ease;
}
.ai-pay-submit:hover {
    filter: brightness(1.08);
}
.ai-pay-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ---- حوار إعادة تسمية الجلسة (نفس لغة طبقة الدفع: خلفية ضبابية + بطاقة) ---- */
.ai-rename-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    animation: ai-topup-in 0.16s ease;
}
/* ⚠️ إلزامي: display أعلاه يغلب [hidden] (نفس بعثة ai-pay-overlay) */
.ai-rename-overlay[hidden] {
    display: none;
}
.ai-rename-card {
    width: 400px;
    max-width: 100%;
    background: var(--surface-solid, #fff);
    border: 1px solid var(--border-main);
    border-radius: 16px;
    box-shadow: 0 24px 60px -20px rgba(15, 23, 42, 0.4);
    padding: 20px;
}
.ai-rename-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}
.ai-rename-head strong {
    display: block;
    font-size: 15px;
    font-weight: 800;
    color: var(--text-main);
}
.ai-rename-sub {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary);
}
.ai-rename-icon {
    flex: none;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
}
.ai-rename-close {
    margin-inline-start: auto;
    border: 0;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 6px;
}
.ai-rename-close:hover {
    color: var(--text-main);
    background: var(--surface-hover, rgba(0, 0, 0, 0.05));
}
.ai-rename-input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-main);
    background: var(--surface-main);
    color: var(--text-main);
    font-size: 13.5px;
    font-family: inherit;
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}
.ai-rename-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}
.ai-rename-error {
    margin: 10px 2px 0;
    font-size: 12.5px;
    color: var(--danger, #ef4444);
}
.ai-rename-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}
.ai-rename-cancel {
    padding: 9px 16px;
    border-radius: 10px;
    border: 1px solid var(--border-main);
    background: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition:
        color 0.15s ease,
        border-color 0.15s ease;
}
.ai-rename-cancel:hover {
    color: var(--text-main);
    border-color: var(--text-secondary);
}
.ai-rename-save {
    padding: 9px 18px;
    border-radius: 10px;
    border: 0;
    background: var(--primary);
    color: var(--on-primary, #fff);
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: filter 0.15s ease;
}
.ai-rename-save:hover {
    filter: brightness(1.08);
}
.ai-rename-save:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-pay-footnote {
    display: block;
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 10px;
    line-height: 1.6;
}

@media (max-width: 520px) {
    .ai-pay-methods {
        grid-template-columns: 1fr;
    }
}
