/* ============================================================
   ARLA - AI Chatbot Styles (Self-contained)
   Colors: --primary #0b2559, --accent #f59e0b, --chat-green #4db748
   ============================================================ */

:root {
    --arla-primary: #0b2559;
    --arla-primary-light: #163a6e;
    --arla-accent: #f59e0b;
    --arla-green: #4db748;
    --arla-green-dark: #3a9e36;
    --arla-red: #ef4444;
    --arla-purple: #a855f7;
    --arla-indigo: #6366f1;
    --arla-bg: #f8fafc;
    --arla-border: #e2e8f0;
    --arla-text: #1e293b;
    --arla-text-muted: #94a3b8;
    --arla-text-secondary: #64748b;
    --arla-white: #ffffff;
    --arla-shadow: rgba(11,37,89,0.25);
    --arla-radius: 16px;
    --arla-transition: 0.3s cubic-bezier(0.25,0.8,0.25,1);
}

/* ===== FLOATING BUTTON ===== */
#arla-chat-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 62px;
    height: 62px;
    background: linear-gradient(135deg, var(--arla-green), var(--arla-green-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--arla-white);
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(77,183,72,0.45);
    z-index: 9999;
    transition: transform 0.25s, box-shadow 0.25s;
    animation: arlaPulse 2s infinite;
    border: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}
#arla-chat-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(77,183,72,0.6);
}
#arla-chat-btn.arla-open {
    animation: none;
    background: linear-gradient(135deg, var(--arla-primary), var(--arla-primary-light));
    box-shadow: 0 4px 20px var(--arla-shadow);
}
@keyframes arlaPulse {
    0%   { box-shadow: 0 4px 20px rgba(77,183,72,0.45); }
    50%  { box-shadow: 0 4px 30px rgba(77,183,72,0.7), 0 0 0 12px rgba(77,183,72,0.15); }
    100% { box-shadow: 0 4px 20px rgba(77,183,72,0.45); }
}

/* ===== BADGE ===== */
.arla-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--arla-red);
    color: var(--arla-white);
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--arla-white);
    transition: transform 0.3s;
}
.arla-badge.arla-badge-hidden {
    transform: scale(0);
}

/* ===== CHAT WINDOW ===== */
#arla-chat-modal {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 400px;
    height: 560px;
    background: var(--arla-white);
    border-radius: var(--arla-radius);
    box-shadow: 0 10px 50px var(--arla-shadow);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s, transform var(--arla-transition);
    transform-origin: bottom right;
}
#arla-chat-modal.arla-hidden {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    pointer-events: none;
}
#arla-chat-modal.arla-visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

/* ===== HEADER ===== */
.arla-header {
    background: linear-gradient(135deg, var(--arla-primary), var(--arla-primary-light));
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.arla-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.arla-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--arla-green), var(--arla-green-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.8rem;
    color: var(--arla-white);
    flex-shrink: 0;
    position: relative;
}
.arla-avatar::after {
    content: '';
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    background: var(--arla-green);
    border-radius: 50%;
    border: 2px solid var(--arla-primary);
    animation: arlaDotPulse 1.5s infinite;
}
.arla-title {
    color: var(--arla-white);
    font-weight: 700;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 6px;
}
.arla-ia-badge {
    background: linear-gradient(135deg, var(--arla-purple), var(--arla-indigo));
    font-size: 0.55rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--arla-white);
}
.arla-status {
    color: rgba(255,255,255,0.7);
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    gap: 5px;
}
@keyframes arlaDotPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}
.arla-header-actions {
    display: flex;
    gap: 6px;
}
.arla-hdr-btn {
    background: rgba(255,255,255,0.12);
    border: none;
    color: var(--arla-white);
    font-size: 0.85rem;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.arla-hdr-btn:hover {
    background: rgba(255,255,255,0.25);
}

/* ===== MESSAGES AREA ===== */
.arla-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
    background: var(--arla-bg);
}
.arla-messages::-webkit-scrollbar {
    width: 5px;
}
.arla-messages::-webkit-scrollbar-track {
    background: transparent;
}
.arla-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* ===== MESSAGE BUBBLES ===== */
.arla-msg {
    display: flex;
    gap: 8px;
    animation: arlaMsgIn 0.3s ease;
    max-width: 100%;
}
.arla-msg.user {
    flex-direction: row-reverse;
}
@keyframes arlaMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.arla-msg-avatar {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--arla-green), var(--arla-green-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    font-weight: 800;
    color: var(--arla-white);
    flex-shrink: 0;
    margin-top: 2px;
}
.arla-msg.user .arla-msg-avatar {
    background: linear-gradient(135deg, var(--arla-primary), var(--arla-primary-light));
}
.arla-msg-content {
    max-width: 82%;
}
.arla-msg-bubble {
    padding: 10px 14px;
    font-size: 0.84rem;
    line-height: 1.55;
    color: var(--arla-text);
    border-radius: 14px 14px 14px 4px;
    background: var(--arla-white);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.arla-msg.user .arla-msg-bubble {
    background: linear-gradient(135deg, var(--arla-green), var(--arla-green-dark));
    color: var(--arla-white);
    border-radius: 14px 14px 4px 14px;
    box-shadow: 0 1px 3px rgba(77,183,72,0.3);
}
.arla-msg-bubble a {
    color: var(--arla-green);
    text-decoration: underline;
    font-weight: 600;
}
.arla-msg.user .arla-msg-bubble a {
    color: var(--arla-white);
}
.arla-msg-bubble strong {
    font-weight: 700;
}
.arla-msg-time {
    font-size: 0.62rem;
    color: var(--arla-text-muted);
    margin-top: 3px;
    padding: 0 4px;
}
.arla-msg.user .arla-msg-time {
    text-align: right;
}

/* ===== RICH RESPONSE CARDS ===== */
/* Payment cards */
.arla-msg-bubble .si-pay-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    margin: 6px 0;
    font-size: 0.8rem;
    font-weight: 600;
}
.si-pay-card.mtn {
    background: #fffbe6;
    border: 1.5px solid #ffcc00;
    color: #a68600;
}
.si-pay-card.orange {
    background: #fff5eb;
    border: 1.5px solid #ff6600;
    color: #e55d00;
}
.si-pay-card.cash {
    background: #f0f4f8;
    border: 1.5px solid var(--arla-text-muted);
    color: #475569;
}

/* Contact cards */
.arla-msg-bubble .si-contact-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f0f4f8;
    border-radius: 8px;
    margin: 5px 0;
    text-decoration: none;
    color: var(--arla-primary);
    font-size: 0.8rem;
    font-weight: 600;
    border: 1.5px solid var(--arla-border);
    transition: all 0.2s;
}
.si-contact-card:hover {
    border-color: var(--arla-green);
    background: #f0fdf4;
}
.si-contact-card i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

/* Delivery table */
.arla-msg-bubble .si-delivery-table {
    width: 100%;
    border-collapse: collapse;
    margin: 6px 0;
    font-size: 0.78rem;
}
.si-delivery-table th,
.si-delivery-table td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid var(--arla-border);
}
.si-delivery-table th {
    background: #f0f4f8;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--arla-text-secondary);
}
.si-delivery-table td {
    color: var(--arla-text);
}

/* Service grid */
.arla-msg-bubble .si-svc-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: 8px 0;
}
.si-svc-grid a {
    display: inline-block;
    padding: 5px 10px;
    background: #f0f4f8;
    border: 1.5px solid var(--arla-border);
    border-radius: 20px;
    font-size: 0.72rem;
    color: var(--arla-primary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
}
.si-svc-grid a:hover {
    border-color: var(--arla-green);
    background: #f0fdf4;
    color: var(--arla-green-dark);
}

/* Product card in responses */
.arla-msg-bubble .si-product-card {
    display: flex;
    gap: 10px;
    padding: 10px;
    background: #f8fafc;
    border: 1.5px solid var(--arla-border);
    border-radius: 10px;
    margin: 6px 0;
    text-decoration: none;
    color: var(--arla-text);
    transition: all 0.2s;
}
.si-product-card:hover {
    border-color: var(--arla-green);
    box-shadow: 0 2px 8px rgba(77,183,72,0.15);
}
.si-product-card .si-pc-info {
    flex: 1;
}
.si-product-card .si-pc-name {
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--arla-primary);
}
.si-product-card .si-pc-price {
    font-weight: 700;
    color: var(--arla-green);
    font-size: 0.85rem;
}

/* ===== QUICK REPLY SUGGESTIONS ===== */
.arla-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 2px 0 4px 36px;
}
.arla-suggestions button {
    background: var(--arla-white);
    border: 1.5px solid var(--arla-green);
    color: var(--arla-green-dark);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: inherit;
}
.arla-suggestions button:hover {
    background: var(--arla-green);
    color: var(--arla-white);
}

/* ===== TYPING INDICATOR ===== */
.arla-typing {
    display: flex;
    gap: 8px;
    padding: 0 0 4px 0;
    animation: arlaMsgIn 0.3s ease;
}
.arla-typing-dots {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--arla-white);
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.arla-typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--arla-text-muted);
    border-radius: 50%;
    animation: arlaBounce 1.4s infinite;
}
.arla-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.arla-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes arlaBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-6px); }
}

/* ===== INPUT AREA ===== */
.arla-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--arla-border);
    background: var(--arla-white);
    flex-shrink: 0;
}
.arla-input {
    flex: 1;
    border: 1.5px solid var(--arla-border);
    border-radius: 24px;
    padding: 9px 16px;
    font-size: 0.84rem;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    color: var(--arla-text);
}
.arla-input:focus {
    border-color: var(--arla-green);
}
.arla-input::placeholder {
    color: var(--arla-text-muted);
}
.arla-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--arla-green), var(--arla-green-dark));
    color: var(--arla-white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}
.arla-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 2px 10px rgba(77,183,72,0.4);
}

/* ===== FOOTER ===== */
.arla-footer {
    text-align: center;
    font-size: 0.6rem;
    color: var(--arla-text-muted);
    padding: 4px;
    background: var(--arla-white);
    border-top: 1px solid #f1f5f9;
    flex-shrink: 0;
}

/* ===== WELCOME BUTTONS ===== */
.arla-welcome-btns {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}
.arla-welcome-btns button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid var(--arla-border);
    background: var(--arla-white);
    color: var(--arla-primary);
    text-align: left;
    transition: all 0.2s;
    font-family: inherit;
}
.arla-welcome-btns button:hover {
    border-color: var(--arla-green);
    background: #f0fdf4;
}
.arla-welcome-btns button i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    color: var(--arla-green);
}

/* ===== FEEDBACK BUTTONS ===== */
.arla-feedback {
    display: flex;
    gap: 4px;
    padding: 2px 4px;
    margin-top: 4px;
}
.arla-feedback button {
    background: transparent;
    border: 1px solid var(--arla-border);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--arla-text-muted);
}
.arla-feedback button:hover {
    border-color: var(--arla-green);
    color: var(--arla-green);
}
.arla-feedback button.active {
    background: var(--arla-green);
    color: var(--arla-white);
    border-color: var(--arla-green);
}

/* ===== CONFIDENCE INDICATOR ===== */
.arla-confidence {
    font-size: 0.58rem;
    color: var(--arla-text-muted);
    padding: 0 4px;
    display: flex;
    align-items: center;
    gap: 3px;
}
.arla-confidence-bar {
    width: 40px;
    height: 3px;
    background: var(--arla-border);
    border-radius: 2px;
    overflow: hidden;
}
.arla-confidence-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s;
}
.arla-confidence-fill.high { background: var(--arla-green); }
.arla-confidence-fill.medium { background: var(--arla-accent); }
.arla-confidence-fill.low { background: var(--arla-red); }

/* ===== ESCALATION BANNER ===== */
.arla-escalation {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 1.5px solid var(--arla-accent);
    border-radius: 10px;
    margin: 8px 0;
    font-size: 0.8rem;
    color: #92400e;
}
.arla-escalation i {
    font-size: 1.1rem;
    color: var(--arla-accent);
}
.arla-escalation a {
    color: #92400e;
    font-weight: 700;
    text-decoration: underline;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    #arla-chat-modal {
        width: 100vw;
        height: 100vh;
        right: 0;
        bottom: 0;
        border-radius: 0;
        max-height: 100vh;
    }
    #arla-chat-btn {
        bottom: 18px;
        right: 18px;
        width: 54px;
        height: 54px;
        font-size: 1.3rem;
    }
    .arla-messages {
        padding: 12px;
    }
    .arla-msg-content {
        max-width: 88%;
    }
}
@media (min-width: 481px) and (max-width: 640px) {
    #arla-chat-modal {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 90px;
        height: 70vh;
    }
}
@media (min-width: 641px) and (max-width: 768px) {
    #arla-chat-modal {
        width: 380px;
        height: 520px;
    }
}
