/* GLI Customer Service Chat Widget Styles v2.0 */

/* CSS Variables */
:root {
    --gli-primary: #22c55e;
    --gli-primary-dark: #16a34a;
    --gli-bg: #ffffff;
    --gli-bg-secondary: #f8fafc;
    --gli-text: #1e293b;
    --gli-text-secondary: #64748b;
    --gli-border: #e2e8f0;
    --gli-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --gli-shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --gli-radius: 16px;
    --gli-radius-sm: 12px;
    --gli-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --gli-warning: #f59e0b;
    --gli-error: #ef4444;
    --gli-success: #22c55e;
}

/* Reset for widget */
.gli-chat-widget,
.gli-chat-widget * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Main Container */
.gli-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-size: 14px;
    line-height: 1.5;
}

/* Toggle Button */
.gli-chat-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gli-primary) 0%, var(--gli-primary-dark) 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--gli-shadow), 0 0 0 0 rgba(34, 197, 94, 0.4);
    transition: var(--gli-transition);
    position: relative;
    overflow: hidden;
}

.gli-chat-toggle::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
    border-radius: 50%;
}

.gli-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: var(--gli-shadow), 0 0 0 8px rgba(34, 197, 94, 0.15);
}

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

.gli-chat-toggle .gli-chat-icon-close {
    display: none;
}

.gli-chat-widget.open .gli-chat-toggle .gli-chat-icon-open {
    display: none;
}

.gli-chat-widget.open .gli-chat-toggle .gli-chat-icon-close {
    display: block;
}

/* Pulse animation for toggle */
@keyframes gli-pulse {
    0% {
        box-shadow: var(--gli-shadow), 0 0 0 0 rgba(34, 197, 94, 0.4);
    }
    70% {
        box-shadow: var(--gli-shadow), 0 0 0 15px rgba(34, 197, 94, 0);
    }
    100% {
        box-shadow: var(--gli-shadow), 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

.gli-chat-toggle:not(:hover) {
    animation: gli-pulse 2s infinite;
}

.gli-chat-widget.open .gli-chat-toggle {
    animation: none;
}

/* Chat Window */
.gli-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: var(--gli-bg);
    border-radius: var(--gli-radius);
    box-shadow: var(--gli-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: var(--gli-transition);
    border: 1px solid var(--gli-border);
}

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

/* Header */
.gli-chat-header {
    background: linear-gradient(135deg, var(--gli-primary) 0%, var(--gli-primary-dark) 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.gli-chat-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.gli-chat-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gli-chat-title {
    font-weight: 600;
    font-size: 16px;
    letter-spacing: -0.01em;
}

.gli-chat-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.gli-status-dot {
    width: 8px;
    height: 8px;
    background: #86efac;
    border-radius: 50%;
    animation: gli-status-pulse 2s infinite;
}

@keyframes gli-status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.gli-chat-minimize {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--gli-transition);
}

.gli-chat-minimize:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages Container */
.gli-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--gli-bg-secondary);
    scroll-behavior: smooth;
}

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

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

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

.gli-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--gli-text-secondary);
}

/* Message Bubbles */
.gli-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: gli-message-appear 0.3s ease-out;
}

@keyframes gli-message-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.gli-message-bubble {
    padding: 12px 16px;
    border-radius: var(--gli-radius-sm);
    word-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.6;
}

.gli-message.user .gli-message-bubble {
    background: linear-gradient(135deg, var(--gli-primary) 0%, var(--gli-primary-dark) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.gli-message.assistant .gli-message-bubble {
    background: var(--gli-bg);
    color: var(--gli-text);
    border: 1px solid var(--gli-border);
    border-bottom-left-radius: 4px;
    box-shadow: var(--gli-shadow-sm);
}

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

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

/* Message Images */
.gli-message-image {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--gli-radius-sm);
    margin-bottom: 8px;
    object-fit: contain;
    border: 1px solid var(--gli-border);
}

/* Model Confirmation UI */
.gli-model-confirmation {
    margin-top: 12px;
    padding: 12px;
    background: var(--gli-bg-secondary);
    border-radius: var(--gli-radius-sm);
    border: 1px solid var(--gli-border);
}

.gli-model-confirmation p {
    margin: 0 0 8px 0;
}

.gli-model-confirmation p:last-child {
    margin-bottom: 0;
}

.gli-ocr-warning {
    color: var(--gli-warning);
    font-size: 12px;
    padding: 6px 10px;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 6px;
    border-left: 3px solid var(--gli-warning);
}

.gli-alternatives {
    font-size: 12px;
    color: var(--gli-text-secondary);
}

.gli-model-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.gli-model-btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--gli-border);
    background: var(--gli-bg);
    color: var(--gli-text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--gli-transition);
}

.gli-model-btn:hover {
    border-color: var(--gli-primary);
    background: rgba(34, 197, 94, 0.05);
}

.gli-model-btn-confirm {
    background: var(--gli-primary);
    color: white;
    border-color: var(--gli-primary);
}

.gli-model-btn-confirm:hover {
    background: var(--gli-primary-dark);
    border-color: var(--gli-primary-dark);
}

.gli-model-btn-other {
    background: transparent;
    border-style: dashed;
}

.gli-model-btn-other:hover {
    border-color: var(--gli-error);
    color: var(--gli-error);
    background: rgba(239, 68, 68, 0.05);
}

/* Typing Indicator */
.gli-typing-indicator {
    padding: 0 20px 12px;
    background: var(--gli-bg-secondary);
}

.gli-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--gli-bg);
    border-radius: var(--gli-radius-sm);
    border: 1px solid var(--gli-border);
    box-shadow: var(--gli-shadow-sm);
}

.gli-typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--gli-primary);
    border-radius: 50%;
    animation: gli-typing-bounce 1.4s infinite ease-in-out both;
}

.gli-typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

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

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

/* Input Area */
.gli-chat-input-area {
    padding: 16px 20px;
    background: var(--gli-bg);
    border-top: 1px solid var(--gli-border);
    flex-shrink: 0;
}

.gli-chat-input-container {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--gli-bg-secondary);
    border: 1px solid var(--gli-border);
    border-radius: var(--gli-radius-sm);
    padding: 8px 12px;
    transition: var(--gli-transition);
}

.gli-chat-input-container:focus-within {
    border-color: var(--gli-primary);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

/* Image Upload Button */
.gli-image-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    cursor: pointer;
    color: var(--gli-text-secondary);
    border-radius: 8px;
    transition: var(--gli-transition);
    flex-shrink: 0;
}

.gli-image-upload-label:hover {
    background: var(--gli-border);
    color: var(--gli-primary);
}

/* Image Preview */
.gli-image-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    margin-top: 8px;
    background: var(--gli-bg-secondary);
    border: 1px solid var(--gli-border);
    border-radius: 8px;
}

.gli-image-preview img {
    max-width: 60px;
    max-height: 60px;
    border-radius: 6px;
    object-fit: cover;
}

.gli-remove-image {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--gli-error);
    color: white;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--gli-transition);
}

.gli-remove-image:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.gli-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    color: var(--gli-text);
    max-height: 120px;
    padding: 4px 0;
}

.gli-chat-input:focus {
    outline: none;
}

.gli-chat-input::placeholder {
    color: var(--gli-text-secondary);
}

.gli-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gli-primary) 0%, var(--gli-primary-dark) 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--gli-transition);
}

.gli-chat-send:hover {
    transform: scale(1.08);
}

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

.gli-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.gli-chat-powered {
    text-align: center;
    font-size: 11px;
    color: var(--gli-text-secondary);
    margin-top: 10px;
}

/* Links in messages */
.gli-message-bubble a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.gli-message.assistant .gli-message-bubble a {
    color: var(--gli-primary-dark);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .gli-chat-widget {
        bottom: 16px;
        right: 16px;
    }
    
    .gli-chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        bottom: 72px;
        right: -8px;
        border-radius: var(--gli-radius-sm);
    }
    
    .gli-chat-toggle {
        width: 56px;
        height: 56px;
    }
    
    .gli-chat-messages {
        padding: 16px;
    }
    
    .gli-message {
        max-width: 90%;
    }
    
    .gli-model-buttons {
        flex-direction: column;
    }
    
    .gli-model-btn {
        width: 100%;
        text-align: center;
    }
}

/* Notification badge (future feature) */
.gli-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .gli-chat-widget.dark-mode {
        --gli-bg: #1e293b;
        --gli-bg-secondary: #0f172a;
        --gli-text: #f1f5f9;
        --gli-text-secondary: #94a3b8;
        --gli-border: #334155;
    }
}

/* Drag and Drop States */
.gli-chat-window.gli-drag-over {
    position: relative;
}

.gli-chat-window.gli-drag-over::after {
    content: 'Drop image here';
    position: absolute;
    inset: 0;
    background: rgba(34, 197, 94, 0.95);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    z-index: 100;
    border-radius: var(--gli-radius);
    border: 3px dashed white;
    margin: 8px;
    pointer-events: none;
}

/* Toast Notifications */
.gli-toast {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--gli-text);
    color: var(--gli-bg);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--gli-shadow);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 101;
    white-space: nowrap;
}

.gli-toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Paste hint in input placeholder */
.gli-chat-input::placeholder {
    color: var(--gli-text-secondary);
}

/* Image preview improvements */
.gli-image-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    margin-top: 8px;
    background: var(--gli-bg-secondary);
    border: 1px solid var(--gli-border);
    border-radius: 8px;
    animation: gli-preview-appear 0.2s ease-out;
}

@keyframes gli-preview-appear {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.gli-image-preview img {
    max-width: 60px;
    max-height: 60px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--gli-border);
}

.gli-image-preview-info {
    flex: 1;
    font-size: 12px;
    color: var(--gli-text-secondary);
}

/* Upload area hint */
.gli-upload-hint {
    font-size: 11px;
    color: var(--gli-text-secondary);
    text-align: center;
    padding: 4px 0;
    margin-top: 4px;
}

/* =========================================================================
   SATISFACTION SURVEY
   ========================================================================= */

.gli-satisfaction-survey {
    padding: 20px;
    background: var(--gli-bg);
    border-top: 1px solid var(--gli-border);
    text-align: center;
    animation: gli-survey-appear 0.3s ease-out;
}

@keyframes gli-survey-appear {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.gli-survey-header {
    font-size: 15px;
    font-weight: 600;
    color: var(--gli-text);
    margin-bottom: 12px;
}

.gli-stars {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 12px;
}

.gli-star {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gli-border);
    padding: 4px;
    border-radius: 4px;
    transition: color 0.15s, transform 0.15s;
}

.gli-star:hover,
.gli-star.gli-star-hover {
    color: #facc15;
    transform: scale(1.15);
}

.gli-star.gli-star-active {
    color: #facc15;
}

.gli-star.gli-star-active svg {
    fill: #facc15;
}

.gli-survey-comment {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gli-border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    color: var(--gli-text);
    background: var(--gli-bg-secondary);
    margin-bottom: 12px;
}

.gli-survey-comment:focus {
    outline: none;
    border-color: var(--gli-primary);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.gli-survey-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.gli-survey-skip,
.gli-survey-submit {
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--gli-transition);
}

.gli-survey-skip {
    background: transparent;
    border: 1px solid var(--gli-border);
    color: var(--gli-text-secondary);
}

.gli-survey-skip:hover {
    background: var(--gli-bg-secondary);
}

.gli-survey-submit {
    background: var(--gli-primary);
    border: none;
    color: white;
}

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

.gli-survey-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
