/* client_chat.css */
.ksgc-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.ksgc-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--ksg-chat-color, #3b82f6);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: transform 0.2s;
    padding: 0;
}

.ksgc-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

.ksgc-toggle:hover {
    transform: scale(1.05);
}

.ksgc-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 450px;
    height: 600px;
    max-height: 80vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: ksgc-slideUp 0.3s ease;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ksgc-header {
    background: var(--ksg-chat-color, #3b82f6);
    color: white !important;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ksgc-header h3 {
    margin: 0 !important;
    font-size: 16px !important;
    color: white !important;
}

.ksgc-close {
    background: none !important;
    border: none !important;
    color: white !important;
    cursor: pointer !important;
    font-size: 18px !important;
    padding: 5px !important;
}

.ksgc-body {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ksgc-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
    box-sizing: border-box;
}

.ksgc-message.ksgc-me {
    align-self: flex-end;
    background: var(--ksg-chat-color, #3b82f6);
    color: white !important;
    border-bottom-right-radius: 2px;
}

.ksgc-message.ksgc-them {
    align-self: flex-start;
    background: #e5e7eb;
    color: #1f2937 !important;
    border-bottom-left-radius: 2px;
}

.ksgc-message.ksgc-bot {
    border-left: 3px solid var(--ksg-chat-color, #3b82f6);
}

.ksgc-attachment-img {
    max-width: 200px;
    cursor: pointer;
    border-radius: 8px;
    margin-top: 5px;
    display: block;
}

.ksgc-footer {
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    background: white;
    position: relative;
}

.ksgc-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ksgc-textarea {
    flex: 1;
    border: 1px solid #e5e7eb !important;
    border-radius: 20px !important;
    padding: 10px 15px !important;
    resize: none !important;
    font-family: inherit !important;
    font-size: 14px !important;
    max-height: 120px !important;
    outline: none !important;
    background: #fdfdfd !important;
    color: #333 !important;
}

.ksgc-textarea:focus {
    border-color: var(--ksg-chat-color, #3b82f6) !important;
}

.ksgc-send,
.ksgc-btn-icon {
    background: none !important;
    border: none !important;
    color: var(--ksg-chat-color, #3b82f6) !important;
    cursor: pointer !important;
    font-size: 20px !important;
    padding: 5px !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Auth Overlay */
.ksgc-auth-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.98);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 100;
}

.ksgc-auth-box {
    padding: 30px;
    width: 85%;
    box-sizing: border-box;
}

.ksgc-auth-box p {
    font-size: 14px;
    color: #4b5563;
    margin-bottom: 20px;
}

.ksgc-input {
    width: 100% !important;
    padding: 12px !important;
    margin-bottom: 12px !important;
    border: 1px solid #d1d5db !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    box-sizing: border-box !important;
}

.ksgc-btn {
    width: 100% !important;
    padding: 12px !important;
    background: var(--ksg-chat-color, #3b82f6) !important;
    color: white !important;
    border: none !important;
    border-radius: 8px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    margin-bottom: 10px !important;
}

.ksgc-btn-text {
    background: none !important;
    border: none !important;
    color: #6b7280 !important;
    font-size: 13px !important;
    text-decoration: underline !important;
    cursor: pointer !important;
}

/* Dropzone */
.ksgc-dropzone-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(59, 130, 246, 0.1);
    border: 2px dashed var(--ksg-chat-color, #3b82f6);
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 50;
    color: var(--ksg-chat-color, #3b82f6);
    font-weight: bold;
}

.ksgc-window.ksgc-dragover .ksgc-dropzone-overlay {
    display: flex;
}

/* Mode Switch */
.ksgc-mode-switch {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.15);
    padding: 3px;
    border-radius: 6px;
}

.ksgc-mode-btn {
    background: none !important;
    border: none !important;
    color: white !important;
    padding: 4px 10px !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    border-radius: 4px !important;
    transition: all 0.2s;
}

.ksgc-mode-btn.ksgc-active {
    background: white !important;
    color: var(--ksg-chat-color, #3b82f6) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Typing Indicator */
.ksgc-typing {
    display: none;
    align-self: flex-start;
    background: #e5e7eb;
    padding: 8px 12px;
    border-radius: 12px;
    border-bottom-left-radius: 2px;
    margin-bottom: 5px;
}

.ksgc-typing span {
    display: inline-block;
    width: 5px;
    height: 5px;
    background: #9ca3af;
    border-radius: 50%;
    margin: 0 2px;
    animation: ksgc-typingAnim 1.4s infinite;
}

.ksgc-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.ksgc-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes ksgc-typingAnim {

    0%,
    100% {
        transform: translateY(0);
        opacity: 0.6;
    }

    50% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Markdown Scoped Styling */
.ksgc-me p {
    color: white !important;
}

.ksgc-message p {
    margin: 0 0 10px 0;
}

.ksgc-message p:last-child {
    margin-bottom: 0;
}

.ksgc-message ul,
.ksgc-message ol {
    margin: 8px 0;
    padding-left: 20px;
}

.ksgc-message li {
    margin-bottom: 4px;
}

.ksgc-message table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
    font-size: 12px;
}

.ksgc-message th,
.ksgc-message td {
    border: 1px solid #ccc;
    padding: 4px 8px;
    text-align: left;
}

.ksgc-message th {
    background: rgba(0, 0, 0, 0.05);
}

.ksgc-message code {
    background: rgba(0, 0, 0, 0.08);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 12px;
}

.ksgc-message pre {
    background: #1f2937;
    color: white;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
}

.ksgc-message pre code {
    background: none;
    color: inherit;
    padding: 0;
}

.ksgc-message img {
    max-width: 100%;
    border-radius: 8px;
    margin: 8px 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

/* Image Modal */
.ksgc-image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 20000;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.ksgc-preview-img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

.ksgc-image-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none !important;
    border: none !important;
    color: white !important;
    font-size: 30px !important;
    cursor: pointer !important;
}

/* Responsive */
@media (max-width: 500px) {
    .ksgc-window {
        bottom: 0px;
        right: 0px;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        bottom: 0;
    }

    .ksgc-widget {
        bottom: 10px;
        right: 10px;
    }
}