/* K-TEC Customer Chat Widget */
#ktec-chat-widget {
    position: fixed;
    bottom: 100px;  /* sits above the WhatsApp button (which is at bottom: 20px) */
    right: 20px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#ktec-chat-widget * { box-sizing: border-box; }

#ktec-chat-toggle {
    background: linear-gradient(135deg, #1a5d96 0%, #0a3d6b 100%);
    color: #fff;
    border: none;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    padding: 0;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(10, 61, 107, 0.35);
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}
#ktec-chat-toggle .ktec-chat-toggle-text { display: none !important; }
#ktec-chat-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 28px rgba(10, 61, 107, 0.45);
}
.ktec-chat-toggle-icon { font-size: 18px; }

.ktec-chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 30px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
/* FIX (2026-10-07): Restore HTML5 hidden behavior. Without this, the close (X) button
   has no visible effect because .ktec-chat-window { display: flex } overrides [hidden]. */
.ktec-chat-window[hidden],
.ktec-chat-collapsed .ktec-chat-window,
#ktec-chat-image-preview[hidden] {
    display: none !important;
}


.ktec-chat-header {
    background: linear-gradient(135deg, #1a5d96 0%, #0a3d6b 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.ktec-chat-header-info { flex: 1; line-height: 1.3; }
.ktec-chat-header-info strong { display: block; font-size: 14px; }
.ktec-chat-header-info small { font-size: 11px; opacity: 0.85; }
.ktec-chat-header button {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
}
.ktec-chat-header button:hover { background: rgba(255, 255, 255, 0.3); }
.ktec-chat-clear { font-size: 14px !important; }

.ktec-chat-thread {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f7f8f9;
}
.ktec-chat-welcome-customer {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.ktec-chat-welcome-customer h3 { margin: 0 0 6px; font-size: 15px; }
.ktec-chat-welcome-customer p { margin: 0 0 12px; font-size: 13px; color: #555; line-height: 1.4; }

.ktec-chat-suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.ktec-suggestion {
    background: #eef2f7;
    color: #1a5d96;
    border: 1px solid #d6deea;
    border-radius: 14px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
.ktec-suggestion:hover { background: #d6deea; color: #1a5d96; }
.ktec-suggestion.shop-all {
    background: #fff;
    border-color: #1a5d96;
    color: #1a5d96;
    font-weight: 500;
}
.ktec-suggestion.shop-all:hover { background: #eef2f7; }

.ktec-msg {
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
}
.ktec-msg-user { align-items: flex-end; }
.ktec-msg-assistant { align-items: flex-start; }
.ktec-msg-bubble {
    max-width: 86%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.45;
    word-wrap: break-word;
}
.ktec-msg-user .ktec-msg-bubble {
    background: #1a5d96;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ktec-msg-assistant .ktec-msg-bubble {
    background: #fff;
    color: #1d1d1d;
    border: 1px solid #e8eaee;
    border-bottom-left-radius: 4px;
}
.ktec-msg-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 10px;
    border: 1px solid #e8eaee;
    margin-bottom: 4px;
}

.ktec-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
    max-width: 340px;
    margin-top: 6px;
}
.ktec-card {
    background: #fff;
    border: 1px solid #e8eaee;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.ktec-card-img {
    background: #f7f8f9;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ktec-card-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.ktec-card-body {
    padding: 6px 8px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ktec-card-title {
    font-size: 11px;
    line-height: 1.3;
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 36px;
}
.ktec-card-brand {
    background: #1a5d96;
    color: #fff;
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 6px;
    align-self: flex-start;
}
.ktec-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    margin-top: 2px;
}
.ktec-card-price { font-weight: 600; color: #1d1d1d; }
.ktec-card-stock.in { color: #008a00; }
.ktec-card-stock.out { color: #b32d2d; }
.ktec-card-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}
.ktec-card-fav-icon {
    flex: 0 0 auto !important;
    width: 28px !important;
    min-width: 28px;
    background: #fff !important;
    color: #888 !important;
    border: 1px solid #d0d7de !important;
    font-size: 14px !important;
    padding: 5px 0 !important;
}
.ktec-card-fav-icon:hover { background: #fff0f3 !important; color: #e0245e !important; }
.ktec-card-fav-icon.ktec-card-fav-on { color: #e0245e !important; border-color: #e0245e !important; }
.ktec-card-btn {
    flex: 1;
    background: #1a5d96;
    color: #fff;
    border: none;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    line-height: 1.2;
}
.ktec-card-btn:hover { background: #0a3d6b; color: #fff; }
.ktec-card-btn.secondary {
    background: #fff;
    color: #1a5d96;
    border: 1px solid #1a5d96;
}
.ktec-card-btn.secondary:hover { background: #eef2f7; color: #1a5d96; }
.ktec-card-btn.added { background: #008a00 !important; }

.ktec-chat-input-form {
    display: flex;
    gap: 6px;
    padding: 10px;
    background: #fff;
    border-top: 1px solid #e8eaee;
    align-items: flex-end;
}
.ktec-chat-input-form textarea {
    flex: 1;
    border: 1px solid #d6deea;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    resize: none;
    max-height: 100px;
    font-family: inherit;
}
.ktec-chat-input-form button {
    background: #1a5d96;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
}
.ktec-chat-input-form button:hover { background: #0a3d6b; }
#ktec-chat-image-btn {
    background: #fff !important;
    color: #1a5d96 !important;
    border: 1px solid #d6deea !important;
}
#ktec-chat-image-btn:hover { background: #eef2f7 !important; }

#ktec-chat-image-preview {
    padding: 6px 10px;
    background: #fff;
    border-top: 1px solid #e8eaee;
}
#ktec-chat-image-preview img {
    max-width: 80px;
    max-height: 80px;
    border-radius: 4px;
    vertical-align: middle;
}
.ktec-clear-preview {
    background: none;
    border: none;
    color: #b32d2d;
    cursor: pointer;
    margin-left: 8px;
    font-size: 16px;
}

.ktec-chat-typing {
    display: inline-flex;
    gap: 4px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #e8eaee;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.ktec-chat-typing span {
    width: 6px; height: 6px;
    background: #999;
    border-radius: 50%;
    animation: ktec-bounce 1.4s infinite ease-in-out both;
}
.ktec-chat-typing span:nth-child(1) { animation-delay: -0.32s; }
.ktec-chat-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes ktec-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

@media (max-width: 480px) {
    .ktec-chat-window {
        width: calc(100vw - 24px);
        right: -10px;
        bottom: 70px;
    }
    /* mobile chat toggle stays as small circular icon */
}