/**
 * Chatbot Widget Styles
 * STUDIO85 IT (st85.ru)
 */

/* CSS Variables */
:root {
    --chatbot-primary: #0071e3;
    --chatbot-primary-dark: #005bb5;
    --chatbot-primary-light: #D6EEFF;
    --chatbot-bg: #ffffff;
    --chatbot-bg-secondary: #F8FAFC;
    --chatbot-user-msg-bg: #0071e3;
    --chatbot-user-msg-text: #ffffff;
    --chatbot-bot-msg-bg: #F1F5F9;
    --chatbot-bot-msg-text: #1E293B;
    --chatbot-text: #1E293B;
    --chatbot-text-light: #64748B;
    --chatbot-border: #E2E8F0;
    --chatbot-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --chatbot-radius: 16px;
    --chatbot-radius-sm: 12px;
}

/* Button (collapsed state) */
.chatbot-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chatbot-primary);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 113, 227, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 9998;
}

.chatbot-button:hover {
    background: var(--chatbot-primary-dark);
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(0, 113, 227, 0.5);
}

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

.chatbot-button svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.chatbot-button.chatbot-hidden {
    display: none;
}

/* Pulse animation */
.chatbot-button::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--chatbot-primary);
    animation: chatbotPulse 2s ease-out infinite;
    z-index: -1;
}

@keyframes chatbotPulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Window */
.chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    height: calc(100vh - 165px);
    max-height: 600px;
    background: var(--chatbot-bg);
    border-radius: var(--chatbot-radius);
    box-shadow: var(--chatbot-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
}

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

/* Header */
.chatbot-header {
    background: var(--chatbot-primary);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

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

.chatbot-header-avatar svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.chatbot-header-title {
    font-size: 16px;
    font-weight: 600;
}

.chatbot-header-subtitle {
    font-size: 12px;
    opacity: 0.8;
}

.chatbot-header-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    margin: -8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.chatbot-header-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chatbot-header-close svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Messages area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--chatbot-bg-secondary);
}

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

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--chatbot-border);
    border-radius: 3px;
}

/* Message */
.chatbot-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: chatbotMessageIn 0.3s ease;
}

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

.chatbot-message.chatbot-user {
    align-self: flex-end;
}

.chatbot-message.chatbot-assistant {
    align-self: flex-start;
}

.chatbot-message-content {
    padding: 12px 16px;
    border-radius: var(--chatbot-radius-sm);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chatbot-message.chatbot-user .chatbot-message-content {
    background: var(--chatbot-user-msg-bg);
    color: var(--chatbot-user-msg-text);
    border-bottom-right-radius: 4px;
}

.chatbot-message.chatbot-assistant .chatbot-message-content {
    background: var(--chatbot-bg);
    color: var(--chatbot-bot-msg-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chatbot-message-time {
    font-size: 11px;
    color: var(--chatbot-text-light);
    margin-top: 4px;
    padding: 0 4px;
}

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

/* Typing indicator */
.chatbot-typing {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: var(--chatbot-bg);
    border-radius: var(--chatbot-radius-sm);
    border-bottom-left-radius: 4px;
    max-width: 80px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chatbot-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--chatbot-text-light);
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out both;
}

.chatbot-typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

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

@keyframes typingDot {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input area */
.chatbot-input-container {
    padding: 16px;
    background: var(--chatbot-bg);
    border-top: 1px solid var(--chatbot-border);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chatbot-input-wrapper {
    flex: 1;
    position: relative;
}

.chatbot-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--chatbot-border);
    border-radius: var(--chatbot-radius-sm);
    font-size: 14px;
    resize: none;
    max-height: 100px;
    line-height: 1.5;
    font-family: inherit;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.chatbot-input:focus {
    outline: none;
    border-color: var(--chatbot-primary);
}

.chatbot-input::placeholder {
    color: var(--chatbot-text-light);
}

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

.chatbot-send-button:hover:not(:disabled) {
    background: var(--chatbot-primary-dark);
}

.chatbot-send-button:disabled {
    background: var(--chatbot-border);
    cursor: not-allowed;
}

.chatbot-send-button svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Phone form */
.chatbot-phone-form {
    padding: 16px;
    background: var(--chatbot-primary-light);
    border-top: 1px solid var(--chatbot-border);
}

.chatbot-phone-label {
    font-size: 13px;
    color: var(--chatbot-text);
    margin-bottom: 8px;
    display: block;
}

.chatbot-phone-input-row {
    display: flex;
    gap: 8px;
}

.chatbot-phone-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--chatbot-border);
    border-radius: var(--chatbot-radius-sm);
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}

.chatbot-phone-input:focus {
    outline: none;
    border-color: var(--chatbot-primary);
}

.chatbot-phone-submit {
    padding: 12px 20px;
    background: var(--chatbot-primary);
    color: white;
    border: none;
    border-radius: var(--chatbot-radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.chatbot-phone-submit:hover:not(:disabled) {
    background: var(--chatbot-primary-dark);
}

.chatbot-phone-submit:disabled {
    background: var(--chatbot-border);
    cursor: not-allowed;
}

.chatbot-phone-success {
    padding: 16px;
    background: #DCFCE7;
    border-top: 1px solid #BBF7D0;
    text-align: center;
    color: #166534;
    font-size: 14px;
}

/* Error message */
.chatbot-error {
    padding: 12px 16px;
    background: #FEF2F2;
    color: #DC2626;
    font-size: 13px;
    text-align: center;
    border-radius: var(--chatbot-radius-sm);
    margin: 8px 16px;
}

/* Quick reply buttons */
.chatbot-quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
    animation: chatbotMessageIn 0.3s ease;
}

.chatbot-quick-btn {
    padding: 8px 16px;
    background: var(--chatbot-bg);
    color: var(--chatbot-primary);
    border: 1.5px solid var(--chatbot-primary);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.3;
}

.chatbot-quick-btn:hover {
    background: var(--chatbot-primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}

.chatbot-quick-btn:active {
    transform: translateY(0);
}

/* Mobile styles */
@media (max-width: 480px) {
    .chatbot-button {
        bottom: 16px;
        right: 12px;
        width: 56px;
        height: 56px;
    }

    .chatbot-window {
        left: 8px;
        right: 8px;
        bottom: 80px;
        width: auto;
        border-radius: 16px;
        max-height: 70vh;
        height: 70vh;
    }

    .chatbot-header {
        padding: 12px 16px;
    }

    .chatbot-input-container {
        padding-bottom: 12px;
    }
}
