/**
 * Polar Cloud Chat Widget Styles
 */

/* Widget Container */
#polarcloud-chat-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.polarcloud-widget-bottom-right {
    bottom: 20px;
    right: 20px;
}

.polarcloud-widget-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Chat Button */
.polarcloud-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.polarcloud-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.6);
}

.polarcloud-chat-button svg {
    width: 28px;
    height: 28px;
    color: white;
    transition: all 0.3s ease;
}

.polarcloud-icon-chat {
    display: block;
}

.polarcloud-icon-close {
    display: none;
}

.polarcloud-chat-button.polarcloud-open .polarcloud-icon-chat {
    display: none;
}

.polarcloud-chat-button.polarcloud-open .polarcloud-icon-close {
    display: block;
}

/* Notification Badge */
.polarcloud-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 24px;
    height: 24px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
    animation: polarcloud-pulse 2s infinite;
}

@keyframes polarcloud-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Chat Window */
.polarcloud-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    pointer-events: none;
    transition: all 0.3s ease;
}

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

/* Header */
.polarcloud-chat-header {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    padding: 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.polarcloud-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.polarcloud-avatar svg {
    width: 24px;
    height: 24px;
}

.polarcloud-header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.polarcloud-status {
    font-size: 13px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
}

.polarcloud-minimize-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.polarcloud-minimize-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.polarcloud-minimize-button svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Messages Container */
.polarcloud-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

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

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

/* Messages */
.polarcloud-message {
    display: flex;
    animation: polarcloud-message-appear 0.3s ease;
}

@keyframes polarcloud-message-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.polarcloud-message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    overflow-x: hidden;
}

.polarcloud-message-user .polarcloud-message-content {
    background: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

.polarcloud-message-bot .polarcloud-message-content {
    background: white;
    color: #2d3748;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Sources */
.polarcloud-sources {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
    font-size: 13px;
    word-break: break-word;
    overflow-wrap: break-word;
}

.polarcloud-sources strong {
    color: #4a5568;
    display: block;
    margin-bottom: 6px;
}

.polarcloud-sources a {
    color: #007bff;
    text-decoration: none;
    display: inline-block;
    margin-bottom: 4px;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.polarcloud-sources a:hover {
    text-decoration: underline;
}

/* Typing Indicator */
.polarcloud-typing {
    display: flex;
    gap: 4px;
    padding: 0 20px 10px 20px;
    align-items: center;
}

.polarcloud-typing-dot {
    width: 8px;
    height: 8px;
    background: #cbd5e0;
    border-radius: 50%;
    animation: polarcloud-typing-bounce 1.4s infinite;
}

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

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

@keyframes polarcloud-typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Input Area */
.polarcloud-chat-input {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
    align-items: flex-end;
}

.polarcloud-input-field {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color 0.2s;
}

.polarcloud-input-field:focus {
    outline: none;
    border-color: #007bff;
}

.polarcloud-input-field::-webkit-scrollbar {
    width: 4px;
}

.polarcloud-input-field::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}

.polarcloud-send-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #007bff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.polarcloud-send-button:hover {
    background: #0056b3;
    transform: scale(1.05);
}

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

.polarcloud-send-button svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Footer */
.polarcloud-chat-footer {
    padding: 12px 20px;
    text-align: center;
    font-size: 12px;
    color: #718096;
    background: white;
    border-radius: 0 0 16px 16px;
    border-top: 1px solid #e2e8f0;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .polarcloud-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 20px;
    }
    
    .polarcloud-widget-bottom-left .polarcloud-chat-window {
        left: 20px;
        right: auto;
    }
}

/* Accessibility */
.polarcloud-chat-button:focus,
.polarcloud-send-button:focus,
.polarcloud-minimize-button:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Animations */
@keyframes polarcloud-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Message Templates */
.polarcloud-templates {
    padding: 15px;
    background: #f7fafc;
    border-top: 1px solid #e2e8f0;
    animation: polarcloud-fade-in 0.3s ease;
}

.polarcloud-templates-title {
    font-size: 0.85em;
    color: #718096;
    margin-bottom: 10px;
    font-weight: 600;
}

.polarcloud-templates-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.polarcloud-template-chip {
    background: white;
    border: 1px solid #cbd5e0;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.9em;
    color: #2d3748;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.polarcloud-template-chip:hover {
    background: #007bff;
    color: white;
    border-color: #007bff;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.polarcloud-template-chip:active {
    transform: translateY(0);
}

@keyframes polarcloud-fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
