﻿/* GAP1 Chat Widget Styles */

.gap1-chat-button {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #7CC242 0%, #69B32E 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(124, 194, 66, 0.4);
    transition: all 0.3s ease;
    z-index: 9998;
}

.gap1-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(124, 194, 66, 0.5);
}

.gap1-chat-button.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.gap1-chat-widget {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
    z-index: 9999;
    overflow: hidden;
}

.gap1-chat-widget.open {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

/* Header */
.gap1-chat-header {
    background: linear-gradient(135deg, #7CC242 0%, #69B32E 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.gap1-chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    direction: rtl;
}

.gap1-chat-header-icons {
    display: flex;
    justify-content: center;
    align-items: center;
}

.gap1-chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: white;
    border: 2px solid #7CC242;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gap1-chat-avatar:first-child {
    margin-left: 0;
}

.gap1-chat-header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.gap1-chat-header-text p {
    margin: 4px 0 0;
    font-size: 12px;
    opacity: 0.9;
    transition: all 0.3s ease;
}

.gap1-chat-header-text p.admin-active {
    color: white !important;
    font-weight: bold !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    opacity: 1;
}

.gap1-chat-header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.gap1-chat-close,
.gap1-chat-new {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.gap1-chat-close:hover,
.gap1-chat-new:hover {
    background: rgba(255, 255, 255, 0.2);
}

.gap1-chat-new {
    position: relative;
}

.gap1-chat-new:hover::after {
    content: attr(title);
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 12px;
    white-space: nowrap;
    border-radius: 4px;
    z-index: 10000;
}

/* Body */
.gap1-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #F5F5F5;
    direction: rtl;
}

.gap1-welcome-message {
    text-align: center;
    padding: 12px 16px;
    font-size: 14px;
    color: #333;
    margin-bottom: 16px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Categories */
.gap1-categories {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Add spacing above button containers when they follow messages */
.gap1-chat-buttons-container {
    margin-top: 16px;
}

.gap1-category-btn {
    background: linear-gradient(135deg, #7CC242 0%, #69B32E 100%);
    color: white;
    border: none;
    margin: 1px; /* Don't change it */
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(124, 194, 66, 0.25);
    text-align: center;
    width: 100%;
    white-space: normal;
    line-height: 1.5;
    min-height: 48px;
    opacity: 0;
    transform: translateY(-10px);
    animation: slideIn 0.3s ease forwards;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gap1-category-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(124, 194, 66, 0.35);
}

.gap1-back-btn {
    background: linear-gradient(135deg, #6C757D 0%, #5A6268 100%);
}

/* Chat Messages */
.gap1-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 0px; /* Zero gap for ultra-tight stacking of image messages */
}

/* Add back spacing for text messages only */
.gap1-message-bot,
.gap1-message-assistant,
.gap1-message-system {
    margin-top: 8px;
}

/* Admin messages need spacing too */
.gap1-message-admin {
    margin-top: 8px;
}

/* Text-only user messages get extra spacing too */
.gap1-message-user:not(:has(.gap1-message-images-container)) {
    margin-top: 8px;
}

/* CRITICAL: REMOVE ALL spacing from image messages */
.gap1-message-user:has(.gap1-message-images-container) {
    margin: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
    line-height: 0 !important; /* Remove line-height spacing */
}

/* Add spacing when image message follows bot/assistant message */
.gap1-message-bot + .gap1-message-user:has(.gap1-message-images-container),
.gap1-message-assistant + .gap1-message-user:has(.gap1-message-images-container),
.gap1-message-admin + .gap1-message-user:has(.gap1-message-images-container) {
    margin-top: 12px !important;
}

/* Also remove any gap in the message wrapper for images */
.gap1-message:has(.gap1-message-images-container) {
    gap: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 0 !important; /* Remove line-height spacing */
}

.gap1-message {
    display: flex;
    gap: 8px;
    animation: fadeIn 0.3s ease;
}

/* Disable animation for image messages to prevent spacing issues */
.gap1-message:has(.gap1-message-images-container) {
    animation: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gap1-message-user {
    justify-content: flex-end;
}

.gap1-message-bot,
.gap1-message-assistant {
    justify-content: flex-start;
}

.gap1-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7CC242 0%, #69B32E 100%);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Hide avatar for image messages to remove extra spacing */
}

/* Hide avatar completely for image-only messages */
.gap1-message-user:has(.gap1-message-images-container) .gap1-message-avatar {
    display: none !important;
}

.gap1-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap; /* Preserve line breaks and spaces */
}

.gap1-message-user .gap1-message-content {
    background: #7CC242;
    color: white;
    border-bottom-left-radius: 4px;
}

.gap1-message-bot .gap1-message-content,
.gap1-message-assistant .gap1-message-content {
    background: white;
    color: #333;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    white-space: pre-wrap; /* Preserve line breaks */
}

/* Admin Messages */
.gap1-message-admin {
    justify-content: flex-start;
}

.gap1-admin-avatar {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
}

/* Remove broken earlier rule and apply consistent bubble style */
.gap1-message-content.gap1-admin-message {
    background: #E3F2FD;
    border: 1px solid #90CAF9;
    color: #1565C0;
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    border-bottom-right-radius: 4px; /* same corner tweak */
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap; /* keep line breaks */
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    display: inline-block; /* shrink to content height */
    direction: rtl;
    text-align: right;
}

.gap1-admin-name {
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 4px;
    color: #1976D2;
}

/* System Messages */
.gap1-message-system {
    justify-content: center;
    margin: 8px 0;
}

.gap1-system-message {
    background: #FFF3E0;
    border: 1px solid #FFB74D;
    color: #E65100;
    padding: 8px 16px;
    border-radius: 16px;
    font-size: 12px;
    text-align: center;
    max-width: 80%;
}

/* Typing Indicator */
.gap1-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px 20px;
}

.gap1-typing span {
    width: 8px;
    height: 8px;
    background: #7CC242;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.gap1-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.gap1-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Questions in Chat */
.gap1-chat-questions-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 12px;
}

/* Footer - Always visible */
.gap1-chat-footer {
    padding: 16px;
    background: white;
    border-top: 1px solid #E0E0E0;
    display: block !important; /* Always show the footer */
}

.gap1-input-container {
    display: flex;
    gap: 8px;
    direction: rtl;
}

.gap1-input-container input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #E0E0E0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    direction: rtl;
}

.gap1-input-container input:focus {
    border-color: #7CC242;
}

.gap1-input-container button {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #7CC242 0%, #69B32E 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.gap1-input-container button svg {
    transform: scaleX(-1);
}

.gap1-input-container button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(124, 194, 66, 0.4);
}

/* Scrollbar */
.gap1-chat-body::-webkit-scrollbar {
    width: 6px;
}

.gap1-chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.gap1-chat-body::-webkit-scrollbar-thumb {
    background: #CBD5E0;
    border-radius: 3px;
}

.gap1-chat-body::-webkit-scrollbar-thumb:hover {
    background: #A0AEC0;
}

/* Responsive */
@media (max-width: 480px) {
    .gap1-chat-widget {
        width: calc(100% - 32px);
        height: calc(100% - 32px);
        bottom: 16px;
        left: 16px;
        border-radius: 12px;
        /* Adjust for mobile keyboards - use dvh (dynamic viewport height) */
        max-height: calc(100dvh - 32px);
    }
    
    .gap1-chat-button {
        bottom: 16px;
        left: 16px;
        /* Ensure button is always visible on mobile */
        z-index: 9998 !important;
        width: 56px;
        height: 56px;
    }
    
    /* Ensure input is visible above keyboard on mobile */
    .gap1-chat-footer {
        position: relative;
        z-index: 10;
    }
    
    /* Better scrolling when keyboard is open */
    .gap1-chat-body {
        /* Use dvh to account for mobile keyboard */
        max-height: calc(100dvh - 200px);
        scroll-padding-bottom: 100px;
    }
    
    /* Ensure input field stays in viewport when focused */
    .gap1-input-container input:focus {
        position: relative;
        z-index: 11;
    }
}

/* Additional mobile support for tablets and smaller screens */
@media (max-width: 768px) {
    .gap1-chat-button {
        /* Ensure visibility on tablets and larger mobile devices */
        z-index: 9998 !important;
    }
    
    .gap1-chat-widget {
        /* Ensure widget doesn't cover button on tablets */
        z-index: 9999 !important;
    }
}

/* Fallback for browsers that don't support dvh */
@supports not (height: 100dvh) {
    @media (max-width: 480px) {
        .gap1-chat-widget {
            max-height: calc(100vh - 32px);
        }
        
        .gap1-chat-body {
            max-height: calc(100vh - 200px);
        }
    }
}

/* Image Upload Styles */
#gap1-image-btn {
    background: transparent !important;
    border: 1px solid #E0E0E0;
    color: #7CC242;
}

#gap1-image-btn:hover {
    background: #F5F5F5 !important;
    border-color: #7CC242;
}

.gap1-image-upload {
    flex-direction: column;
    align-items: flex-end;
}

.gap1-image-preview-container {
    position: relative;
    display: inline-block;
    width: 100px;
    height: 100px;
}

.gap1-upload-progress {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gap1-progress-ring {
    transform: rotate(-90deg);
}

.gap1-progress-ring-circle {
    transition: stroke-dashoffset 0.3s;
    stroke-dasharray: 100 100;
    stroke-dashoffset: 100;
}

.gap1-progress-text {
    position: absolute;
    font-size: 12px;
    font-weight: 600;
    color: #7CC242;
}

/* CRITICAL: Remove all user message styling from image containers */
.gap1-message-user .gap1-message-content.gap1-message-images-container {
    background: transparent !important;
    padding: 0 !important;
    border-radius: 0 !important;
    max-width: none !important;
    box-shadow: none !important;
    color: inherit !important;
    margin: 0 !important; /* Ensure no margin */
}

/* Image display consistency - make all images thumbnails */
.gap1-message-images {
    display: flex;
    flex-direction: row; /* Standard row direction */
    flex-wrap: wrap;
    gap: 4px; /* Reduced from 8px to 4px for tighter horizontal spacing */
    background: transparent !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 0 !important; /* Remove line-height spacing */
    justify-content: flex-start; /* Align to start (left in LTR context) */
    direction: ltr; /* Override RTL to ensure left-to-right arrangement */
}

.gap1-message-images-container {
    background: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    line-height: 0 !important; /* Remove line-height spacing */
    font-size: 0 !important; /* Remove font-size inline spacing */
}

.gap1-message-image {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.3s;
    display: block;
    margin: 0 !important;
    line-height: 0 !important; /* Remove line-height spacing */
    vertical-align: top; /* Remove inline image spacing */
}

/* Lightbox Styles */
.gap1-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.gap1-lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    cursor: pointer;
}

.gap1-lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    z-index: 1;
}

.gap1-lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.gap1-lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.gap1-lightbox-close:hover {
    background: #f0f0f0;
}

.gap1-lightbox-prev,
.gap1-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 2;
}

.gap1-lightbox-prev:hover:not(:disabled),
.gap1-lightbox-next:hover:not(:disabled) {
    background: white;
    transform: translateY(-50%) scale(1.1);
}

.gap1-lightbox-prev:disabled,
.gap1-lightbox-next:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.gap1-lightbox-prev {
    left: -70px;
}

.gap1-lightbox-next {
    right: -70px;
}

.gap1-lightbox-prev svg path,
.gap1-lightbox-next svg path {
    fill: #333;
}

/* Responsive: move buttons inside on small screens */
@media (max-width: 768px) {
    .gap1-lightbox-prev {
        left: 10px;
    }
    
    .gap1-lightbox-next {
        right: 10px;
    }
}

.gap1-lightbox-counter {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
