/* Chat Widget Modern Styles */
:root {
    --cw-primary-color: #007bff;
    --cw-secondary-color: #6c757d;
    --cw-success-color: #28a745;
    --cw-danger-color: #dc3545;
    --cw-warning-color: #ffc107;
    --cw-info-color: #17a2b8;
    --cw-light-color: #f8f9fa;
    --cw-dark-color: #343a40;
    --cw-white: #ffffff;
    --cw-shadow: rgba(0, 0, 0, 0.15);
    --cw-border-radius: 12px;
    --cw-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-widget-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    position: fixed;
    z-index: 9999;
    user-select: none;
    pointer-events: none;
}

.chat-widget-container * {
    pointer-events: auto;
}

/* Position Classes */
.cw-bottom-right {
    bottom: 20px;
    right: 20px;
}

.cw-bottom-left {
    bottom: 20px;
    left: 20px;
}

.cw-top-right {
    top: 20px;
    right: 20px;
}

.cw-top-left {
    top: 20px;
    left: 20px;
}

/* Chat Bubble */
.chat-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cw-primary-color), #0056b3);
    color: var(--cw-white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px var(--cw-shadow);
    transition: var(--cw-transition);
    border: none;
    overflow: hidden;
    z-index: 9998;
}

.chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px var(--cw-shadow);
}

.chat-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.chat-bubble:hover::before {
    left: 100%;
}

.chat-bubble-icon {
    font-size: 24px;
    transition: var(--cw-transition);
}

.chat-bubble.minimized .chat-bubble-icon {
    transform: rotate(45deg);
}

/* Chat Widget */
.chat-widget {
    background: var(--cw-white);
    border-radius: var(--cw-border-radius);
    box-shadow: 0 10px 40px var(--cw-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--cw-transition);
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    visibility: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-widget.open {
    opacity: 1;
    transform: scale(1) translateY(0);
    visibility: visible;
}

.chat-widget.minimized {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    visibility: hidden;
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, var(--cw-primary-color), #0056b3);
    color: var(--cw-white);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.chat-header:hover::before {
    transform: translateX(100%);
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-controls {
    display: flex;
    gap: 8px;
}

.chat-control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: var(--cw-white);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--cw-transition);
    font-size: 14px;
}

.chat-control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    max-height: 400px;
    scroll-behavior: smooth;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: var(--cw-light-color);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--cw-secondary-color);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--cw-dark-color);
}

/* Message Styles */
.message {
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease;
}

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

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

.user-message .message-content {
    background: linear-gradient(135deg, var(--cw-primary-color), #0056b3);
    color: var(--cw-white);
    border-bottom-right-radius: 6px;
}

.bot-message {
    display: flex;
    justify-content: flex-start;
}

.bot-message .message-content {
    background: var(--cw-light-color);
    color: var(--cw-dark-color);
    border-bottom-left-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.message-time {
    font-size: 11px;
    color: var(--cw-secondary-color);
    margin-top: 4px;
    text-align: center;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--cw-light-color);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    max-width: 80%;
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease;
}

.typing-text {
    font-size: 14px;
    color: var(--cw-secondary-color);
}

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

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--cw-secondary-color);
    animation: typingDot 1.4s infinite ease-in-out;
}

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

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

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

/* Input Area */
.chat-input {
    padding: 16px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    background: var(--cw-white);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input-field {
    flex: 1;
    border: 2px solid var(--cw-light-color);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    resize: none;
    outline: none;
    transition: var(--cw-transition);
    min-height: 20px;
    max-height: 100px;
    font-family: inherit;
}

.chat-input-field:focus {
    border-color: var(--cw-primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.chat-send-btn {
    background: linear-gradient(135deg, var(--cw-primary-color), #0056b3);
    color: var(--cw-white);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--cw-transition);
    font-size: 16px;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 12px var(--cw-shadow);
}

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

/* Resize Handles */
.resize-handle {
    position: absolute;
    background: transparent;
}

.resize-handle-se {
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: se-resize;
}

.resize-handle-se::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-bottom: 8px solid var(--cw-secondary-color);
    opacity: 0.5;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@keyframes typingDot {

    0%,
    80%,
    100% {
        opacity: 0.3;
        transform: scale(0.8);
    }

    40% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(0, 123, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0);
    }
}

/* Theme Variations */
.cw-theme-dark {
    --cw-white: #2d3748;
    --cw-light-color: #4a5568;
    --cw-dark-color: #e2e8f0;
    --cw-shadow: rgba(0, 0, 0, 0.3);
}

.cw-theme-minimal {
    --cw-border-radius: 4px;
    --cw-shadow: rgba(0, 0, 0, 0.1);
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-bubble {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    .chat-widget {
        position: fixed !important;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100% !important;
        height: 70vh !important;
        border-radius: var(--cw-border-radius) var(--cw-border-radius) 0 0;
        transform: translateY(100%);
    }

    .chat-widget.open {
        transform: translateY(0);
    }

    .chat-bubble {
        position: fixed;
        bottom: 20px;
        right: 20px;
    }
}

/* Status Indicator */
.chat-status {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--cw-success-color);
    border: 2px solid var(--cw-white);
    animation: pulse 2s infinite;
}

/* Accessibility */
.chat-widget:focus-within {
    outline: 2px solid var(--cw-primary-color);
    outline-offset: 2px;
}

.chat-control-btn:focus,
.chat-send-btn:focus,
.chat-input-field:focus {
    outline: 2px solid var(--cw-primary-color);
    outline-offset: 2px;
}

/* Loading State */
.chat-widget.loading {
    opacity: 0.7;
    pointer-events: none;
}

.chat-widget.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--cw-secondary-color);
}