/* Chat Widget Styles */
.chat-widget-container {
    position: relative;
    z-index: 1000;
}

/* Floating button (default, mobile first) */
.chat-widget-button {
    position: fixed;
    bottom: 95px; /* Déplacé vers le haut pour ne pas cacher la navigation mobile */
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    border: none;
    box-shadow: none;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1001;
}

.chat-widget-button:hover {
    transform: scale(1.1);
}

.chat-widget-box {
    position: fixed;
    bottom: 160px; /* Aligné avec le nouveau bouton */
    right: 20px;
    width: 360px;
    max-width: calc(100% - 40px);
    height: 480px;
    max-height: calc(100vh - 180px); /* Pour ne pas déborder sur les petits écrans */
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: none;
    overflow: hidden;
    display: none;
    flex-direction: column;
    z-index: 1000;
}

.chat-widget-box.open {
    display: flex;
    animation: slideUp 0.3s ease;
}

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

.chat-widget-header {
    background: var(--color-primary);
    color: white;
    padding: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-widget-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-widget-close {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s;
}

.chat-widget-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-widget-messages {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message {
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 80%;
    font-size: 14px;
    line-height: 1.5;
}

.chat-message.user {
    background: var(--color-primary);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant {
    background: var(--bg-primary);
    color: var(--text-primary);
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.chat-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--bg-primary);
    border-radius: 12px;
    margin-right: auto;
    border-bottom-left-radius: 4px;
    max-width: 70px;
}

.chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-primary);
    animation: typing 1.4s infinite both;
}

.chat-typing span:nth-child(1) { animation-delay: -0.32s; }
.chat-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

.chat-widget-input-container {
    padding: 12px;
    border-top: 1px solid var(--bg-tertiary);
    display: flex;
    gap: 8px;
    background: var(--bg-primary);
}

.chat-widget-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--bg-tertiary);
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.chat-widget-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-primary);
    border: none;
    color: white;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.chat-widget-send:hover {
    transform: scale(1.1);
}

/* Responsive Styles */
/* Mobile (≤992px): Show only floating widget */
@media (max-width: 992px) {
    #chat-widget-sidebar-container {
        display: none !important;
    }
}

/* Desktop (≥993px): Show sidebar widget, hide floating widget for client area */
@media (min-width: 993px) {
    #chat-widget-sidebar-container {
        display: block !important;
    }
    
    #chat-widget-float-container {
        display: none !important;
    }
    
    #chat-widget-sidebar-container .chat-widget-button {
        position: relative;
        bottom: auto;
        right: auto;
        width: 100%;
        height: auto;
        border-radius: 10px;
        font-size: 14px;
        padding: 0.6rem 0.8rem;
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }
    
    #chat-widget-sidebar-container .chat-widget-button .chat-button-text {
        display: inline !important;
        font-weight: 600;
    }
    
    #chat-widget-sidebar-container .chat-widget-box {
        position: absolute;
        bottom: calc(100% + 10px);
        right: 0;
        width: 360px;
    }
}

/* Elegant Chat Page Styles */
.elegant-chat-page {
    height: 100vh;
    background: var(--bg-secondary);
    padding: 0;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    margin: 0;
    overflow: hidden;
    position: relative;
}

.chat-container {
    width: 100%;
    max-width: 100%;
    background: var(--bg-secondary);
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100vh;
}

.chat-messages-area {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background: var(--bg-secondary);
}

.welcome-section {
    text-align: center;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80%;
}

.welcome-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--color-primary);
}

.welcome-section h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

.welcome-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0 0 1.5rem 0;
}

.suggestion-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.suggestion-card {
    background: var(--bg-primary);
    border: 1px solid var(--bg-tertiary);
    border-radius: 12px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
}

.suggestion-card:hover {
    border-color: var(--color-primary);
}

.suggestion-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.suggestion-text h3 {
    margin: 0 0 0.25rem 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.suggestion-text p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.chat-input-area {
    padding: 0.75rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--bg-tertiary);
    flex-shrink: 0;
    position: fixed;
    bottom: 10px;
    left: 0;
    right: 0;
    z-index: 100;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--bg-tertiary);
    border-radius: 12px;
    padding: 0.6rem 0.8rem;
    transition: all 0.2s ease;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.input-wrapper:focus-within {
    border-color: var(--color-primary);
}

.elegant-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.9rem;
    color: var(--text-primary);
    resize: none;
    outline: none;
    font-family: inherit;
    line-height: 1.4;
}

.elegant-input::placeholder {
    color: var(--text-secondary);
}

.send-btn-elegant {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: var(--color-primary);
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.send-btn-elegant:hover {
    opacity: 0.9;
}

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

/* Message Styles for Elegant Page */
.elegant-message {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.elegant-message.user {
    flex-direction: row-reverse;
}

.elegant-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.elegant-message.assistant .elegant-message-avatar {
    background: var(--color-primary);
    color: white;
}

.elegant-message.user .elegant-message-avatar {
    background: var(--text-secondary);
    color: white;
}

.elegant-message-content {
    max-width: 80%;
}

.elegant-message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.elegant-message.assistant .elegant-message-bubble {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

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

.elegant-message-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    padding: 0 0.5rem;
}

/* Responsive for Elegant Chat Page */
@media (max-width: 992px) {
    .elegant-chat-page {
        padding: 0;
        background: var(--bg-secondary);
        height: 100vh;
        overflow: hidden;
    }
    
    .chat-container {
        border-radius: 0;
        height: 100vh;
        max-height: none;
        display: flex;
        flex-direction: column;
    }
    
    .chat-messages-area {
        flex: 1;
        padding: 1rem;
        padding-bottom: 220px;
        overflow-y: auto;
    }
    
    .suggestion-cards {
        grid-template-columns: 1fr;
        max-width: 400px;
    }
    
    .chat-input-area {
        padding: 0.75rem;
        flex-shrink: 0;
        position: fixed;
        bottom: 70px; /* Espace pour la navigation mobile au lieu du padding massif */
        left: 0;
        right: 0;
        z-index: 90;
        background: var(--bg-primary);
        box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
    }
    
    .elegant-message-content {
        max-width: 85%;
    }
}

/* For client area mobile to make sure input is above the bottom nav */
@media (max-width: 992px) {
    .client-layout .elegant-chat-page {
        padding: 0;
        height: 100vh;
        overflow: hidden;
    }
    
    .client-layout .chat-container {
        height: 100vh;
    }
    
    .client-layout .chat-messages-area {
        padding-bottom: 180px;
    }
    
    .client-layout .chat-input-area {
        bottom: 70px;
        padding-bottom: 0.75rem;
    }
}

@media (min-width: 993px) {
    .elegant-chat-page {
        padding: 0;
        min-height: calc(100vh - 80px); /* Ajuster selon le header */
        margin-top: 20px;
    }
    
    .chat-container {
        border-radius: 16px;
        height: calc(100vh - 120px);
        max-height: 800px;
        box-shadow: 0 8px 32px rgba(0,0,0,0.08);
        border: 1px solid var(--border-color, #eaeaea);
        margin: 0 auto;
        max-width: 1000px;
    }
    
    .chat-input-area {
        position: relative; /* Relative au conteneur au lieu de fixed */
        bottom: auto;
        left: auto;
        right: auto;
        padding: 1rem;
        z-index: 100;
        border-radius: 0 0 16px 16px;
    }
    
    .chat-messages-area {
        padding: 1.5rem;
        padding-bottom: 2rem;
        margin-left: 0;
    }
    
    .input-wrapper {
        max-width: 100%;
    }
}
/* Markdown formatting in chatbot */
.chat-message strong, .elegant-message-bubble strong { font-weight: bold; }
.chat-message p, .elegant-message-bubble p { margin-bottom: 0.5em; }
.chat-message p:last-child, .elegant-message-bubble p:last-child { margin-bottom: 0; }
.chat-message ul, .elegant-message-bubble ul { list-style-type: disc; padding-left: 1.5em; margin-bottom: 0.5em; }
.chat-message ol, .elegant-message-bubble ol { list-style-type: decimal; padding-left: 1.5em; margin-bottom: 0.5em; }
.chat-message li, .elegant-message-bubble li { margin-bottom: 0.25em; }
.chat-message table, .elegant-message-bubble table { width: 100%; border-collapse: collapse; margin-bottom: 0.5em; }
.chat-message th, .elegant-message-bubble th { border: 1px solid rgba(0,0,0,0.1); padding: 0.3em; background: rgba(0,0,0,0.05); text-align: left; }
.chat-message td, .elegant-message-bubble td { border: 1px solid rgba(0,0,0,0.1); padding: 0.3em; }
.chat-message code, .elegant-message-bubble code { background: rgba(0,0,0,0.1); padding: 0.1em 0.3em; border-radius: 3px; font-family: monospace; }
.chat-message pre, .elegant-message-bubble pre { background: rgba(0,0,0,0.8); color: #fff; padding: 0.5em; border-radius: 5px; overflow-x: auto; font-family: monospace; margin-bottom: 0.5em; }
.chat-message pre code, .elegant-message-bubble pre code { background: none; color: inherit; padding: 0; }
.chat-message blockquote, .elegant-message-bubble blockquote { border-left: 3px solid rgba(0,0,0,0.2); padding-left: 0.5em; margin: 0.5em 0; color: inherit; opacity: 0.8; }

/* Horizontal Suggestions */
.suggestion-cards-horizontal {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}
.suggestion-cards-horizontal::-webkit-scrollbar {
    display: none;
}
.suggestion-cards-horizontal {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.suggestion-card-chip {
    flex: 0 0 auto;
    background: var(--bg-tertiary, #f0f0f0);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 20px;
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary, #333);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.suggestion-card-chip:hover {
    background: var(--color-primary, #e83e8c);
    color: white;
    border-color: var(--color-primary, #e83e8c);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.suggestion-card-chip i {
    font-size: 0.9rem;
}

/* Center the suggestion cards on large screens */
@media (min-width: 768px) {
    .suggestion-cards-horizontal {
        justify-content: center;
    }
}
