/**
 * TourGo Chatbot Widget Styles
 */

:root {
    --chatbot-primary: var(--tourgo-blue, #007bff);
    --chatbot-light: var(--tourgo-light-blue, #e3f2fd);
    --chatbot-dark: #333;
    --chatbot-border: #e0e0e0;
    --chatbot-bg: #f8f9fa;
}

#tourgo-chatbot-widget {
    position: fixed;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    z-index: 9999;
    font-size: 14px;
}

/* Position variants */
#tourgo-chatbot-widget.chatbot-bottom-right {
    bottom: 20px;
    right: 20px;
}

#tourgo-chatbot-widget.chatbot-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Theme variants */
#tourgo-chatbot-widget.chatbot-light {
    --message-bg: #fff;
    --text-color: #333;
    --border-color: #e0e0e0;
}

#tourgo-chatbot-widget.chatbot-dark {
    --message-bg: #2a2a2a;
    --text-color: #fff;
    --border-color: #444;
}

/* Chat box */
.chatbot-box {
    display: flex;
    flex-direction: column;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

@media (max-width: 480px) {
    .chatbot-box {
        width: calc(100vw - 20px);
        height: 70vh;
        max-height: 600px;
    }
}

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

/* Header */
.chatbot-header {
    padding: 16px;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary) 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: none;
}

.chatbot-title {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    flex: 1;
}

.chatbot-icon {
    font-size: 24px;
    line-height: 1;
}

.chatbot-title h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.chatbot-title p {
    margin: 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.chatbot-close:hover {
    transform: scale(1.1);
}

/* Messages area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

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

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

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Messages */
.chatbot-message {
    display: flex;
    gap: 8px;
    animation: fadeIn 0.3s ease-out;
}

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

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

.chatbot-message.user-message .message-content {
    background: var(--chatbot-primary);
    color: white;
    border-radius: 18px 18px 4px 18px;
    max-width: 70%;
}

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

.chatbot-message.bot-message .message-content {
    background: var(--chatbot-light);
    color: var(--chatbot-dark);
    border-radius: 18px 18px 18px 4px;
    max-width: 70%;
}

.message-avatar {
    font-size: 24px;
    line-height: 1;
    margin-top: 2px;
}

.message-content {
    padding: 10px 14px;
    word-wrap: break-word;
}

.message-content p {
    margin: 0 0 6px 0;
    font-size: 14px;
    line-height: 1.4;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content strong {
    font-weight: 600;
}

.message-content a {
    color: inherit;
    text-decoration: underline;
}

/* Quick reply chips */
.chatbot-qr {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}
.chatbot-quick-reply {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 16px;
    background: #fff;
    color: var(--chatbot-dark);
    border: 1px solid var(--chatbot-border);
    cursor: pointer;
    font-size: 12px;
    transition: background 0.15s, transform 0.1s;
    user-select: none;
}
.chatbot-quick-reply:hover {
    background: #f1f5f9;
}
.chatbot-quick-reply:active {
    transform: scale(0.98);
}

.message-time {
    display: block;
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
}

/* Typing indicator */
.typing-indicator .message-content {
    padding: 10px 14px;
}

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

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--chatbot-dark);
    opacity: 0.4;
    animation: typingAnimation 1.4s infinite;
}

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

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

@keyframes typingAnimation {
    0%, 60%, 100% {
        opacity: 0.4;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-8px);
    }
}

/* Input area */
.chatbot-input-area {
    padding: 12px;
    background: #f8f9fa;
    border-top: 1px solid var(--chatbot-border);
}

.chatbot-form {
    display: flex;
    gap: 8px;
}

.chatbot-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--chatbot-border);
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
    background: white;
}

.chatbot-input:focus {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.chatbot-input::placeholder {
    color: #999;
}

.chatbot-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--chatbot-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 18px;
    flex-shrink: 0;
}

.chatbot-send:hover {
    transform: scale(1.05);
}

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

.send-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Toggle button */
.chatbot-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--chatbot-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s;
    position: relative;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-toggle.active {
    background: #dc3545;
}

.toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-label {
    position: absolute;
    bottom: -30px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.chatbot-toggle:hover .toggle-label {
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .chatbot-box {
        width: calc(100vw - 16px);
        height: 80vh;
    }
    
    .chatbot-message.user-message .message-content,
    .chatbot-message.bot-message .message-content {
        max-width: 85%;
    }
}

@media (max-width: 480px) {
    #tourgo-chatbot-widget.chatbot-bottom-right,
    #tourgo-chatbot-widget.chatbot-bottom-left {
        bottom: 16px;
        right: 16px;
        left: auto;
    }
    
    .chatbot-toggle {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
    
    .chatbot-input {
        font-size: 16px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .chatbot-box,
    .chatbot-message,
    .chatbot-toggle,
    .chatbot-send {
        animation: none !important;
        transition: none !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .chatbot-box {
        background: #1e1e1e;
    }
    
    .chatbot-input {
        background: #2a2a2a;
        border-color: #444;
        color: white;
    }
    
    .chatbot-input-area {
        background: #252525;
        border-color: #444;
    }
    
    .chatbot-message.bot-message .message-content {
        background: rgba(0, 123, 255, 0.15);
        color: white;
    }
}
