/* ============================================
   ASDP - AI Chat Agent Styles
   Floating assistant widget for all pages
   ============================================ */

/* ---- Floating Action Button ---- */
.chat-fab {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a5276 0%, #0e6655 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    transition: all 0.3s ease;
    animation: chatFabPulse 2.5s infinite;
}

.chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.35);
}

.chat-fab.open {
    animation: none;
    background: #6c757d;
    transform: none;
}

.chat-fab .fab-icon-open,
.chat-fab .fab-icon-close {
    position: absolute;
    transition: all 0.3s ease;
}

.chat-fab .fab-icon-close {
    opacity: 0;
    transform: rotate(-90deg);
}

.chat-fab.open .fab-icon-open {
    opacity: 0;
    transform: rotate(90deg);
}

.chat-fab.open .fab-icon-close {
    opacity: 1;
    transform: rotate(0deg);
}

/* Notification dot */
.chat-fab-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #e74c3c;
    border: 2px solid #fff;
    animation: dotPulse 1.5s infinite;
}

.chat-fab.open .chat-fab-dot {
    display: none;
}

@keyframes chatFabPulse {
    0% { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25), 0 0 0 0 rgba(26, 82, 118, 0.4); }
    70% { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25), 0 0 0 14px rgba(26, 82, 118, 0); }
    100% { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25), 0 0 0 0 rgba(26, 82, 118, 0); }
}

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

/* ---- Chat Window ---- */
.chat-window {
    position: fixed;
    bottom: 96px;
    left: 24px;
    width: 380px;
    height: 520px;
    max-height: 70vh;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.2);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

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

/* ---- Chat Header ---- */
.chat-window-header {
    background: linear-gradient(135deg, #1a5276 0%, #0e6655 100%);
    color: #fff;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    direction: rtl;
}

.chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.chat-header-info {
    flex: 1;
}

.chat-header-info .chat-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.chat-header-info .chat-status {
    font-size: 0.7rem;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-header-info .chat-status .online-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #2ecc71;
    display: inline-block;
}

/* ---- Messages Area ---- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: #f8f9fa;
    direction: ltr;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* ---- Message Bubbles ---- */
.chat-msg {
    max-width: 88%;
    padding: 0.7rem 1rem;
    border-radius: 16px;
    font-size: 0.85rem;
    line-height: 1.6;
    direction: rtl;
    text-align: right;
    word-wrap: break-word;
}

.chat-msg.agent {
    align-self: flex-start;
    background: #fff;
    color: #2c3e50;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
}

.chat-msg.user {
    align-self: flex-end;
    background: #1a5276;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg b, .chat-msg strong {
    font-weight: 700;
}

.chat-msg .msg-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
}

.chat-msg .msg-badge.green { background: #d5f5e3; color: #0e6655; }
.chat-msg .msg-badge.yellow { background: #fef9e7; color: #b7950b; }
.chat-msg .msg-badge.red { background: #fdedec; color: #c0392b; }
.chat-msg .msg-badge.black { background: #eaecee; color: #2c3e50; }
.chat-msg .msg-badge.blue { background: #d6eaf8; color: #1a5276; }
.chat-msg .msg-badge.teal { background: #d1f2eb; color: #0e6655; }

.chat-msg .msg-mini-table {
    width: 100%;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    border-collapse: collapse;
}

.chat-msg .msg-mini-table td {
    padding: 3px 6px;
    border-bottom: 1px solid #f0f0f0;
}

.chat-msg .msg-mini-table td:first-child {
    color: #6c757d;
    white-space: nowrap;
}

/* ---- Typing Indicator ---- */
.chat-typing {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 0.7rem 1.2rem;
    display: none;
    gap: 5px;
    align-items: center;
}

.chat-typing.show {
    display: flex;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #999;
    animation: typingBounce 1.4s infinite ease-in-out;
}

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

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

/* ---- Suggestions (Quick Replies) ---- */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 1rem;
    direction: rtl;
    margin-bottom: 0.5rem;
}

.chat-suggestions:empty {
    display: none;
}

.chat-sug-btn {
    background: #fff;
    border: 1.5px solid #1a5276;
    color: #1a5276;
    padding: 5px 14px;
    border-radius: 20px;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chat-sug-btn:hover {
    background: #1a5276;
    color: #fff;
}

/* ---- Input Area ---- */
.chat-input-area {
    padding: 0.75rem 1rem;
    background: #fff;
    border-top: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    direction: rtl;
}

.chat-input {
    flex: 1;
    border: 1.5px solid #e0e0e0;
    border-radius: 24px;
    padding: 8px 16px;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.88rem;
    outline: none;
    direction: rtl;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #1a5276;
}

.chat-input::placeholder {
    color: #adb5bd;
}

.chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a5276, #0e6655);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.1);
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
    .chat-window {
        left: 8px;
        right: 8px;
        bottom: 88px;
        width: auto;
        height: 75vh;
        max-height: 75vh;
        border-radius: 16px;
    }

    .chat-fab {
        bottom: 16px;
        left: 16px;
        width: 54px;
        height: 54px;
        font-size: 1.4rem;
    }
}

@media (max-width: 768px) {
    .chat-window {
        width: 340px;
    }
}
