/**
 * KK Chatbot Frontend Styles
 */

/* Widget Container */
.kk-chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Chat Bubble */
.kk-chat-bubble {
    border-radius: 30px;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    padding: 16px 24px;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
}

.kk-chat-bubble-text {
    display: inline;
}

.kk-chat-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* Chat Window */
.kk-chat-window {
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 100px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.kk-chat-header {
    background: #1a1a2e;
    color: #fff;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.kk-chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.kk-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kk-contact-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    opacity: 0.8;
    border-radius: 4px;
    transition: opacity 0.2s ease, background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kk-contact-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

.kk-contact-btn:disabled {
    cursor: default;
}

.kk-contact-btn:disabled:hover {
    background: none;
}

.kk-chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
}

.kk-chat-close:hover {
    opacity: 1;
}

/* Consent Banner */
.kk-consent-banner {
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.kk-consent-banner p {
    margin: 0 0 12px;
    font-size: 13px;
    color: #555;
}

.kk-consent-banner label {
    display: block;
    margin-bottom: 12px;
    font-size: 13px;
    cursor: pointer;
}

.kk-consent-banner label input {
    margin-right: 6px;
}

.kk-consent-banner a {
    color: #0073aa;
}

/* Chat Body — wraps messages and lead form */
.kk-chat-body {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

/* Messages Area */
.kk-chat-messages {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Message Bubbles */
.kk-message {
    margin-bottom: 8px;
    padding: 12px 16px;
    border-radius: 14px;
    max-width: 88%;
    word-wrap: break-word;
    animation: kk-fade-in 0.3s ease;
}

@keyframes kk-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.kk-message-bot {
    background: #f0f0f1;
    color: #2c2c2c;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    font-size: 14.5px;
    line-height: 1.6;
    letter-spacing: 0.01em;
}

/* Formatted bot message content */
.kk-message-bot .kk-bot-paragraph {
    margin: 0 0 10px;
}

.kk-message-bot .kk-bot-paragraph:last-child {
    margin-bottom: 0;
}

.kk-message-bot .kk-bot-list {
    margin: 6px 0 10px;
    padding-left: 20px;
    list-style: disc;
}

.kk-message-bot .kk-bot-list:last-child {
    margin-bottom: 0;
}

.kk-message-bot .kk-bot-list li {
    margin-bottom: 5px;
    line-height: 1.55;
    padding-left: 2px;
}

.kk-message-bot .kk-bot-list li:last-child {
    margin-bottom: 0;
}

.kk-message-bot strong {
    font-weight: 600;
    color: #1a1a2e;
}

/* Links in bot messages */
.kk-message-bot .kk-bot-link {
    color: #0066b3;
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 102, 179, 0.3);
    transition: border-color 0.2s ease, color 0.2s ease;
    word-break: break-word;
}

.kk-message-bot .kk-bot-link:hover {
    color: #004a82;
    border-bottom-color: #004a82;
}

.kk-message-user {
    background: #1a1a2e;
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 4px;
    font-size: 14.5px;
    line-height: 1.5;
}

.kk-message-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    font-size: 13px;
}

/* Typing Indicator */
.kk-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 12px 18px;
}

.kk-typing span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: kk-bounce 1.4s ease-in-out infinite;
}

.kk-typing span:nth-child(1) { animation-delay: 0s; }
.kk-typing span:nth-child(2) { animation-delay: 0.2s; }
.kk-typing span:nth-child(3) { animation-delay: 0.4s; }

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

/* Input Area */
.kk-chat-input-area {
    display: flex;
    padding: 12px;
    border-top: 1px solid #e0e0e0;
    gap: 8px;
    flex-shrink: 0;
}

#kk-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
}

#kk-chat-input:focus {
    border-color: #1a1a2e;
}

/* Buttons */
.kk-btn-primary {
    background: #1a1a2e;
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    transition: background 0.2s ease;
}

.kk-btn-primary:hover {
    background: #2d2d4a;
}

.kk-btn-primary:disabled {
    background: #999;
    cursor: not-allowed;
}

.kk-btn-secondary {
    background: transparent;
    color: #666;
    border: 1px solid #d0d0d0;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    transition: background 0.2s ease;
}

.kk-btn-secondary:hover {
    background: #f5f5f5;
}

/* Lead Offer (inline prompt) */
.kk-lead-offer {
    background: #f7f5ff;
    border: 1px solid #e0daf5;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    animation: kk-fade-in 0.3s ease;
}

.kk-lead-offer p {
    margin: 0 0 4px;
    width: 100%;
    font-size: 13.5px;
    color: #444;
    line-height: 1.5;
}

.kk-btn-small {
    padding: 7px 14px;
    font-size: 13px;
    border-radius: 6px;
}

/* Lead Form — overlay within chat body */
.kk-lead-form {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    z-index: 2;
    padding: 20px;
    overflow-y: auto;
    animation: kk-fade-in 0.2s ease;
}

.kk-lead-form h4 {
    margin: 0 0 16px;
    font-size: 16px;
}

.kk-lead-form input,
.kk-lead-form textarea {
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 10px;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}

.kk-lead-form textarea {
    height: 80px;
    resize: vertical;
}

.kk-lead-form input:focus,
.kk-lead-form textarea:focus {
    outline: none;
    border-color: #1a1a2e;
}

.kk-form-buttons {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

/* Back Button in Lead Form */
.kk-lead-back {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    padding: 0 0 12px;
    display: block;
    transition: color 0.2s ease;
}

.kk-lead-back:hover {
    color: #1a1a2e;
}

/* Summary Card */
.kk-summary-card {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 14px;
    margin-top: 12px;
    text-align: left;
}

.kk-summary-card strong {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: #444;
}

.kk-summary-card p {
    margin: 0;
    font-size: 13px;
    color: #555;
    line-height: 1.5;
}

/* Success / Info Messages */
.kk-success-message,
.kk-info-message {
    text-align: center;
    padding: 30px 20px;
}

.kk-success-message h4 {
    color: #16a34a;
    font-size: 18px;
}

.kk-info-message h4 {
    margin-bottom: 10px;
}

.kk-info-message ul {
    list-style: none;
    padding: 0;
    margin: 12px 0 0;
}

.kk-info-message li {
    margin-bottom: 8px;
}

.kk-info-message a {
    color: #0073aa;
    text-decoration: none;
}

.kk-info-message a:hover {
    text-decoration: underline;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .kk-chatbot-widget {
        bottom: 10px;
        right: 10px;
    }

    .kk-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        border-radius: 8px;
    }

    .kk-chat-bubble {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        padding: 0;
        gap: 0;
    }

    .kk-chat-bubble-text {
        display: none;
    }
}
