/* ============================================
   Digikraal AI Chatbot Widget
   ============================================ */

#dk-chatbot {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 10000;
    font-family: 'Inter', sans-serif;
}

/* Toggle Button */
#dk-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #FA8312, #e06b00);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(250, 131, 18, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#dk-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(250, 131, 18, 0.5);
}

#dk-chat-toggle.active {
    background: linear-gradient(135deg, #307CBB, #1e5a8f);
    box-shadow: 0 4px 20px rgba(48, 124, 187, 0.4);
}

/* Notification dot */
#dk-chat-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid white;
    animation: dk-pulse 2s infinite;
}

#dk-chat-toggle.active::after {
    display: none;
}

@keyframes dk-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Chat Panel */
#dk-chat-panel {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 380px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: dk-slideUp 0.3s ease;
}

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

/* Header */
#dk-chat-header {
    background: linear-gradient(135deg, #307CBB, #1e5a8f);
    color: white;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.dk-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dk-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.dk-chat-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.dk-chat-subtitle {
    font-size: 0.75rem;
    opacity: 0.8;
}

#dk-chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 4px;
}

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

/* Messages Area */
#dk-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 250px;
    max-height: 320px;
    background: #f8fafc;
}

/* Message Bubbles */
.dk-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.875rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.dk-msg-bot {
    align-self: flex-start;
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.dk-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #307CBB, #1e5a8f);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Typing Indicator */
.dk-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

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

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

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

/* Listing Cards */
.dk-listings-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.dk-listing-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: flex;
    gap: 10px;
    padding: 10px;
}

.dk-listing-card:hover {
    border-color: #307CBB;
    box-shadow: 0 2px 12px rgba(48, 124, 187, 0.15);
    transform: translateY(-1px);
}

.dk-listing-thumb {
    width: 70px;
    height: 70px;
    border-radius: 8px;
    object-fit: cover;
    background: #e2e8f0;
    flex-shrink: 0;
}

.dk-listing-thumb-placeholder {
    width: 70px;
    height: 70px;
    border-radius: 8px;
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.dk-listing-info {
    flex: 1;
    min-width: 0;
}

.dk-listing-title {
    font-weight: 600;
    font-size: 0.8rem;
    color: #1e293b;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dk-listing-meta {
    font-size: 0.7rem;
    color: #64748b;
    margin-bottom: 4px;
}

.dk-listing-price {
    font-weight: 700;
    font-size: 0.8rem;
    color: #307CBB;
}

.dk-listing-badge {
    display: inline-block;
    background: #FA8312;
    color: white;
    font-size: 0.6rem;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
    margin-left: 4px;
    vertical-align: middle;
}

.dk-listing-view-btn {
    display: inline-block;
    margin-top: 6px;
    padding: 4px 12px;
    background: linear-gradient(135deg, #307CBB, #1e5a8f);
    color: white;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.2s;
}

.dk-listing-view-btn:hover {
    opacity: 0.9;
    color: white;
}

.dk-listing-view-btn i {
    margin-left: 3px;
    font-size: 0.6rem;
}

/* View All Button */
.dk-view-all-btn {
    display: block;
    text-align: center;
    padding: 8px;
    background: linear-gradient(135deg, #307CBB, #1e5a8f);
    color: white;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    margin-top: 4px;
    transition: opacity 0.2s;
}

.dk-view-all-btn:hover {
    opacity: 0.9;
    color: white;
}

/* Quick Actions */
#dk-chat-quick-actions {
    padding: 8px 16px;
    display: flex;
    gap: 8px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.dk-quick-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #307CBB;
    border-radius: 20px;
    background: white;
    color: #307CBB;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.dk-quick-btn:hover {
    background: #307CBB;
    color: white;
}

.dk-quick-btn i {
    margin-right: 4px;
}

/* Input Area */
#dk-chat-input-area {
    display: flex;
    padding: 12px 16px;
    gap: 8px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    flex-shrink: 0;
}

#dk-chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 8px 16px;
    font-size: 0.875rem;
    outline: none;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s;
}

#dk-chat-input:focus {
    border-color: #307CBB;
}

#dk-chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #307CBB, #1e5a8f);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

#dk-chat-send:hover {
    opacity: 0.9;
}

#dk-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #dk-chat-panel {
        width: calc(100vw - 2rem);
        right: -0.5rem;
        max-height: 70vh;
    }

    #dk-chatbot {
        bottom: 1rem;
        right: 1rem;
    }
}

/* Dark mode support */
html.dark-mode #dk-chat-panel {
    background: #1e293b;
}

html.dark-mode #dk-chat-messages {
    background: #0f172a;
}

html.dark-mode .dk-msg-bot {
    background: #334155;
    color: #e2e8f0;
    border-color: #475569;
}

html.dark-mode .dk-listing-card {
    background: #334155;
    border-color: #475569;
}

html.dark-mode .dk-listing-title {
    color: #e2e8f0;
}

html.dark-mode #dk-chat-input {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

html.dark-mode #dk-chat-quick-actions {
    background: #0f172a;
    border-color: #334155;
}

html.dark-mode .dk-quick-btn {
    background: #334155;
    border-color: #307CBB;
    color: #93c5fd;
}

html.dark-mode #dk-chat-input-area {
    background: #1e293b;
    border-color: #334155;
}
