/* Chatlyx Frontend Styles */
/* Note: Variables are loaded from variables.css */

.chatlyx-widget-container {
    font-family: var(--chatlyx-font-family);
    position: fixed;
    z-index: var(--chatlyx-z-index);
    bottom: 20px;
    display: flex;
    flex-direction: column;
    pointer-events: none;
    /* Allow clicking through when closed */
}

.chatlyx-widget-container.chatlyx-pos-bottom-right {
    right: 20px;
    align-items: flex-end;
}

.chatlyx-widget-container.chatlyx-pos-bottom-left {
    left: 20px;
    align-items: flex-start;
}

.chatlyx-widget-container * {
    box-sizing: border-box;
}

/* Launcher */
.chatlyx-launcher {
    width: 60px;
    height: 60px;
    background-color: var(--chatlyx-launcher-bg);
    border-radius: var(--chatlyx-radius-full);
    box-shadow: var(--chatlyx-shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--chatlyx-text-light);
    transition: var(--chatlyx-transition);
    pointer-events: auto;
}

.chatlyx-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
}

.chatlyx-launcher svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
    display: block;
}

.chatlyx-launcher img {
    width: 50px !important;
    height: 50px !important;
    max-width: 50px !important;
    max-height: 50px !important;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    padding: 0;
}

/* Chat Window */
/* Chat Window */
.chatlyx-window {
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: rgba(255, 255, 255, 0.98);
    /* Less transparent for cleaner monochrome look */
    border: 1px solid rgba(0, 0, 0, 0.15);
    /* Slightly more visible light border */
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15),
        0 0 15px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    margin-bottom: 0px;
    overflow: hidden;

    /* Animation State: Closed */
    opacity: 0;
    transform: scale(0);
    /* Start scaled down completely */
    transform-origin: bottom right;
    /* Animate from launcher */
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    /* Smoother expand without excessive bounce for genie feel */
    pointer-events: none;

    position: absolute;
    bottom: 75px;
    right: 0;
}

.chatlyx-pos-bottom-left .chatlyx-window {
    left: 0;
    right: auto;
    transform-origin: bottom left;
}

.chatlyx-widget-container.chatlyx-open .chatlyx-window {
    opacity: 1;
    transform: scale(1);
    /* Full size */
    pointer-events: auto;
}

/* Header */
/* Header */
/* Header */
.chatlyx-header {
    background: var(--chatlyx-header-bg);
    /* Black */
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #2a2a2a;
    position: relative;
    z-index: 10;
}

.chatlyx-header-info {
    display: flex;
    align-items: center;
}

.chatlyx-status-dot {
    width: 10px;
    height: 10px;
    background: var(--chatlyx-success);
    border-radius: 50%;
    margin-right: 10px;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.chatlyx-header-title {
    font-weight: 700;
    font-size: 15px;
    /* Decreased size as requested */
    line-height: 1.2;
    letter-spacing: 0.01em;
}

.chatlyx-btn-icon {
    background: transparent !important;
    border: none !important;
    color: inherit;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
    opacity: 0.9;
}

.chatlyx-btn-icon:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    opacity: 1;
}

/* Content */
.chatlyx-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px 20px;
    overflow-y: auto;
    background-color: #fafbfc;
}

/* Pre-chat */
/* Pre-chat */
.chatlyx-prechat-header h3 {
    font-size: 20px !important;
    /* Reduced from 24px */
    line-height: 1.3 !important;
    margin: 0 0 10px 0 !important;
    text-align: left;
    color: #333 !important;
    font-weight: 600 !important;
}

.chatlyx-prechat-desc {
    margin-bottom: 32px;
    color: #555;
    font-size: 15px;
    line-height: 1.6;
    text-align: left;
    font-weight: 400;
}

.chatlyx-form-group {
    margin-bottom: 24px;
    position: relative;
}

.chatlyx-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    opacity: 0.8;
}

.chatlyx-form-group input {
    width: 100% !important;
    padding: 14px 20px !important;
    border: 1px solid #e1e4e8 !important;
    border-radius: 16px !important;
    font-size: 15px !important;
    line-height: normal !important;
    transition: all 0.3s ease;
    background: #f0f4f8 !important;
    color: #1a1a1a !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02) !important;
    height: auto !important;
    /* Fix for some themes setting fixed height */
}

.chatlyx-form-group input:focus {
    border-color: #0073aa !important;
    border-width: 1px !important;
    border-style: solid !important;
    background: white !important;
    box-shadow: none !important;
    outline: none !important;
}

.chatlyx-btn-primary {
    width: 100% !important;
    padding: 14px !important;
    background: #000000 !important;
    color: white !important;
    border: 1px solid transparent !important;
    border-radius: 12px !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: normal !important;
    height: auto !important;
}

.chatlyx-btn-primary:hover {
    background: #333 !important;
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
}

.chatlyx-btn-primary:active {
    transform: translateY(0);
}

/* Messages */
.chatlyx-messages {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Scrollbar styling */
/* Scrollbar styling - Specific 3px Request */
.chatlyx-messages::-webkit-scrollbar,
.chatlyx-window *::-webkit-scrollbar {
    width: 3px !important;
}

.chatlyx-messages::-webkit-scrollbar-track,
.chatlyx-window *::-webkit-scrollbar-track {
    background: transparent !important;
    margin-right: 2px !important;
}

.chatlyx-messages::-webkit-scrollbar-thumb,
.chatlyx-window *::-webkit-scrollbar-thumb {
    background: #cbd5e1 !important;
    border-radius: 4px !important;
}

/* Ensure spacing between text and scrollbar */
.chatlyx-messages {
    padding-right: 14px !important;
    /* Extra spacing for scrollbar */
}

.chatlyx-message {
    max-width: 85%;
    padding: 10px 16px;
    border-radius: var(--chatlyx-radius-md);
    font-size: var(--chatlyx-font-base);
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.chatlyx-message-system {
    align-self: center;
    background: transparent;
    color: var(--chatlyx-text-muted);
    font-size: var(--chatlyx-font-sm);
    padding: 5px;
    font-style: italic;
}

.chatlyx-message-visitor {
    align-self: flex-end;
    background: var(--chatlyx-bubble-visitor);
    color: var(--chatlyx-text-dark);
    border-radius: 18px;
    border-bottom-right-radius: 2px;
    padding: 10px 14px;
    box-shadow: var(--chatlyx-shadow-sm);
}

.chatlyx-message-agent {
    align-self: flex-start;
    border: 1px solid var(--chatlyx-border);
    border-bottom-left-radius: 2px;
    box-shadow: var(--chatlyx-shadow-sm);
}

.chatlyx-chat-image {
    max-width: 150px;
    max-height: 150px;
    width: auto;
    height: auto;
    border-radius: 4px;
    margin-top: 4px;
    cursor: pointer;
    object-fit: cover;
    display: block;
}

/* File Preview Area */
.chatlyx-file-preview {
    display: none;
    padding: 8px;
    margin-bottom: 8px;
}

.chatlyx-file-preview:not(:empty) {
    display: flex;
}

.chatlyx-preview-item {
    position: relative;
    display: inline-block;
    max-width: 80px;
}

.chatlyx-preview-item img {
    max-width: 80px;
    max-height: 60px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid #ddd;
}

.chatlyx-remove-preview {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ff4757 !important;
    color: white !important;
    border: none !important;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s, background 0.1s;
}

.chatlyx-remove-preview:hover {
    background: #ff6b81 !important;
    transform: scale(1.1);
}

/* Modern Composer */
.chatlyx-composer-container {
    padding: 15px 0 0 0;
    /* background: #fff; */
    /* border-top: 1px solid var(--chatlyx-border); */
}

.chatlyx-composer {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border-radius: 12px;
    padding: 0 8px;
    border: 1px solid var(--chatlyx-border);
    transition: border-color 0.2s;
}

.chatlyx-composer:focus-within {
    border-color: #999;
    background: #fff;
}

#chatlyx-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    padding: 2px 0;
    font-size: 14px;
    max-height: 80px;
    min-height: 18px;
    outline: none;
    color: #000000 !important;
    line-height: 1.4;
    overflow-y: auto;
}

/* Custom thin scrollbar for input */
#chatlyx-input::-webkit-scrollbar {
    width: 2px !important;
}

#chatlyx-input::-webkit-scrollbar-track {
    background: transparent !important;
}

#chatlyx-input::-webkit-scrollbar-thumb {
    background: #ccc !important;
    border-radius: 2px !important;
}

#chatlyx-input::-webkit-scrollbar-thumb:hover {
    background: #aaa !important;
}

/* Attachment Button - hardcoded black to prevent theme override */
.chatlyx-icon-btn {
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    color: #000000 !important;
    cursor: pointer;
    padding: 0 !important;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.15s;
}

.chatlyx-icon-btn:hover {
    opacity: 0.8;
    background: transparent !important;
}

.chatlyx-icon-btn:focus {
    outline: none !important;
    box-shadow: none !important;
    opacity: 0.8;
}

.chatlyx-icon-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 1.5;
}

/* Attachment Dropdown */
.chatlyx-attach-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.chatlyx-attach-menu {
    position: absolute;
    bottom: 100%;
    /* Show above buttom */
    left: 0;
    margin-bottom: 8px;
    background: #fff !important;
    border-radius: 12px;
    /* Slightly tighter radius */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15) !important;
    padding: 6px;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 99999 !important;
    /* Ensure it stays on top */
    border: 1px solid rgba(0, 0, 0, 0.06) !important;

    /* Genie Effect Initial State */
    opacity: 0;
    transform: scale(0) translateY(20px);
    transform-origin: bottom left;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    pointer-events: none;
}

.chatlyx-attach-menu.open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* Force override for attachment buttons using IDs to beat theme specificity */
#chatlyx-opt-image,
#chatlyx-opt-zip,
.chatlyx-menu-item {
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 8px 10px !important;
    text-align: left;
    cursor: pointer;
    border-radius: 6px !important;
    /* Force radius */
    font-size: 13px !important;
    color: #333 !important;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.1s;
    font-weight: 500;
    width: 100%;
    /* Ensure full width */
    margin: 0 !important;
}

#chatlyx-opt-image:hover,
#chatlyx-opt-zip:hover,
.chatlyx-menu-item:hover {
    background: #f5f5f5 !important;
    background-color: #f5f5f5 !important;
    color: #000 !important;
}

.chatlyx-menu-item svg {
    width: 16px;
    height: 16px;
    opacity: 0.6;
    color: inherit;
}

/* Send Button */
#chatlyx-send-btn {
    background: none;
    border: none;
    color: var(--chatlyx-primary);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    border-radius: 50%;
    transition: transform 0.2s;
}

#chatlyx-send-btn:hover {
    transform: scale(1.1);
}

#chatlyx-send-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

@media (max-width: 480px) {
    .chatlyx-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        bottom: 90px;
        right: 0;
    }
}

/* Restart Chat Button */
.chatlyx-restart-container {
    padding: 15px !important;
    background: #fff !important;
    border-top: 1px solid var(--chatlyx-border) !important;
    margin-top: auto !important;
}

.chatlyx-btn-block {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    text-align: center !important;
    background-color: var(--chatlyx-primary, #0073aa) !important;
    color: #fff !important;
    padding: 12px !important;
    border-radius: 8px !important;
    border: none !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
}

.chatlyx-btn-block:hover {
    background-color: #005177 !important;
    color: #fff !important;
}

/* Message Timestamp - WhatsApp Style */
.chatlyx-bubble .chatlyx-msg-time {
    display: block !important;
    width: 100%;
    font-size: 10px !important;
    margin-top: 4px;
    opacity: 0.7;
    text-align: right;
    line-height: 1.2;
    color: inherit;
    clear: both;
}

/* Image Modal */
.chatlyx-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000000;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
}

.chatlyx-image-modal.open {
    display: flex;
    opacity: 1;
}

.chatlyx-image-modal img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.chatlyx-image-modal.open img {
    transform: scale(1);
}

.chatlyx-image-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 30px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.chatlyx-image-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chatlyx-modal-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    z-index: 1000001;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 15px;
    border-radius: 20px;
    backdrop-filter: blur(5px);
}

.chatlyx-modal-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
}

.chatlyx-modal-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.chatlyx-modal-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Header Menu */
.chatlyx-header-menu-wrapper {
    position: relative;
}

#chatlyx-header-dropdown {
    transform-origin: top right;
    right: 0;
    left: auto;
    width: 165px;
}

#chatlyx-header-dropdown .chatlyx-menu-item {
    font-size: 14px !important;
    padding: 10px 12px !important;
}

#chatlyx-header-dropdown svg {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

/* Typing Indicator */
.chatlyx-typing-indicator {
    padding: 8px 16px;
    color: var(--chatlyx-text-muted);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
    border-top: 1px solid var(--chatlyx-border);
    background: var(--chatlyx-bg-light);
}

.chatlyx-typing-indicator .typing-dot {
    width: 6px;
    height: 6px;
    background: var(--chatlyx-primary);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

.chatlyx-typing-indicator .typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.chatlyx-typing-indicator .typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

.chatlyx-typing-indicator .typing-dot:nth-child(3) {
    animation-delay: 0s;
}

.chatlyx-typing-indicator .typing-text {
    margin-left: 6px;
    font-style: italic;
}

@keyframes typing-bounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Rating UI */
.chatlyx-rating-container {
    padding: 20px 15px;
    text-align: center;
    background: #f9fafb;
    border-top: 1px solid var(--chatlyx-border);
}

.chatlyx-rating-prompt {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
}

.chatlyx-rating-stars {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.chatlyx-star {
    font-size: 28px;
    color: #ccc;
    cursor: pointer;
    transition: color 0.15s, transform 0.15s;
}

.chatlyx-star:hover,
.chatlyx-star.active {
    color: #f5a623;
    transform: scale(1.15);
}

.chatlyx-rating-feedback {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    resize: none;
    font-size: 14px;
    margin-bottom: 12px;
    font-family: inherit;
}

.chatlyx-rating-feedback:focus {
    outline: none;
    border-color: #999;
}

#chatlyx-submit-rating {
    width: auto !important;
    padding: 10px 24px !important;
}

#chatlyx-submit-rating:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chatlyx-rating-thanks {
    font-size: 15px;
    color: #28a745;
    font-weight: 500;
}

.chatlyx-transcript-container {
    padding-top: 15px;
}

.chatlyx-transcript-container .chatlyx-btn-secondary {
    background: #f8f9fa;
    border: 1px solid #ddd;
    color: #333;
    font-size: 13px;
    padding: 8px 15px;
}

.chatlyx-transcript-container .chatlyx-btn-secondary:hover {
    background: #e9ecef;
}

#chatlyx-transcript-email {
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.2s;
}

#chatlyx-transcript-email:focus {
    border-color: #0073aa;
    outline: none;
}

/* Transcript Popup Refinement */
.chatlyx-transcript-popup {
    position: absolute;
    bottom: -100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid var(--chatlyx-border);
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1);
    padding: 20px 15px;
    z-index: 100;
    transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px 12px 0 0;
}

.chatlyx-transcript-popup.active {
    bottom: 0;
}

.chatlyx-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 99;
}

.chatlyx-popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

.chatlyx-popup-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
    color: #333;
}

.chatlyx-popup-body {
    margin-bottom: 15px;
}

.chatlyx-popup-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
}