/* MediSense chatbot widget */
.medi-chat-fab {
    position: fixed; bottom: 24px; inset-inline-end: 24px;
    width: 60px; height: 60px;
    background: linear-gradient(135deg, #0F5132, #20C997);
    color: #fff;
    border: 0; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 9998;
    box-shadow: 0 16px 32px -10px rgba(15,81,50,0.5);
    transition: transform .2s ease, box-shadow .2s ease;
    font-size: 1.6rem;
}
.medi-chat-fab:hover { transform: scale(1.06); box-shadow: 0 22px 40px -12px rgba(15,81,50,0.6); }
.medi-chat-fab .badge {
    position: absolute; top: -2px; inset-inline-end: -2px;
    width: 16px; height: 16px;
    background: #ef4444; border: 2px solid #fff;
    border-radius: 50%;
    animation: chatBadge 1.2s ease-in-out infinite;
}
@keyframes chatBadge {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.15); }
}

.medi-chat-window {
    position: fixed; bottom: 96px; inset-inline-end: 24px;
    width: 380px; max-width: calc(100vw - 32px);
    height: 560px; max-height: calc(100vh - 130px);
    background: #fff;
    border-radius: 22px; overflow: hidden;
    display: none; flex-direction: column;
    z-index: 9999;
    box-shadow: 0 30px 60px -20px rgba(15,81,50,0.4);
    transform-origin: bottom right;
    animation: chatOpen .25s cubic-bezier(0.16, 1, 0.3, 1);
}
[dir="rtl"] .medi-chat-window { transform-origin: bottom left; }
.medi-chat-window.open { display: flex; }
@keyframes chatOpen {
    from { opacity: 0; transform: translateY(20px) scale(0.94); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.medi-chat-header {
    background: linear-gradient(135deg, #0F5132, #198754);
    color: #fff; padding: 16px 20px;
    display: flex; align-items: center; gap: 12px;
}
.medi-chat-header .avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: rgba(255,255,255,0.18);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
}
.medi-chat-header h3 { margin: 0; font-size: .95rem; font-weight: 700; line-height: 1.3; }
.medi-chat-header p  { margin: 2px 0 0; font-size: .72rem; opacity: .85; }
.medi-chat-header .close {
    margin-inline-start: auto;
    background: rgba(255,255,255,0.2); border: 0;
    color: #fff; cursor: pointer;
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}
.medi-chat-header .close:hover { background: rgba(255,255,255,0.35); }
.medi-chat-header .online {
    width: 8px; height: 8px; border-radius: 50%;
    background: #BEF264; box-shadow: 0 0 8px #BEF264;
    display: inline-block; margin-inline-end: 4px;
}

.medi-chat-body {
    flex: 1; overflow-y: auto;
    padding: 16px;
    background: linear-gradient(180deg, #f7faf8 0%, #ffffff 100%);
    display: flex; flex-direction: column; gap: 10px;
}
.medi-chat-body::-webkit-scrollbar { width: 6px; }
.medi-chat-body::-webkit-scrollbar-thumb { background: rgba(15,81,50,0.2); border-radius: 4px; }

.medi-msg {
    max-width: 80%; padding: 10px 14px;
    border-radius: 16px;
    font-size: .88rem; line-height: 1.55;
    word-wrap: break-word;
}
.medi-msg.user {
    background: linear-gradient(135deg, #0F5132, #198754);
    color: #fff; align-self: flex-end;
    border-bottom-right-radius: 4px;
}
[dir="rtl"] .medi-msg.user { border-bottom-right-radius: 16px; border-bottom-left-radius: 4px; }
.medi-msg.bot {
    background: #fff; color: #1a2e22;
    border: 1px solid #e6efe9;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
[dir="rtl"] .medi-msg.bot { border-bottom-left-radius: 16px; border-bottom-right-radius: 4px; }
.medi-msg.bot a { color: #0F5132; font-weight: 600; }

/* === Product cards === */
.medi-product-stack {
    align-self: stretch;
    display: flex; flex-direction: column; gap: 10px;
    margin-top: 4px;
}
.medi-product-card {
    display: flex; gap: 12px; align-items: center;
    background: #fff;
    border: 1.5px solid #d6e3da;
    border-radius: 16px;
    padding: 12px;
    text-decoration: none;
    color: #0F5132;
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
    position: relative;
    overflow: hidden;
}
.medi-product-card::before {
    content: '';
    position: absolute;
    top: 0; bottom: 0; inset-inline-start: 0;
    width: 4px;
    background: linear-gradient(180deg, #0F5132, #20C997);
    transform: scaleY(0);
    transform-origin: top;
    transition: transform .25s ease;
}
.medi-product-card:hover {
    transform: translateY(-2px);
    border-color: #20C997;
    box-shadow: 0 14px 28px -14px rgba(15,81,50,0.4);
}
.medi-product-card:hover::before { transform: scaleY(1); }

.medi-product-img {
    width: 64px; height: 64px;
    border-radius: 12px;
    background: linear-gradient(160deg, #f7faf8, #e8efeb);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    padding: 6px;
}
.medi-product-img img {
    max-width: 100%; max-height: 100%;
    object-fit: contain;
}

.medi-product-info {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; gap: 3px;
}
.medi-product-name {
    font-weight: 800;
    font-size: .9rem;
    color: #0F5132;
    line-height: 1.3;
}
.medi-product-tagline {
    font-size: .76rem;
    color: #5a7064;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.medi-product-meta {
    display: flex; align-items: center; gap: 8px;
    margin-top: 4px;
}
.medi-product-price {
    background: linear-gradient(135deg, #84CC16, #20C997);
    color: #0F5132;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 800;
}
.medi-product-cat {
    background: rgba(15,81,50,0.08);
    color: #0F5132;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.medi-product-actions {
    display: flex; gap: 4px;
    margin-top: 6px;
}
.medi-product-actions .btn-mini {
    padding: 5px 10px;
    border-radius: 10px;
    font-size: .72rem;
    font-weight: 700;
    text-decoration: none;
    transition: filter .15s ease;
}
.medi-product-actions .btn-mini:hover { filter: brightness(1.05); }
.medi-product-actions .btn-mini.primary {
    background: linear-gradient(135deg, #0F5132, #198754);
    color: #fff;
}
.medi-product-actions .btn-mini.shop {
    background: linear-gradient(135deg, #84CC16, #20C997);
    color: #0F5132;
}
.medi-msg.typing { color: #6b7280; font-style: italic; }

.medi-chat-suggestions {
    padding: 0 16px 12px;
    display: flex; gap: 6px; flex-wrap: wrap;
}
.medi-chip {
    background: #fff; border: 1px solid #d6e3da;
    color: #0F5132;
    padding: 6px 12px; border-radius: 999px;
    font-size: .78rem; cursor: pointer;
    transition: all .2s;
}
.medi-chip:hover { border-color: #20C997; background: #f0faf3; }

.medi-chat-form {
    border-top: 1px solid #e6efe9;
    padding: 12px;
    display: flex; gap: 8px;
    background: #fff;
}
.medi-chat-form input {
    flex: 1; padding: 10px 14px;
    border: 1.5px solid #e6efe9; border-radius: 12px;
    font-size: .9rem; font-family: inherit;
    outline: none;
}
.medi-chat-form input:focus { border-color: #20C997; }
.medi-chat-form button {
    background: linear-gradient(135deg, #0F5132, #198754);
    color: #fff; border: 0;
    padding: 0 18px; border-radius: 12px;
    cursor: pointer; font-weight: 700;
}
.medi-chat-form button:disabled { opacity: .5; cursor: wait; }

.medi-chat-footer {
    text-align: center;
    padding: 6px 12px 10px;
    font-size: .7rem; color: #94a3a3;
    background: #fff;
}

@media (max-width: 480px) {
    .medi-chat-window {
        bottom: 0; inset-inline-end: 0;
        width: 100vw; height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    .medi-chat-fab { bottom: 16px; inset-inline-end: 16px; }
}
