/* Live Chat Widget Styles - Enhanced Version */
#reach-hub-floating-chat {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-size: 14px;
}

/* Chat Trigger Button */
.reach-chat-trigger {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1D77D1 0%, #17345E 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(29, 119, 209, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.reach-chat-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(29, 119, 209, 0.5);
}

.reach-chat-trigger:active {
    transform: scale(0.95);
}

.reach-chat-trigger svg {
    width: 28px;
    height: 28px;
    color: white;
    stroke: white;
}

.reach-chat-trigger .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    border: 2px solid white;
}

/* Chat Panel */
.reach-chat-panel {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 2px 10px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.reach-chat-panel.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Chat Header */
.reach-chat-header {
    background: linear-gradient(135deg, #1D77D1 0%, #17345E 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.reach-chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.reach-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
}

.reach-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.reach-chat-new {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s;
    opacity: 0.8;
}

.reach-chat-new:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
}

.reach-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
}

.reach-chat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.reach-chat-status-connected {
    background: #10b981;
    animation: pulse 2s infinite;
}

.reach-chat-status-disconnected {
    background: #ef4444;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.reach-chat-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s;
}

.reach-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages Area */
.reach-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

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

.reach-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.reach-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.reach-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Message Styles */
.reach-chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* User messages - right aligned */
.reach-chat-message-user {
    align-self: flex-end;
    align-items: flex-end;
}

/* Bot/Agent messages - left aligned */
.reach-chat-message-bot {
    align-self: flex-start;
    align-items: flex-start;
}

/* Message Bubbles */
.reach-chat-message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.reach-chat-bubble-user {
    background: linear-gradient(135deg, #1D77D1 0%, #155a9e 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.reach-chat-bubble-bot {
    background: white;
    color: #1f2937;
    border-bottom-left-radius: 6px;
    border: 1px solid #e5e7eb;
}

.reach-chat-message-text {
    margin: 0;
    font-size: 14px;
}

.reach-chat-message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    padding: 0 4px;
}

.reach-chat-message-time {
    font-size: 11px;
    color: #9ca3af;
}

.reach-chat-message-user .reach-chat-message-time {
    color: #9ca3af;
}

/* Typing Indicator Container */
.reach-chat-typing-container {
    padding: 0 16px;
    min-height: 20px;
}

/* Typing Indicator */
.reach-chat-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
}

.reach-chat-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.reach-chat-typing-dot:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.6;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Human Support Button Bar */
.reach-chat-human-bar {
    padding: 8px 16px;
    background: #f8fafc;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.reach-chat-human-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.reach-chat-human-btn:hover {
    background: linear-gradient(135deg, #047857 0%, #065f46 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.3);
}

.reach-chat-human-btn:active {
    transform: translateY(0);
}

.reach-chat-human-btn svg {
    stroke: white;
    flex-shrink: 0;
}

/* System Messages */
.reach-chat-system-message {
    text-align: center;
    padding: 12px 16px;
    margin: 8px 0;
    background: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
    border-radius: 12px;
    font-size: 13px;
    color: #1e40af;
    line-height: 1.5;
    animation: slideIn 0.3s ease;
}

.reach-chat-system-message a {
    color: #1D77D1;
    text-decoration: underline;
}

.reach-chat-system-message a:hover {
    color: #17345E;
}

/* Message Sender Label */
.reach-chat-message-sender {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Input Area */
.reach-chat-input-area {
    padding: 16px;
    border-top: 1px solid #e5e7eb;
    background: white;
    flex-shrink: 0;
}

.reach-chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.reach-chat-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    min-height: 44px;
    line-height: 1.4;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f9fafb;
}

.reach-chat-input:focus {
    outline: none;
    border-color: #1D77D1;
    box-shadow: 0 0 0 3px rgba(29, 119, 209, 0.15);
    background: white;
}

.reach-chat-input::placeholder {
    color: #9ca3af;
}

.reach-chat-send {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #1D77D1 0%, #155a9e 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.reach-chat-send:hover:not(:disabled) {
    background: linear-gradient(135deg, #155a9e 0%, #17345E 100%);
    transform: scale(1.05);
}

.reach-chat-send:active:not(:disabled) {
    transform: scale(0.95);
}

.reach-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.reach-chat-send svg {
    width: 20px;
    height: 20px;
    stroke: white;
    fill: white;
}

/* Legacy classes for backward compatibility */
.reach-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: slideIn 0.3s ease;
}

.reach-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.reach-message.bot {
    align-self: flex-start;
}

.reach-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.reach-message.user .reach-message-avatar {
    background: #1D77D1;
}

.reach-message.bot .reach-message-avatar {
    background: #6b7280;
}

.reach-message-content {
    background: white;
    padding: 10px 14px;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
    line-height: 1.5;
}

.reach-message.user .reach-message-content {
    background: #1D77D1;
    color: white;
    border-bottom-right-radius: 4px;
}

.reach-message.bot .reach-message-content {
    background: white;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

/* Responsive */
@media (max-width: 640px) {
    #reach-hub-floating-chat {
        bottom: 16px;
        right: 16px;
    }

    .reach-chat-panel {
        width: calc(100vw - 32px);
        right: 16px;
        bottom: 84px;
        height: calc(100vh - 110px);
        max-height: calc(100vh - 110px);
        border-radius: 14px;
    }

    .reach-chat-trigger {
        width: 54px;
        height: 54px;
    }

    .reach-chat-trigger svg {
        width: 24px;
        height: 24px;
    }

    .reach-chat-message {
        max-width: 90%;
    }

    .reach-chat-messages {
        padding: 12px;
        gap: 12px;
    }

    .reach-chat-input-area {
        padding: 12px;
    }

    .reach-chat-input {
        padding: 10px 16px;
    }

    .reach-chat-send {
        width: 40px;
        height: 40px;
    }
}

/* Accessibility */
.reach-chat-trigger:focus-visible,
.reach-chat-close:focus-visible,
.reach-chat-send:focus-visible {
    outline: 2px solid #1D77D1;
    outline-offset: 2px;
}

.reach-chat-input:focus-visible {
    outline: none;
    border-color: #1D77D1;
    box-shadow: 0 0 0 3px rgba(29, 119, 209, 0.2);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

    .reach-chat-panel,
    .reach-chat-trigger,
    .reach-chat-send,
    .reach-chat-message {
        transition: none;
    }

    .reach-chat-status-connected,
    .reach-chat-typing-dot {
        animation: none;
    }
}

/* Loading state */
.reach-chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #6b7280;
    font-size: 14px;
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles if needed */
}