/* Eastport Emerald — Chat Widget */

.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, sans-serif;
}

/* Floating button */
.chat-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1B4D3E 0%, #2d7a65 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(27, 77, 62, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.chat-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(27, 77, 62, 0.5);
}

.chat-btn svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

.chat-btn .chat-close {
    display: none;
    font-size: 24px;
    color: #fff;
    line-height: 1;
}

.chat-widget.open .chat-btn svg { display: none; }
.chat-widget.open .chat-btn .chat-close { display: block; }

/* Unread badge */
.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    border-radius: 50%;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

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

/* Chat panel */
.chat-panel {
    display: none;
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 380px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    flex-direction: column;
}

.chat-widget.open .chat-panel {
    display: flex;
}

/* Panel header */
.chat-header {
    background: linear-gradient(135deg, #1B4D3E 0%, #2d7a65 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.chat-header-info h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
}

.chat-header-info p {
    font-size: 0.75rem;
    opacity: 0.8;
    margin: 2px 0 0;
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 280px;
    max-height: 360px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.45;
    word-wrap: break-word;
}

.chat-msg.assistant {
    background: #f0fdf4;
    color: #1a1a2e;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

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

.chat-msg.system {
    background: #fef3c7;
    color: #92400e;
    align-self: center;
    text-align: center;
    font-size: 0.8rem;
    border-radius: 8px;
}

/* Typing indicator */
.chat-typing {
    display: none;
    align-self: flex-start;
    padding: 12px 16px;
    background: #f0fdf4;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.chat-typing.show { display: flex; gap: 4px; }

.typing-dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typingBounce 1.2s infinite;
}

.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; }
}

/* Input area */
.chat-input-area {
    display: flex;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: #fafafa;
    gap: 8px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 80px;
    line-height: 1.4;
}

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

.chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #1B4D3E;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.chat-send:hover { background: #164034; }
.chat-send:disabled { background: #94a3b8; cursor: not-allowed; }

.chat-send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* History button in header */
.chat-history-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    flex-shrink: 0;
    transition: background 0.15s;
}
.chat-history-btn:hover { background: rgba(255,255,255,0.3); }

/* Past conversations list */
.chat-past-header {
    font-weight: 600;
    font-size: 0.95rem;
    padding: 8px 0 12px;
    color: #1B4D3E;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 8px;
}

.chat-past-item {
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.chat-past-item:hover { border-color: #1B4D3E; background: #f0fdf4; }
.chat-past-item.current { border-color: #1B4D3E; background: #f0fdf4; }

.chat-past-date { font-size: 0.75rem; color: #999; margin-bottom: 4px; }
.chat-past-preview { font-size: 0.85rem; color: #333; line-height: 1.4; }
.chat-past-meta { font-size: 0.7rem; color: #999; margin-top: 4px; }

.chat-past-back {
    text-align: center;
    padding: 12px;
    color: #1B4D3E;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 8px;
}
.chat-past-back:hover { text-decoration: underline; }

.chat-past-loading, .chat-past-empty {
    text-align: center;
    padding: 24px;
    color: #999;
    font-size: 0.9rem;
}

.chat-past-view-header {
    padding: 8px 0 12px;
    font-size: 0.85rem;
    color: #666;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 8px;
}
.chat-past-view-back {
    color: #1B4D3E;
    font-weight: 600;
    cursor: pointer;
    margin-right: 8px;
}
.chat-past-view-back:hover { text-decoration: underline; }

/* Chat links */
.chat-date-link {
    display: inline-block;
    background: #1B4D3E;
    color: #fff;
    padding: 3px 10px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: background 0.15s;
}

.chat-date-link:hover {
    background: #164034;
    text-decoration: none;
}

.chat-call-link {
    color: #1B4D3E;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.chat-call-link:hover {
    text-decoration: underline;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .chat-panel {
        width: calc(100vw - 32px);
        right: -8px;
        bottom: 68px;
        max-height: calc(100vh - 120px);
    }
    .chat-widget { bottom: 16px; right: 16px; }
}
