/**
 * HDKN Chatbot Widget Styles
 * Basé sur le design Adon AI
 */

/* Variables CSS */
:root {
    --hdkn-primary: #75dab4;
    --hdkn-secondary: #f0f0f0;
    --hdkn-header: #11141b;
    --hdkn-text: #1a1a1a;
    --hdkn-text-muted: #6b7280;
    --hdkn-white: #ffffff;
    --hdkn-border: #e5e7eb;
    --hdkn-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --hdkn-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --hdkn-radius: 16px;
    --hdkn-radius-sm: 8px;
    --hdkn-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --hdkn-z-index: 999999;
}

/* Reset */
#hdkn-chatbot,
#hdkn-chatbot *,
#hdkn-chatbot *::before,
#hdkn-chatbot *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--hdkn-font);
}

/* Container principal */
#hdkn-chatbot {
    position: fixed;
    bottom: 20px;
    z-index: var(--hdkn-z-index);
    font-size: 14px;
    line-height: 1.5;
    color: var(--hdkn-text);
}

#hdkn-chatbot.hdkn-position-right {
    right: 20px;
}

#hdkn-chatbot.hdkn-position-left {
    left: 20px;
}

/* ==================== BULLE FLOTTANTE ==================== */
.hdkn-bubble {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px 10px 10px;
    background: var(--hdkn-header);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: var(--hdkn-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.hdkn-bubble:hover {
    transform: scale(1.05);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
}

.hdkn-bubble-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--hdkn-primary);
}

.hdkn-bubble-text {
    color: var(--hdkn-white);
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
}

.hdkn-bubble-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--hdkn-header);
    animation: hdkn-pulse 2s infinite;
}

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

/* ==================== FENÊTRE DE CHAT ==================== */
.hdkn-window {
    display: none;
    flex-direction: column;
    position: absolute;
    bottom: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 100px);
    background: var(--hdkn-white);
    border-radius: var(--hdkn-radius);
    box-shadow: var(--hdkn-shadow);
    overflow: hidden;
    animation: hdkn-slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hdkn-position-right .hdkn-window {
    right: 0;
}

.hdkn-position-left .hdkn-window {
    left: 0;
}

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

#hdkn-chatbot.hdkn-open .hdkn-bubble {
    display: none;
}

#hdkn-chatbot.hdkn-open .hdkn-window {
    display: flex;
}

/* ==================== HEADER ==================== */
.hdkn-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--hdkn-header);
    color: var(--hdkn-white);
    flex-shrink: 0;
}

.hdkn-header-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--hdkn-primary);
}

.hdkn-header-info {
    flex: 1;
    min-width: 0;
}

.hdkn-header-name {
    display: block;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hdkn-header-desc {
    display: block;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hdkn-header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 2px;
}

.hdkn-status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
}

.hdkn-minimize {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: var(--hdkn-white);
    cursor: pointer;
    transition: background 0.2s;
}

.hdkn-minimize:hover {
    background: rgba(255, 255, 255, 0.2);
}

.hdkn-minimize svg {
    width: 20px;
    height: 20px;
}

/* ==================== ZONE DES MESSAGES ==================== */
.hdkn-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #fafafa;
}

/* Message */
.hdkn-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: hdkn-fadeIn 0.3s ease;
}

@keyframes hdkn-fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.hdkn-message-bot {
    align-self: flex-start;
}

.hdkn-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.hdkn-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.hdkn-message-user .hdkn-message-avatar {
    display: none;
}

.hdkn-message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hdkn-message-bubble {
    padding: 12px 16px;
    border-radius: var(--hdkn-radius);
    word-wrap: break-word;
    white-space: pre-wrap;
}

.hdkn-message-bot .hdkn-message-bubble {
    background: var(--hdkn-white);
    color: var(--hdkn-text);
    border: 1px solid var(--hdkn-border);
    border-bottom-left-radius: 4px;
}

.hdkn-message-user .hdkn-message-bubble {
    background: var(--hdkn-primary);
    color: var(--hdkn-header);
    border-bottom-right-radius: 4px;
}

.hdkn-message-time {
    font-size: 11px;
    color: var(--hdkn-text-muted);
}

/* Links in messages */
.hdkn-message-bubble a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.hdkn-message-bubble a:hover {
    opacity: 0.8;
}

/* Typing indicator */
.hdkn-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.hdkn-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--hdkn-text-muted);
    border-radius: 50%;
    animation: hdkn-typing 1.4s infinite;
}

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

@keyframes hdkn-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* ==================== QUESTIONS RAPIDES ==================== */
.hdkn-quick-questions {
    margin-top: 8px;
}

.hdkn-quick-intro {
    font-size: 12px;
    color: var(--hdkn-text-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.hdkn-quick-intro::before {
    content: '💡';
}

.hdkn-quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hdkn-quick-btn {
    padding: 8px 14px;
    background: var(--hdkn-white);
    border: 1px solid var(--hdkn-border);
    border-radius: 20px;
    font-size: 13px;
    color: var(--hdkn-text);
    cursor: pointer;
    transition: all 0.2s;
}

.hdkn-quick-btn:hover {
    background: var(--hdkn-primary);
    border-color: var(--hdkn-primary);
    color: var(--hdkn-header);
}

/* ==================== BOUTON WHATSAPP ==================== */
.hdkn-whatsapp-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 10px 16px;
    background: #25D366;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.hdkn-whatsapp-btn:hover {
    background: #1da851;
    transform: translateY(-1px);
}

.hdkn-whatsapp-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* ==================== LIENS UTILES ==================== */
.hdkn-useful-links {
    margin-top: 12px;
    padding: 12px;
    background: var(--hdkn-white);
    border-radius: var(--hdkn-radius-sm);
    border: 1px solid var(--hdkn-border);
}

.hdkn-links-intro {
    font-size: 12px;
    color: var(--hdkn-text-muted);
    margin-bottom: 8px;
}

.hdkn-link {
    display: block;
    padding: 6px 0;
    color: var(--hdkn-primary);
    text-decoration: none;
    font-size: 13px;
}

.hdkn-link:hover {
    text-decoration: underline;
}

/* ==================== FEEDBACK / RATING ==================== */
.hdkn-feedback {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 12px;
    background: var(--hdkn-white);
    border-radius: var(--hdkn-radius-sm);
    border: 1px solid var(--hdkn-border);
}

.hdkn-feedback-title {
    font-size: 12px;
    color: var(--hdkn-text-muted);
}

.hdkn-feedback-stars {
    display: flex;
    gap: 4px;
}

.hdkn-feedback-star {
    width: 28px;
    height: 28px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: #d1d5db;
    transition: all 0.2s;
}

.hdkn-feedback-star:hover,
.hdkn-feedback-star.active {
    color: #fbbf24;
    transform: scale(1.1);
}

.hdkn-feedback-star svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.hdkn-feedback-thanks {
    font-size: 13px;
    color: #22c55e;
    font-weight: 500;
}

/* ==================== ZONE DE SAISIE ==================== */
.hdkn-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    background: var(--hdkn-white);
    border-top: 1px solid var(--hdkn-border);
    flex-shrink: 0;
}

.hdkn-restart {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: 1px solid var(--hdkn-border);
    border-radius: 50%;
    color: var(--hdkn-text-muted);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.hdkn-restart:hover {
    background: var(--hdkn-secondary);
    color: var(--hdkn-text);
}

.hdkn-restart svg {
    width: 18px;
    height: 18px;
}

.hdkn-input-wrapper {
    flex: 1;
    position: relative;
}

.hdkn-textarea {
    width: 100%;
    min-height: 40px;
    max-height: 120px;
    padding: 10px 14px;
    background: var(--hdkn-secondary);
    border: 1px solid transparent;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

.hdkn-textarea:focus {
    border-color: var(--hdkn-primary);
}

.hdkn-textarea::placeholder {
    color: var(--hdkn-text-muted);
}

.hdkn-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--hdkn-primary);
    border: none;
    border-radius: 50%;
    color: var(--hdkn-header);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.hdkn-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(117, 218, 180, 0.4);
}

.hdkn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.hdkn-send svg {
    width: 18px;
    height: 18px;
}

/* ==================== POWERED BY ==================== */
.hdkn-powered {
    padding: 8px;
    text-align: center;
    background: var(--hdkn-white);
    border-top: 1px solid var(--hdkn-border);
    flex-shrink: 0;
}

.hdkn-powered a {
    font-size: 11px;
    color: var(--hdkn-text-muted);
    text-decoration: none;
}

.hdkn-powered a:hover {
    color: var(--hdkn-text);
}

.hdkn-powered strong {
    color: var(--hdkn-primary);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 480px) {
    #hdkn-chatbot {
        bottom: 10px;
    }

    #hdkn-chatbot.hdkn-position-right,
    #hdkn-chatbot.hdkn-position-left {
        right: 10px;
        left: 10px;
    }

    .hdkn-bubble-text {
        display: none;
    }

    .hdkn-bubble {
        padding: 8px;
        border-radius: 50%;
    }

    .hdkn-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        max-height: none;
        right: 0 !important;
        left: 0 !important;
        bottom: 0;
        border-radius: var(--hdkn-radius) var(--hdkn-radius) 0 0;
    }

    .hdkn-message {
        max-width: 90%;
    }
}

/* ==================== DARK MODE SUPPORT ==================== */
@media (prefers-color-scheme: dark) {
    :root {
        --hdkn-secondary: #2a2a2a;
        --hdkn-text: #f0f0f0;
        --hdkn-text-muted: #9ca3af;
        --hdkn-border: #404040;
    }

    .hdkn-window {
        background: #1a1a1a;
    }

    .hdkn-messages {
        background: #111;
    }

    .hdkn-message-bot .hdkn-message-bubble {
        background: #2a2a2a;
        color: #f0f0f0;
        border-color: #404040;
    }

    .hdkn-quick-btn {
        background: #2a2a2a;
        border-color: #404040;
        color: #f0f0f0;
    }

    .hdkn-input-area,
    .hdkn-powered {
        background: #1a1a1a;
        border-color: #404040;
    }

    .hdkn-textarea {
        background: #2a2a2a;
        color: #f0f0f0;
    }

    .hdkn-feedback,
    .hdkn-useful-links {
        background: #2a2a2a;
        border-color: #404040;
    }
}

/* ==================== SCROLLBAR STYLING ==================== */
.hdkn-messages::-webkit-scrollbar {
    width: 6px;
}

.hdkn-messages::-webkit-scrollbar-track {
    background: transparent;
}

.hdkn-messages::-webkit-scrollbar-thumb {
    background: var(--hdkn-border);
    border-radius: 3px;
}

.hdkn-messages::-webkit-scrollbar-thumb:hover {
    background: var(--hdkn-text-muted);
}

/* ==================== ANIMATIONS ==================== */
.hdkn-message-bot .hdkn-message-bubble {
    animation: hdkn-messageIn 0.3s ease;
}

@keyframes hdkn-messageIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.hdkn-message-user .hdkn-message-bubble {
    animation: hdkn-messageInRight 0.3s ease;
}

@keyframes hdkn-messageInRight {
    from {
        opacity: 0;
        transform: translateX(10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}
