/* ═══════════════════════════════════════════
   CHAT WIDGET — Floating Chat Component
   ═══════════════════════════════════════════ */

/* ═══ Floating Toggle Button ═══ */
.chat-toggle {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--navy, #1f5a37);
    color: #fff;
    border: none;
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(31,90,55,.35);
    transition: all .3s cubic-bezier(.4,0,.2,1);
}
.chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(31,90,55,.45);
}
.chat-toggle svg { width: 24px; height: 24px; }

.chat-toggle .chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid #fff;
    animation: chat-badge-pop .3s cubic-bezier(.4,0,.2,1);
}
@keyframes chat-badge-pop {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* ═══ Chat Panel ═══ */
.chat-panel {
    position: fixed;
    bottom: 96px;
    right: 28px;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 12px 48px rgba(0,0,0,.15), 0 0 0 1px rgba(0,0,0,.05);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: chat-slide-up .3s cubic-bezier(.4,0,.2,1);
    font-family: 'DM Sans', sans-serif;
}
.chat-panel.open {
    display: flex;
}
@keyframes chat-slide-up {
    from { opacity: 0; transform: translateY(20px) scale(.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ═══ Chat Header ═══ */
.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--navy, #1f5a37);
    color: #fff;
    flex-shrink: 0;
}
.chat-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.chat-header-avatar svg { width: 18px; height: 18px; }
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-title {
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-header-status {
    font-size: 11px;
    opacity: .75;
    display: flex;
    align-items: center;
    gap: 5px;
}
.chat-header-status .dot {
    width: 7px; height: 7px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
}
.chat-header-close {
    width: 32px; height: 32px;
    border: none; background: rgba(255,255,255,.15);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s;
    flex-shrink: 0;
}
.chat-header-close:hover { background: rgba(255,255,255,.25); }
.chat-header-close svg { width: 16px; height: 16px; }

/* ═══ Messages Area ═══ */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f8faf9;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

/* Load more */
.chat-load-more {
    text-align: center;
    margin-bottom: 8px;
}
.chat-load-more button {
    border: none;
    background: none;
    color: var(--navy, #1f5a37);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 12px;
    transition: background .2s;
    font-family: inherit;
}
.chat-load-more button:hover { background: rgba(31,90,55,.08); }

/* Date separator */
.chat-date-separator {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    font-weight: 600;
    padding: 8px 0;
    position: relative;
}
.chat-date-separator::before,
.chat-date-separator::after {
    content: '';
    position: absolute;
    top: 50%;
    width: calc(50% - 50px);
    height: 1px;
    background: #e5e7eb;
}
.chat-date-separator::before { left: 0; }
.chat-date-separator::after { right: 0; }

/* ═══ Message Bubble ═══ */
.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}
.chat-msg.sent {
    align-self: flex-end;
}
.chat-msg.received {
    align-self: flex-start;
}

.chat-msg-sender {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 3px;
    padding: 0 4px;
}
.chat-msg.sent .chat-msg-sender { text-align: right; }

.chat-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.55;
    word-break: break-word;
    position: relative;
}
.chat-msg.sent .chat-msg-bubble {
    background: var(--navy, #1f5a37);
    color: #fff;
    border-bottom-right-radius: 6px;
}
.chat-msg.received .chat-msg-bubble {
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 6px;
}

.chat-msg-time {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 3px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.chat-msg.sent .chat-msg-time {
    justify-content: flex-end;
}

.chat-msg-read {
    color: #4ade80;
    display: inline-flex;
}
.chat-msg-read svg { width: 12px; height: 12px; }

/* ═══ Empty State ═══ */
.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #9ca3af;
    padding: 40px;
}
.chat-empty svg {
    width: 48px; height: 48px;
    opacity: .3;
    stroke: currentColor;
}
.chat-empty span { font-size: 13px; font-weight: 500; }

/* ═══ Typing Indicator ═══ */
.chat-typing {
    display: none;
    padding: 4px 16px 8px;
    font-size: 12px;
    color: #1f5a37;
    font-style: italic;
    font-weight: 500;
    animation: chat-typing-fade .5s ease;
    flex-shrink: 0;
}
@keyframes chat-typing-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ═══ Input Area ═══ */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}
.chat-input {
    flex: 1;
    border: 1.5px solid #e5e7eb !important;
    border-radius: 14px !important;
    padding: 10px 14px !important;
    font-size: 13px !important;
    font-family: 'DM Sans', sans-serif !important;
    resize: none;
    outline: none;
    max-height: 80px;
    line-height: 1.4;
    color: #1f2937 !important;
    background: #fff !important;
    transition: border-color .2s;
}
.chat-input:focus {
    border-color: var(--navy, #1f5a37) !important;
}
.chat-input::placeholder { color: #9ca3af !important; }

.chat-send {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: var(--navy, #1f5a37);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    flex-shrink: 0;
}
.chat-send:hover {
    background: #174a2c;
    transform: scale(1.05);
}
.chat-send:disabled {
    opacity: .4;
    cursor: not-allowed;
    transform: none;
}
.chat-send svg { width: 18px; height: 18px; }

/* ═══ Navbar Notification Bell ═══ */
.nav-chat-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(15, 26, 19, .06);
    border: 1px solid rgba(15, 26, 19, .10);
    color: #1f5a37;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
    flex-shrink: 0;
    box-sizing: border-box;
}
.nav-chat-bell:hover {
    background: rgba(31, 90, 55, .12);
    border-color: rgba(31, 90, 55, .25);
    color: #14432a;
}
.nav-chat-bell svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    display: block;
    flex-shrink: 0;
}
.nav-chat-bell.has-notif {
    background: rgba(239, 68, 68, .10);
    border-color: rgba(239, 68, 68, .30);
    color: #b91c1c;
}
.nav-chat-bell.has-notif svg { stroke: #b91c1c; }
.nav-notif-dot {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 9px;
    height: 9px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 0 2px #ffffff;
    animation: chat-badge-pop .3s cubic-bezier(.4,0,.2,1);
    pointer-events: none;
}

/* ═══ Responsive ═══ */
@media (max-width: 768px) {
    .chat-panel {
        width: min(340px, calc(100vw - 32px));
        height: 460px;
        right: 16px;
        bottom: 88px;
    }
    .chat-toggle { width: 48px; height: 48px; bottom: 20px; right: 16px; }
}
@media (max-width: 480px) {
    .chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    .chat-toggle { bottom: 16px; right: 16px; }
}

