/**
 * SmartSite Chat AI Widget Styles
 */

/* Chat Button */
.smartsite-chat-button {
    position: fixed;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #EFC94C;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 9999;
    border: none;
    outline: none;
}

.smartsite-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.smartsite-chat-button.active {
    transform: scale(0.9);
}

/* Button Positions */
.smartsite-chat-button.bottom-right {
    bottom: 20px;
    right: 20px;
}

.smartsite-chat-button.bottom-left {
    bottom: 20px;
    left: 20px;
}

.smartsite-chat-button.top-right {
    top: 20px;
    right: 20px;
}

.smartsite-chat-button.top-left {
    top: 20px;
    left: 20px;
}

/* Chat Window */
.smartsite-chat-window {
    position: fixed;
    width: 420px;
    height: 620px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8) translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #e0e0e0;
    overflow: hidden;
}

.smartsite-chat-window.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

/* Chat Window Positions */
.smartsite-chat-window.bottom-right {
    bottom: 90px;
    right: 20px;
}

.smartsite-chat-window.bottom-left {
    bottom: 90px;
    left: 20px;
}

.smartsite-chat-window.top-right {
    top: 90px;
    right: 20px;
}

.smartsite-chat-window.top-left {
    top: 90px;
    left: 20px;
}

/* Chat Header */
.smartsite-chat-header {
    background: linear-gradient(135deg, #EFC94C 0%, #FFA62B 100%);
    color: white;
    padding: 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.smartsite-chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbox-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.smartsite-chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.smartsite-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chat Messages */
.smartsite-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: linear-gradient(180deg, #f8f9fa 0%, #ffffff 100%);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.smartsite-message {
    max-width: 85%;
    word-wrap: break-word;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    align-self: flex-end;
}

.user-message .message-content {
    background: linear-gradient(135deg, #0073aa 0%, #005177 100%);
    color: white;
    padding: 14px 18px;
    border-radius: 18px 18px 4px 18px;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.3);
}

.ai-message {
    align-self: flex-start;
}

.ai-message .message-content {
    background: linear-gradient(135deg, #FFA62B 0%, #FF8A00 100%);
    color: white;
    padding: 14px 18px;
    border-radius: 18px 18px 18px 4px;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(255, 166, 43, 0.3);
}

/* Message Sources */
.message-sources {
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 12px;
}

.message-sources ul {
    margin: 5px 0 0 0;
    padding-left: 15px;
}

.message-sources li {
    margin-bottom: 5px;
}

.message-sources a {
    color: white;
    text-decoration: underline;
}

.message-sources a:hover {
    text-decoration: none;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Chat Input */
.smartsite-chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
    border-radius: 0 0 12px 12px;
    display: flex;
    gap: 10px;
}

.smartsite-chat-input {
    flex: 1;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    padding: 12px 20px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f8f9fa;
}

.smartsite-chat-input:focus {
    border-color: #EFC94C;
    background: white;
    box-shadow: 0 0 0 4px rgba(239, 201, 76, 0.1);
}

.smartsite-chat-send {
    background: linear-gradient(135deg, #EFC94C 0%, #FFA62B 100%);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(239, 201, 76, 0.4);
}

.smartsite-chat-send:hover {
    background: linear-gradient(135deg, #FFA62B 0%, #FF8A00 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(239, 201, 76, 0.5);
}

.smartsite-chat-send:active {
    transform: translateY(0);
}

.smartsite-chat-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .smartsite-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        max-height: 600px;
    }
    
    .smartsite-chat-window.bottom-right,
    .smartsite-chat-window.bottom-left {
        bottom: 90px;
        left: 20px;
        right: 20px;
    }
    
    .smartsite-chat-window.top-right,
    .smartsite-chat-window.top-left {
        top: 90px;
        left: 20px;
        right: 20px;
    }
    
    .smartsite-chat-button {
        width: 50px;
        height: 50px;
    }
    
    .smartsite-chat-button svg {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 480px) {
    .smartsite-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        left: 10px !important;
        right: 10px !important;
    }
    
    .smartsite-chat-messages {
        padding: 15px;
    }
    
    .smartsite-chat-input-container {
        padding: 15px;
    }
    
    .smartsite-chat-send {
        padding: 12px 16px;
        font-size: 13px;
    }
}

/* Scrollbar Styling */
.smartsite-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.smartsite-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.smartsite-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.smartsite-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Link Styling */
.smartsite-message a,
.smartsite-message .chat-link {
    color: inherit;
    text-decoration: underline;
    word-break: break-all;
}

.smartsite-message a:hover,
.smartsite-message .chat-link:hover {
    text-decoration: none;
    opacity: 0.8;
}

/* List Styling */
.smartsite-message .chat-list {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}

.smartsite-message .chat-list-item {
    padding: 5px 0;
    line-height: 1.6;
    position: relative;
    padding-left: 20px;
}

.smartsite-message .chat-list-item:before {
    content: "•";
    position: absolute;
    left: 0;
    font-weight: bold;
}

/* Ensure links in lists don't break */
.smartsite-message .chat-list-item .chat-link {
    display: inline-block;
    margin-left: 5px;
}

/* Loading State */
.smartsite-chat-window.loading .smartsite-chat-send {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Dark Theme */
.smartsite-chat-window.theme-dark {
    background: #1e1e1e;
    border-color: #2d2d2d;
}

.smartsite-chat-window.theme-dark .smartsite-chat-messages {
    background: linear-gradient(180deg, #1e1e1e 0%, #2d2d2d 100%);
}

.smartsite-chat-window.theme-dark .smartsite-chat-header {
    background: linear-gradient(135deg, #2d2d2d 0%, #3d3d3d 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.smartsite-chat-window.theme-dark .smartsite-chat-input-container {
    background: #1e1e1e;
    border-color: #2d2d2d;
}

.smartsite-chat-window.theme-dark .smartsite-chat-input {
    background: #2d2d2d;
    border-color: #3d3d3d;
    color: #ffffff;
}

.smartsite-chat-window.theme-dark .smartsite-chat-input:focus {
    background: #2d2d2d;
    border-color: #EFC94C;
}

.smartsite-chat-window.theme-dark .ai-message .message-content {
    background: linear-gradient(135deg, #2d2d2d 0%, #3d3d3d 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Accessibility */
.smartsite-chat-button:focus,
.smartsite-chat-close:focus,
.smartsite-chat-send:focus {
    outline: 2px solid #EFC94C;
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .smartsite-chat-window {
        border: 2px solid #000;
    }
    
    .smartsite-chat-button {
        border: 2px solid #000;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .smartsite-chat-button,
    .smartsite-chat-window,
    .smartsite-message {
        transition: none;
    }
    
    .typing-indicator span {
        animation: none;
    }
}
