/* ================================================
   CHATBOT - المساعد الفلاحي الذكي
   ================================================ */

.acb {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 99999;
    font-family: 'Tajawal', sans-serif;
    direction: rtl;
}

.acb-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3E8E50, #2E7A3E);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 20px rgba(62, 142, 80, 0.4);
    transition: all 0.3s ease;
    position: relative;
}

.acb-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(62, 142, 80, 0.5);
}

.acb-toggle__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: #E53935;
    border-radius: 50%;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.acb-window {
    position: absolute;
    bottom: 72px;
    left: 0;
    width: 380px;
    max-height: 520px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.acb-window--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.acb-header {
    background: linear-gradient(135deg, #2E7A3E, #3E8E50);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    flex-shrink: 0;
}

.acb-header__info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.acb-header__avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.acb-header__name {
    font-size: 16px;
    font-weight: 700;
}

.acb-header__status {
    font-size: 12px;
    color: #C8E6C9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.acb-status-dot {
    width: 7px;
    height: 7px;
    background: #66BB6A;
    border-radius: 50%;
    animation: dotPulse 2s infinite;
}

@keyframes dotPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.acb-header__close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.acb-header__close:hover {
    opacity: 1;
}

.acb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 300px;
    max-height: 360px;
    background: #fafbfc;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.acb-msg {
    display: flex;
    flex-direction: column;
    animation: msgIn 0.3s ease-out;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.acb-msg--bot {
    align-items: flex-start;
}

.acb-msg--user {
    align-items: flex-end;
}

.acb-msg__bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.7;
    word-wrap: break-word;
}

.acb-msg--bot .acb-msg__bubble {
    background: #fff;
    color: #1a1a1a;
    border: 1px solid #e5e7eb;
    border-bottom-right: 4px;
}

.acb-msg--user .acb-msg__bubble {
    background: #3E8E50;
    color: #fff;
    border-bottom-left-radius: 4px;
}

.acb-msg__bubble a {
    color: #3E8E50;
    text-decoration: underline;
    font-weight: 600;
}

.acb-msg--user .acb-msg__bubble a {
    color: #C8E6C9;
}

.acb-msg__bubble strong {
    font-weight: 700;
}

.acb-wa-btn {
    display: inline-block;
    background: #25D366;
    color: #fff !important;
    padding: 8px 20px;
    border-radius: 8px;
    text-decoration: none !important;
    font-weight: 700;
    font-size: 14px;
    margin-top: 8px;
    transition: background 0.2s;
}

.acb-wa-btn:hover {
    background: #128C7E;
    color: #fff !important;
}

.acb-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    max-width: 85%;
}

.acb-quick-btn {
    background: #fff;
    border: 1px solid #3E8E50;
    color: #3E8E50;
    padding: 6px 14px;
    border-radius: 999px;
    font-family: 'Tajawal', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.acb-quick-btn:hover {
    background: #3E8E50;
    color: #fff;
}

.acb-typing .acb-msg__bubble {
    display: flex;
    gap: 4px;
    padding: 14px 20px;
}

.acb-dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typingDot 1.4s ease-in-out infinite;
}

.acb-dot:nth-child(2) { animation-delay: 0.2s; }
.acb-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.acb-input-area {
    display: flex;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    gap: 8px;
    flex-shrink: 0;
}

.acb-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 14px;
    font-family: 'Tajawal', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    direction: rtl;
}

.acb-input:focus {
    border-color: #3E8E50;
}

.acb-send {
    width: 42px;
    height: 42px;
    background: #3E8E50;
    border: none;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    transform: scaleX(-1);
}

.acb-send:hover {
    background: #2E7A3E;
}

/* ============================
   RESPONSIVE
   ============================ */

@media (max-width: 768px) {
    .acb {
        bottom: 16px;
        left: 16px;
        right: 16px;
    }

    .acb-toggle {
        width: 56px;
        height: 56px;
    }

    .acb-window {
        width: calc(100vw - 32px);
        max-height: calc(100vh - 120px);
        left: 0;
        right: 0;
        bottom: 68px;
        border-radius: 16px;
    }

    .acb-messages {
        min-height: 250px;
        max-height: calc(100vh - 260px);
    }

    .acb-input {
        font-size: 16px;
        min-height: 44px;
    }

    .acb-send {
        min-width: 44px;
        min-height: 44px;
    }

    .acb-quick-btn {
        min-height: 36px;
        font-size: 13px;
    }
}

@media (max-width: 360px) {
    .acb-toggle {
        width: 50px;
        height: 50px;
    }

    .acb-msg__bubble {
        font-size: 13px;
        max-width: 90%;
    }

    .acb-header__name {
        font-size: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .acb-toggle,
    .acb-window,
    .acb-msg,
    .acb-dot {
        animation: none !important;
        transition: none !important;
    }
}
