/* ─── مساعد بصر الذكي — Premium Enterprise UI ──────────────────────────── */

/* ── FAB ────────────────────────────────────────────────────────────────── */
#ai-fab {
    transition: transform .2s cubic-bezier(.175,.885,.32,1.275), box-shadow .2s;
    animation: ai-fab-pulse 3s ease-in-out infinite;
}
#ai-fab:hover {
    transform: translateY(-3px) scale(1.06);
    box-shadow: 0 10px 30px rgba(220,38,38,.6) !important;
    animation: none;
}
#ai-fab:active { transform: scale(.94); animation: none; }

@keyframes ai-fab-pulse {
    0%, 100% { box-shadow: 0 6px 20px rgba(220,38,38,.45); }
    50%       { box-shadow: 0 6px 28px rgba(220,38,38,.7); }
}

/* ── Panel ──────────────────────────────────────────────────────────────── */
#ai-panel { font-family: var(--font-sans, "Tajawal", "IBM Plex Sans Arabic", sans-serif); }

/* ── Header icon buttons ────────────────────────────────────────────────── */
.ai-hdr-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 8px;
    color: #9ca3af;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
    flex-shrink: 0;
}
.ai-hdr-btn:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

/* ── Send button (icon inside pill input) ────────────────────────────────── */
.ai-send-icon-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #dc2626;
    color: #fff;
    border: none;
    border-radius: 9px;
    margin: 3px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, transform .1s;
}
.ai-send-icon-btn:hover  { background: #b91c1c; }
.ai-send-icon-btn:active { transform: scale(.93); }
.ai-send-icon-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Message bubbles ────────────────────────────────────────────────────── */
.ai-msg-user {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #fff;
    border-radius: 14px 14px 2px 14px;
    padding: .6rem .9rem;
    font-size: .84rem;
    max-width: 80%;
    align-self: flex-start;
    line-height: 1.65;
    word-break: break-word;
    box-shadow: 0 2px 10px rgba(220,38,38,.22);
}
.ai-msg-bot {
    background: #ffffff;
    color: #1f2937;
    border: 1.5px solid #f1f5f9;
    border-radius: 14px 14px 14px 2px;
    padding: .6rem .9rem;
    font-size: .84rem;
    max-width: 90%;
    align-self: flex-end;
    line-height: 1.65;
    word-break: break-word;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.ai-msg-time {
    font-size: .61rem;
    color: #9ca3af;
    margin-top: .2rem;
}

/* ── Welcome screen ─────────────────────────────────────────────────────── */
.ai-welcome-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1rem .75rem;
    text-align: center;
}
.ai-welcome-icon {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    background: linear-gradient(135deg, #dc2626, #991b1b);
    color: #fff;
    font-size: 1.7rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: .9rem;
    box-shadow: 0 6px 20px rgba(220,38,38,.3);
}
.ai-welcome-title {
    font-size: .95rem;
    font-weight: 800;
    color: #111827;
    margin: 0 0 .3rem;
}
.ai-welcome-sub {
    font-size: .76rem;
    color: #6b7280;
    margin: 0 0 1.1rem;
    line-height: 1.5;
}

/* ── Suggestion cards ───────────────────────────────────────────────────── */
.ai-sug-wrap {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    width: 100%;
    padding: 0 .25rem;
}
.ai-sug-card {
    display: flex;
    align-items: center;
    gap: .6rem;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-right: 3px solid #dc2626;
    border-radius: 10px;
    padding: .6rem .8rem;
    font-size: .82rem;
    color: #1f2937;
    cursor: pointer;
    width: 100%;
    font-family: inherit;
    text-align: right;
    transition: background .15s, border-color .15s, transform .15s;
}
.ai-sug-card:hover {
    background: #fef2f2;
    border-color: #dc2626;
    transform: translateX(-3px);
}
.ai-sug-emoji { font-size: 1rem; flex-shrink: 0; }
.ai-sug-text  { flex: 1; text-align: right; font-weight: 500; }
.ai-sug-arrow { color: #dc2626; flex-shrink: 0; opacity: .7; }

/* ── Typing indicator ───────────────────────────────────────────────────── */
.ai-thinking {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: .5rem .7rem;
    background: #fff;
    border: 1.5px solid #f1f5f9;
    border-radius: 14px 14px 14px 2px;
    width: fit-content;
    align-self: flex-end;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.ai-thinking span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #dc2626;
    animation: ai-bounce .9s ease-in-out infinite;
}
.ai-thinking span:nth-child(2) { animation-delay: .18s; }
.ai-thinking span:nth-child(3) { animation-delay: .36s; }

@keyframes ai-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 1; }
    30%            { transform: translateY(-7px); opacity: .7; }
}

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
#ai-messages::-webkit-scrollbar       { width: 4px; }
#ai-messages::-webkit-scrollbar-track { background: transparent; }
#ai-messages::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 4px; }
#ai-messages::-webkit-scrollbar-thumb:hover { background: #dc2626; }

/* ── FAB Badge ──────────────────────────────────────────────────────────── */
#ai-fab-badge {
    display: none;
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
    pointer-events: none;
    line-height: 1;
    animation: ai-badge-pop .3s cubic-bezier(.175,.885,.32,1.275);
}

@keyframes ai-badge-pop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* ── Period Filter Pills ─────────────────────────────────────────────────── */
.ai-period-pill {
    padding: .28rem .65rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 20px;
    background: #fff;
    font-size: .72rem;
    color: #6b7280;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
    flex-shrink: 0;
}
.ai-period-pill:hover { border-color: #dc2626; color: #dc2626; }
.ai-period-active     { background: #dc2626 !important; border-color: #dc2626 !important; color: #fff !important; }

/* ── Insight Card (auto-loaded summary) ─────────────────────────────────── */
.ai-insight-card {
    background: #fff;
    border: 1.5px solid #f1f5f9;
    border-right: 3px solid #dc2626;
    border-radius: 14px 14px 14px 2px;
    overflow: hidden;
    max-width: 96%;
    align-self: flex-end;
    box-shadow: 0 2px 10px rgba(0,0,0,.07);
}
.ai-insight-header {
    background: #111827;
    color: #fff;
    padding: .55rem .85rem;
    font-size: .78rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: .4rem;
}
.ai-insight-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border-bottom: 1px solid #f1f5f9;
}
.ai-insight-metric {
    padding: .65rem .75rem;
    text-align: center;
    border-left: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .15rem;
}
.ai-insight-metric:nth-child(odd) { border-left: none; }
.ai-metric-icon { font-size: 1.1rem; }
.ai-metric-val  { font-size: .88rem; font-weight: 800; color: #111827; }
.ai-metric-lbl  { font-size: .62rem; color: #9ca3af; }
.ai-insight-top-client {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem .85rem;
    font-size: .78rem;
    color: #374151;
    border-bottom: 1px solid #f1f5f9;
    flex-wrap: wrap;
}
.ai-insight-top-client strong { color: #111827; font-weight: 700; }
.ai-insight-amount { color: #dc2626; font-weight: 700; margin-inline-start: auto; }
.ai-insight-alerts {
    padding: .5rem .85rem;
    display: flex;
    flex-direction: column;
    gap: .3rem;
}
.ai-insight-alert-row {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .75rem;
    color: #374151;
    background: #fef2f2;
    padding: .3rem .5rem;
    border-radius: 6px;
}
