/* ==========================================================================
   ChatKristen - Live Chat Widget Styles
   ========================================================================== */

#ck-chat-widget-container {
    position: fixed;
    bottom: 95px;
    right: 24px;
    z-index: 9999;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.ck-hidden {
    display: none !important;
}

/* Chat Toggle Button */
#ck-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--color-content-brand);
    color: var(--color-content-inverse);
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 8px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

#ck-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Chat Window */
#ck-chat-window {
    width: 350px;
    height: 500px;
    background: var(--color-card);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: ckFadeInUp 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    border: 1px solid var(--color-line-default);
}

@keyframes ckFadeInUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.ck-chat-header {
    background: var(--color-content-brand);
    color: var(--color-content-inverse);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ck-chat-title h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.ck-chat-status {
    font-size: 11px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ck-chat-status::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #4cd964;
    border-radius: 50%;
}

#ck-chat-close {
    background: none;
    border: none;
    color: var(--color-content-inverse);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    padding: 0;
}

#ck-chat-close:hover {
    opacity: 1;
}

/* Messages Area */
.ck-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--color-page);
}

.ck-chat-messages::-webkit-scrollbar {
    width: 5px;
}
.ck-chat-messages::-webkit-scrollbar-thumb {
    background: var(--color-line-brand);
    border-radius: 5px;
}

/* Message Bubbles */
.ck-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    flex-shrink: 0;
    animation: ckMessagePop 0.3s ease;
}

@keyframes ckMessagePop {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.ck-msg-header {
    font-size: 11px;
    margin-bottom: 4px;
    color: var(--color-content-tertiary);
}

/* User Message */
.ck-msg-user {
    background: var(--color-content-brand);
    color: var(--color-content-inverse);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ck-msg-user .ck-msg-header {
    display: none;
}

/* AI / Admin Message */
.ck-msg-ai, .ck-msg-admin {
    background: var(--color-surface-2);
    color: var(--color-content-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border: 1px solid var(--color-line-default);
}

/* System Message */
.ck-msg-system {
    align-self: center;
    background: var(--color-surface-3);
    color: var(--color-content-tertiary);
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 10px;
    max-width: 90%;
    text-align: center;
}

/* Typing Indicator */
.ck-chat-typing-indicator {
    padding: 10px 20px;
    font-size: 12px;
    color: var(--color-content-tertiary);
    background: var(--color-page);
    font-style: italic;
}

.ck-chat-typing-indicator span {
    animation: ckBlink 1.4s infinite both;
}
.ck-chat-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.ck-chat-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ckBlink {
    0% { opacity: 0.2; }
    20% { opacity: 1; }
    100% { opacity: 0.2; }
}

/* Input Area */
.ck-chat-input-area {
    padding: 15px;
    background: var(--color-card);
    border-top: 1px solid var(--color-line-default);
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

#ck-chat-input {
    flex: 1;
    border: 1px solid var(--color-line-default);
    border-radius: 12px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    height: 44px;
    max-height: 100px;
    outline: none;
    transition: border-color 0.2s ease;
    background: var(--color-surface-2);
    color: var(--color-content-primary);
}

#ck-chat-input:focus {
    border-color: var(--color-content-brand);
    background: var(--color-surface-1);
}

#ck-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--color-content-brand);
    color: var(--color-content-inverse);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

#ck-chat-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

#ck-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Responsive */
@media (max-width: 480px) {
    #ck-chat-widget-container {
        /* When chat window is active, it needs to be able to fill the screen */
        bottom: 0;
        right: 0;
    }

    #ck-chat-window {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        /* Handle iOS Safari safe areas and address bar */
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
        z-index: 99999;
    }
    
    #ck-chat-toggle {
        position: fixed;
        bottom: 24px;
        right: 24px;
        z-index: 9999;
        margin: 8px;
    }
}
