:root {
    --twoma-orange: #ff6b00;
    --twoma-orange-2: #ff9a3d;
    --twoma-navy: #071225;
    --twoma-text: #101828;
    --twoma-bg: #f5f7fb;
    --twoma-border: #e5e7eb;
    --twoma-success: #16a34a;
    --twoma-danger: #ef4444;
}

.twoma-ai,
.twoma-ai * {
    box-sizing: border-box;
    font-family: 'Cairo', system-ui, sans-serif;
}

.twoma-ai-launcher {
    position: fixed;
    left: 24px;
    bottom: 24px;
    z-index: 1080;
    border: 0;
    border-radius: 999px;
    padding: 10px 14px 10px 16px;
    display: inline-grid;
    grid-template-columns: 42px auto;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 10px;
    min-width: 178px;
    color: #fff;
    background: linear-gradient(135deg, var(--twoma-orange), var(--twoma-orange-2));
    box-shadow: 0 20px 50px rgba(255, 107, 0, .35);
    animation: twomaPulse 2.6s ease-in-out infinite;
}

.twoma-ai-launcher__icon {
    grid-row: 1 / 3;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    font-size: 22px;
}

.twoma-ai-launcher span:not(.twoma-ai-launcher__icon) {
    font-weight: 900;
    line-height: 1.1;
}

.twoma-ai-launcher small {
    opacity: .82;
    font-size: 11px;
}

.twoma-ai-launcher::after {
    content: 'اسأل TWOMA AI';
    position: absolute;
    left: 0;
    bottom: calc(100% + 10px);
    padding: 7px 10px;
    border-radius: 999px;
    background: var(--twoma-navy);
    color: #fff;
    font-size: 12px;
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: .18s ease;
    white-space: nowrap;
}

.twoma-ai-launcher:hover::after {
    opacity: 1;
    transform: translateY(0);
}

.twoma-ai-panel {
    position: fixed;
    left: 24px;
    bottom: 24px;
    z-index: 1081;
    width: 420px;
    height: min(720px, calc(100vh - 48px));
    overflow: hidden;
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, .26);
    background: #fff;
    box-shadow: 0 30px 90px rgba(7, 18, 37, .32);
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    opacity: 0;
    transform: translateY(16px) scale(.98);
    transition: opacity .2s ease, transform .2s ease;
}

.twoma-ai-panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.twoma-ai-head {
    min-height: 96px;
    padding: 18px;
    display: grid;
    grid-template-columns: 52px 1fr 42px;
    align-items: center;
    gap: 12px;
    color: #fff;
    background:
        radial-gradient(circle at 20% 0, rgba(255, 107, 0, .35), transparent 34%),
        linear-gradient(135deg, #071225, #122546);
}

.twoma-ai-bot span,
.twoma-ai-head button {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    color: #fff;
    background: rgba(255, 255, 255, .14);
}

.twoma-ai-bot span {
    width: 52px;
    height: 52px;
    border-radius: 20px;
    color: var(--twoma-orange-2);
    font-size: 25px;
}

.twoma-ai-title strong,
.twoma-ai-title small,
.twoma-ai-title em {
    display: block;
}

.twoma-ai-title strong {
    font-size: 20px;
    line-height: 1.1;
}

.twoma-ai-title small {
    margin-top: 4px;
    color: rgba(255, 255, 255, .78);
}

.twoma-ai-title em {
    margin-top: 8px;
    font-size: 12px;
    font-style: normal;
    color: #d1fae5;
}

.twoma-ai-title b {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 5px;
    border-radius: 50%;
    background: var(--twoma-success);
}

.twoma-ai-head button {
    border: 0;
}

.twoma-ai-scroll {
    overflow-y: auto;
    padding: 16px;
    background: var(--twoma-bg);
}

.twoma-ai-welcome__copy {
    padding: 16px;
    border-radius: 22px;
    background: #fff;
    border: 1px solid var(--twoma-border);
}

.twoma-ai-welcome__copy span {
    font-size: 26px;
}

.twoma-ai-welcome__copy h3 {
    margin: 8px 0 5px;
    color: var(--twoma-text);
    font-size: 20px;
}

.twoma-ai-welcome__copy p {
    margin: 0;
    color: #667085;
    line-height: 1.7;
}

.twoma-ai-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.twoma-ai-grid button,
.twoma-ai-context button,
.twoma-ai-chips button,
.twoma-ai-actions button {
    border: 1px solid var(--twoma-border);
    background: #fff;
    color: var(--twoma-text);
    cursor: pointer;
}

.twoma-ai-grid button {
    min-height: 92px;
    padding: 12px;
    border-radius: 18px;
    text-align: right;
    font-weight: 900;
    box-shadow: 0 10px 26px rgba(7, 18, 37, .06);
    transition: .18s ease;
}

.twoma-ai-grid button:hover,
.twoma-ai-context button:hover,
.twoma-ai-chips button:hover,
.twoma-ai-actions button:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 107, 0, .45);
}

.twoma-ai-grid b {
    display: block;
    margin-bottom: 8px;
    font-size: 22px;
}

.twoma-ai-context {
    margin-top: 12px;
    padding: 13px;
    border-radius: 18px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
}

.twoma-ai-context strong,
.twoma-ai-context small {
    display: block;
}

.twoma-ai-context small {
    margin: 5px 0 10px;
    color: #9a3412;
}

.twoma-ai-context button {
    margin: 4px 0 0 6px;
    padding: 7px 10px;
    border-radius: 999px;
    color: #9a3412;
}

.twoma-ai-messages {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.twoma-msg {
    max-width: 90%;
}

.twoma-msg.user {
    justify-self: end;
}

.twoma-msg.assistant {
    justify-self: start;
}

.twoma-bubble {
    padding: 12px 14px;
    border-radius: 18px;
    line-height: 1.75;
    white-space: pre-line;
}

.twoma-msg.user .twoma-bubble {
    color: #fff;
    background: var(--twoma-orange);
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 6px;
}

.twoma-msg.assistant .twoma-bubble {
    color: var(--twoma-text);
    background: #fff;
    border: 1px solid var(--twoma-border);
    border-bottom-right-radius: 18px;
    border-bottom-left-radius: 6px;
}

.twoma-typing {
    display: inline-flex;
    gap: 5px;
}

.twoma-typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--twoma-orange);
    animation: twomaTyping 1s ease-in-out infinite;
}

.twoma-typing i:nth-child(2) { animation-delay: .14s; }
.twoma-typing i:nth-child(3) { animation-delay: .28s; }

.twoma-products,
.twoma-orders {
    display: grid;
    gap: 10px;
    margin-top: 10px;
}

.twoma-product,
.twoma-order {
    padding: 10px;
    border: 1px solid var(--twoma-border);
    border-radius: 18px;
    background: #fff;
}

.twoma-product {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 10px;
}

.twoma-product img {
    width: 72px;
    height: 72px;
    border-radius: 14px;
    object-fit: cover;
    background: #eef2f7;
}

.twoma-product h4,
.twoma-order h4 {
    margin: 0;
    color: var(--twoma-text);
    font-size: 13px;
    line-height: 1.5;
}

.twoma-product p,
.twoma-order p {
    margin: 4px 0 0;
    color: #667085;
    font-size: 12px;
}

.twoma-product .available {
    color: var(--twoma-success);
    font-weight: 900;
}

.twoma-product .unavailable {
    color: var(--twoma-danger);
    font-weight: 900;
}

.twoma-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 9px;
}

.twoma-ai-actions button,
.twoma-actions button,
.twoma-actions a {
    border: 1px solid rgba(255, 107, 0, .32);
    border-radius: 999px;
    background: #fff7ed;
    color: #c2410c;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 900;
    text-decoration: none;
}

.twoma-timeline {
    display: grid;
    gap: 6px;
    margin-top: 10px;
}

.twoma-timeline span {
    color: #667085;
    font-size: 12px;
}

.twoma-timeline span.done {
    color: var(--twoma-success);
    font-weight: 900;
}

.twoma-timeline span.current {
    color: var(--twoma-orange);
}

.twoma-ai-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 14px;
    background: #fff;
    border-top: 1px solid var(--twoma-border);
}

.twoma-ai-chips button {
    flex: 0 0 auto;
    padding: 8px 11px;
    border-radius: 999px;
    color: #344054;
    font-size: 12px;
    font-weight: 800;
}

.twoma-ai-form {
    display: grid;
    grid-template-columns: 1fr 48px;
    gap: 9px;
    padding: 14px;
    background: #fff;
    border-top: 1px solid var(--twoma-border);
}

.twoma-ai-form input {
    min-width: 0;
    height: 48px;
    border: 1px solid var(--twoma-border);
    border-radius: 16px;
    padding: 0 14px;
    outline: none;
    color: var(--twoma-text);
}

.twoma-ai-form input:focus {
    border-color: var(--twoma-orange);
    box-shadow: 0 0 0 4px rgba(255, 107, 0, .12);
}

.twoma-ai-form button {
    border: 0;
    border-radius: 16px;
    background: var(--twoma-orange);
    color: #fff;
}

@keyframes twomaPulse {
    0%, 100% { box-shadow: 0 20px 50px rgba(255, 107, 0, .35); }
    50% { box-shadow: 0 20px 70px rgba(255, 107, 0, .55); }
}

@keyframes twomaTyping {
    0%, 100% { transform: translateY(0); opacity: .45; }
    50% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 640px) {
    .twoma-ai-launcher {
        left: 12px;
        bottom: 12px;
        min-width: 152px;
    }

    .twoma-ai-panel {
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: calc(100vw - 24px);
        height: calc(100vh - 24px);
        border-radius: 24px;
    }
}
