/**
 * Telegram Chat Widget Styles
 * Modern, responsive chat interface
 */

/* Chat Widget Container */
#telegram-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Toggle Button */
.chat-toggle-btn {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.chat-toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.5);
}

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

.chat-toggle-btn.chat-open {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

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

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

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-header-info h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.chat-status {
    font-size: 13px;
    opacity: 0.9;
    display: block;
    margin-top: 4px;
}

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

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Name Form */
.chat-name-form {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    background: linear-gradient(180deg, #f8f9ff 0%, #ffffff 100%);
}

.chat-name-form-content {
    width: 100%;
    max-width: 300px;
    text-align: center;
}

.chat-welcome-icon {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
}

.chat-name-form h3 {
    margin: 0 0 10px 0;
    font-size: 24px;
    font-weight: 600;
    color: #2d3748;
}

.chat-name-form p {
    margin: 0 0 25px 0;
    font-size: 14px;
    color: #718096;
    line-height: 1.5;
}

.chat-name-form .form-group {
    margin-bottom: 20px;
}

.chat-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.2s;
    box-sizing: border-box;
}

.chat-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-chat-primary {
    width: 100%;
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-chat-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-chat-primary:active {
    transform: translateY(0);
}

.btn-chat-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Messages Container */
.chat-messages-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Chat Message */
.chat-message {
    margin-bottom: 16px;
    display: flex;
    animation: fadeIn 0.3s ease;
}

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

.chat-message.outgoing {
    justify-content: flex-end;
}

.chat-message.incoming {
    justify-content: flex-start;
}

.chat-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
}

.chat-message.outgoing .chat-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

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

.chat-message.system .chat-message-content {
    background: #e6fffa;
    color: #047857;
    border-left: 3px solid #10b981;
    max-width: 90%;
    margin: 0 auto;
}

.chat-message.error .chat-message-content {
    background: #fee;
    color: #c53030;
    border-left: 3px solid #ef473a;
    max-width: 90%;
    margin: 0 auto;
}

.chat-message-sender {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #667eea;
}

.chat-message-text {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.chat-message-time {
    font-size: 11px;
    margin-top: 6px;
    opacity: 0.7;
    text-align: right;
}

.chat-message.incoming .chat-message-time {
    text-align: left;
}

/* Chat Input Container */
.chat-input-container {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

#chat-message-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-message-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 20px;
    font-size: 14px;
    resize: none;
    font-family: inherit;
    transition: all 0.2s;
    min-height: 40px;
    max-height: 120px;
    overflow-y: auto;
}

.chat-message-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-message-input::-webkit-scrollbar {
    width: 4px;
}

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

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 0;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chat-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

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

/* Error Message */
.chat-error {
    margin-top: 10px;
    padding: 10px;
    background: #fee;
    color: #c53030;
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
}

/* Responsive Design */
@media (max-width: 480px) {
    #telegram-chat-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    .chat-toggle-btn {
        width: 56px;
        height: 56px;
    }

    .chat-window {
        width: 100%;
        max-width: 100%;
        height: calc(100vh - 80px);
        max-height: calc(100vh - 80px);
        bottom: 70px;
        right: 0;
        left: 0;
        border-radius: 16px 16px 0 0;
    }

    .chat-header {
        padding: 16px;
    }

    .chat-messages {
        padding: 15px;
    }

    .chat-message-content {
        max-width: 85%;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .chat-window {
        background: #1a202c;
    }

    .chat-messages {
        background: #2d3748;
    }

    .chat-message.incoming .chat-message-content {
        background: #4a5568;
        color: #e2e8f0;
    }

    .chat-input,
    .chat-message-input {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    .chat-input-container {
        background: #1a202c;
        border-top-color: #4a5568;
    }

    .chat-name-form {
        background: linear-gradient(180deg, #2d3748 0%, #1a202c 100%);
    }

    .chat-name-form h3 {
        color: #e2e8f0;
    }

    .chat-name-form p {
        color: #a0aec0;
    }
}

