/**
 * Lets TG Chat - Frontend Widget Styles
 */

/* Widget Toggle Button */
.customtglivechat-widget-toggle {
    position: fixed;
    bottom: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    z-index: 999998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

/* Toggle Button Position - Right (Default) */
.customtglivechat-widget-toggle.customtglivechat-position-right {
    right: 20px;
    left: auto;
}

/* Toggle Button Position - Left */
.customtglivechat-widget-toggle.customtglivechat-position-left {
    left: 20px;
    right: auto;
}

.customtglivechat-widget-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.customtglivechat-widget-toggle svg {
    width: 28px;
    height: 28px;
}

.customtglivechat-widget-toggle .customtglivechat-unread-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border: 2px solid #ffffff;
    border-radius: 999px;
    background: #dc2626;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(127, 29, 29, 0.4);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
}

.customtglivechat-widget-toggle .customtglivechat-unread-badge[hidden] {
    display: none;
}

/* Widget Container */
.customtglivechat-widget {
    position: fixed;
    bottom: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 40px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 999999;
    display: none; /* Hidden by default, JavaScript will show it */
    flex-direction: column;
    overflow: hidden;
}

/* Widget Position - Right (Default) */
.customtglivechat-widget.customtglivechat-position-right {
    right: 20px;
    left: auto;
}

/* Widget Position - Left */
.customtglivechat-widget.customtglivechat-position-left {
    left: 20px;
    right: auto;
}

.customtglivechat-widget.customtglivechat-widget-visible {
    display: flex !important;
    animation: customtglivechat-slide-up 0.3s ease;
}

/* Animation for right position */
.customtglivechat-widget.customtglivechat-position-right.customtglivechat-widget-visible {
    animation: customtglivechat-slide-up-right 0.3s ease;
}

/* Animation for left position */
.customtglivechat-widget.customtglivechat-position-left.customtglivechat-widget-visible {
    animation: customtglivechat-slide-up-left 0.3s ease;
}

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

@keyframes customtglivechat-slide-up-right {
    from {
        transform: translate(0, 20px);
        opacity: 0;
    }
    to {
        transform: translate(0, 0);
        opacity: 1;
    }
}

@keyframes customtglivechat-slide-up-left {
    from {
        transform: translate(0, 20px);
        opacity: 0;
    }
    to {
        transform: translate(0, 0);
        opacity: 1;
    }
}

/* Widget Header */
.customtglivechat-widget-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.customtglivechat-widget-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.customtglivechat-avatar-placeholder {
    color: white;
    font-weight: 600;
    font-size: 18px;
}

.customtglivechat-widget-info {
    flex: 1;
}

.customtglivechat-widget-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.customtglivechat-online-indicator {
    width: 10px;
    height: 10px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
    animation: customtglivechat-pulse 2s infinite;
    flex-shrink: 0;
}

.customtglivechat-online-indicator.customtglivechat-offline-indicator {
    background: #94a3b8;
    box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.3);
    animation: none;
}

@keyframes customtglivechat-pulse {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
    }
}

.customtglivechat-widget-status {
    font-size: 12px;
    opacity: 0.9;
}

.customtglivechat-widget-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.customtglivechat-widget-close:hover {
    opacity: 1;
}

.customtglivechat-widget-close svg {
    width: 20px;
    height: 20px;
}

/* Widget Body */
.customtglivechat-widget-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Customer Form */
.customtglivechat-widget-form {
    padding: 24px;
    flex: 1;
}

.customtglivechat-welcome-message {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
}

.customtglivechat-welcome-message .customtglivechat-message-item {
    margin-bottom: 0;
}

.customtglivechat-welcome-message .customtglivechat-message-bubble {
    background: #f3f4f6;
    color: #374151;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.customtglivechat-widget-form h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    color: #1e293b;
    text-align: center;
}

.customtglivechat-form-group {
    margin-bottom: 16px;
}

.customtglivechat-form-group label {
    display: block;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
    font-size: 14px;
}

.customtglivechat-form-group .required {
    color: #dc2626;
}

.customtglivechat-form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.customtglivechat-form-group input:focus {
    outline: none;
    border-color: #667eea;
}

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

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

/* Messages Container */
.customtglivechat-widget-messages {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.customtglivechat-messages-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
}

.customtglivechat-message-item {
    margin-bottom: 12px;
    display: flex;
    gap: 8px;
}

.customtglivechat-message-item.customer {
    flex-direction: row-reverse;
}

.customtglivechat-message-item.admin {
    flex-direction: row;
}

.customtglivechat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
}

.customtglivechat-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.customtglivechat-message-avatar .customtglivechat-avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #667eea;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.customtglivechat-message-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: calc(100% - 40px);
}

.customtglivechat-message-item.customer .customtglivechat-message-content {
    align-items: flex-end;
}

.customtglivechat-message-item.admin .customtglivechat-message-content {
    align-items: flex-start;
}

.customtglivechat-message-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 75%;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.customtglivechat-message-item.customer .customtglivechat-message-bubble {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.customtglivechat-message-item.admin .customtglivechat-message-bubble {
    background: white;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.customtglivechat-message-time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    padding: 0 4px;
}

/* Message Input */
.customtglivechat-message-input {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.customtglivechat-message-input input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
}

.customtglivechat-message-input input:focus {
    outline: none;
    border-color: #667eea;
}

.customtglivechat-offline-questions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 45%;
    overflow-y: auto;
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
}

.customtglivechat-offline-question {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #667eea;
    border-radius: 8px;
    background: #ffffff;
    color: #667eea;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    text-align: left;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.customtglivechat-offline-question:hover,
.customtglivechat-offline-question:focus {
    background: #667eea;
    color: #ffffff;
    outline: none;
    transform: translateY(-1px);
}

.customtglivechat-offline-question:disabled {
    cursor: wait;
    opacity: 0.6;
    transform: none;
}

.customtglivechat-offline-restart {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    font-size: 22px;
    font-weight: 500;
    line-height: 1;
    opacity: 0.85;
    text-align: center;
}

.customtglivechat-offline-empty {
    margin: 0;
    color: #64748b;
    font-size: 13px;
    text-align: center;
}

.customtglivechat-btn-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.customtglivechat-btn-send:hover {
    background: #5568d3;
    transform: scale(1.05);
}

.customtglivechat-btn-send svg {
    width: 20px;
    height: 20px;
}

/* Customer Details Modal */
.customtglivechat-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.customtglivechat-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.customtglivechat-modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 1;
}

.customtglivechat-modal-content h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
    color: #1e293b;
    font-weight: 600;
}

.customtglivechat-modal-description {
    margin: 0 0 20px 0;
    color: #64748b;
    font-size: 14px;
}

.customtglivechat-modal-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
}

.customtglivechat-modal-actions .customtglivechat-btn-primary {
    width: 100%;
}

/* Skin Variations */
.customtglivechat-skin-dark .customtglivechat-widget-toggle,
.customtglivechat-skin-dark .customtglivechat-widget-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

.customtglivechat-skin-light .customtglivechat-widget-toggle,
.customtglivechat-skin-light .customtglivechat-widget-header {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: #1e293b;
}

.customtglivechat-skin-light .customtglivechat-widget-header {
    border-bottom: 1px solid #e2e8f0;
}

/* Responsive */
@media (max-width: 480px) {
    .customtglivechat-widget {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        bottom: 0;
        border-radius: 0;
    }
    
    .customtglivechat-widget.customtglivechat-position-right {
        right: 0;
        left: auto;
    }
    
    .customtglivechat-widget.customtglivechat-position-left {
        left: 0;
        right: auto;
    }
    
    .customtglivechat-widget-toggle {
        bottom: 15px;
        width: 56px;
        height: 56px;
    }
    
    .customtglivechat-widget-toggle.customtglivechat-position-right {
        right: 15px;
        left: auto;
    }
    
    .customtglivechat-widget-toggle.customtglivechat-position-left {
        left: 15px;
        right: auto;
    }
}
