.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.chat-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #0071e3;
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 113, 227, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-button:hover {
    background: #0077ed;
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 113, 227, 0.4);
}

.chat-button.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.chat-window {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 400px;
    height: 600px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(40px) saturate(180%);
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12),
                0 0 2px 1px rgba(255, 255, 255, 0.3) inset,
                0 0 10px 4px rgba(255, 255, 255, 0.1) inset;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(calc(100% + 2rem));
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.4);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.chat-window.mobile-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    margin: 0;
    max-width: 100%;
    max-height: 100%;
    transform: translateY(0);
}

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

.chat-header {
    background: white;
    padding: 16px 20px;
    border-bottom: 1px solid #d2d2d7;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mobile-fullscreen .chat-header {
    padding: max(env(safe-area-inset-top), 16px) 20px 16px;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatars-group {
    display: flex;
    align-items: center;
    position: relative;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border: 2px solid white;
    margin-left: -8px;
    transition: all 0.3s ease;
    overflow: hidden;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-avatar:first-child {
    margin-left: 0;
}

.chat-avatars-group:hover .chat-avatar {
    margin-left: 4px;
}

.chat-avatars-group:hover .chat-avatar:first-child {
    margin-left: 0;
}

.chat-status-indicator {
    width: 10px;
    height: 10px;
    background: #34c759;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.chat-header-title {
    font-size: 17px;
    font-weight: 600;
    color: #1d1d1f;
    letter-spacing: -0.01em;
}

.chat-header-status {
    font-size: 13px;
    color: #86868b;
}

.chat-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #86868b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-close:hover {
    background: #f5f5f7;
    color: #1d1d1f;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f5f7;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

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

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #86868b;
}

.chat-message {
    display: flex;
    animation: messageSlideIn 0.3s ease;
}

.chat-message.system {
    justify-content: center;
    margin: 16px 0;
}

.chat-message.system .chat-message-content {
    background: transparent;
    box-shadow: none;
    padding: 8px 16px;
    text-align: center;
    max-width: 100%;
}

.chat-message.system .chat-message-text {
    color: #86868b;
    font-size: 13px;
    font-weight: 500;
}

.chat-message.system .chat-message-time {
    display: none;
}

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

.chat-message.user {
    justify-content: flex-end;
}

.chat-message.agent {
    justify-content: flex-start;
}

.chat-message-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-message-text {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.user .chat-message-text {
    background: #0071e3;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.agent .chat-message-text {
    background: white;
    color: #1d1d1f;
    border-bottom-left-radius: 4px;
    border: 1px solid #d2d2d7;
}

.chat-message-time {
    font-size: 11px;
    color: #86868b;
    padding: 0 8px;
}

.chat-message.user .chat-message-time {
    text-align: right;
}

.typing-indicator .chat-message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    border: 1px solid #d2d2d7;
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #86868b;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

.chat-input-container {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #d2d2d7;
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.mobile-fullscreen .chat-input-container {
    padding: 16px 20px max(env(safe-area-inset-bottom), 16px);
}

.chat-input {
    flex: 1;
    border: 1px solid #d2d2d7;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease;
    max-height: 120px;
    line-height: 1.5;
}

.chat-input:focus {
    border-color: #0071e3;
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

.chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #0071e3;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send:hover {
    background: #0077ed;
    transform: scale(1.05);
}

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

@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 40px);
        bottom: 20px;
        right: 20px;
    }
    
    .chat-message-content {
        max-width: 85%;
    }
}
