/**
 * Upsell Chatbot — Widget CSS
 * Story 3.4 : Interface visiteur du chatbot
 *
 * Inspiré de formbot.css — structure adaptée, non copiée.
 */

/* ============================================================
   Variables CSS
   ============================================================ */
:root {
    --ucb-primary:     #4F46E5;
    --ucb-primary-dark:#3730A3;
    --ucb-bg:          #f9fafb;
    --ucb-border:      #e5e7eb;
    --ucb-bot-bubble:  #e5e7eb;
    --ucb-user-bubble: var(--ucb-primary);
    --ucb-text:        #111827;
    --ucb-text-light:  #6b7280;
    --ucb-radius:      12px;
    --ucb-radius-msg:  16px;
    --ucb-shadow:      0 2px 8px rgba(0, 0, 0, 0.08);
    --ucb-font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ============================================================
   Conteneur principal
   ============================================================ */
.ucb-widget {
    display: flex;
    flex-direction: column;
    max-width: 480px;
    width: 100%;
    background: var(--ucb-bg);
    border: 1px solid var(--ucb-border);
    border-radius: var(--ucb-radius);
    box-shadow: var(--ucb-shadow);
    font-family: var(--ucb-font);
    font-size: 15px;
    color: var(--ucb-text);
    overflow: hidden;
}

/* ============================================================
   Zone messages
   ============================================================ */
.ucb-messages {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 400px;
    max-height: 400px;
    overflow-y: auto;
    padding: 16px;
    scroll-behavior: smooth;
}

/* ============================================================
   Bulles de messages
   ============================================================ */
.ucb-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: var(--ucb-radius-msg);
    line-height: 1.4;
    word-break: break-word;
}

.ucb-message--bot {
    background: var(--ucb-bot-bubble);
    color: var(--ucb-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.ucb-message--user {
    background: var(--ucb-user-bubble);
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* ============================================================
   Indicateur de frappe (typing)
   ============================================================ */
#ucb-loading {
    padding: 8px 16px;
    align-self: flex-start;
}

.ucb-typing-indicator {
    display: inline-block;
    background: var(--ucb-bot-bubble);
    border-radius: 12px;
    padding: 8px 14px;
    color: var(--ucb-text-light);
    font-size: 18px;
    letter-spacing: 2px;
    animation: ucb-blink 1.2s step-end infinite;
}

@keyframes ucb-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

/* ============================================================
   Zone de saisie
   ============================================================ */
.ucb-input-area {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--ucb-border);
    background: #ffffff;
}

#ucb-text-input {
    flex: 1;
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid var(--ucb-border);
    border-radius: 8px;
    font-size: 15px;
    font-family: var(--ucb-font);
    color: var(--ucb-text);
    outline: none;
    transition: border-color 0.15s;
}

#ucb-text-input:focus {
    border-color: var(--ucb-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* ============================================================
   Date selects (DateMY, DateDMY…)
   ============================================================ */

.ucb-date-my-selects {
    display: flex;
    gap: 8px;
    flex: 1;
}

.ucb-date-select {
    flex: 1;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid var(--ucb-border);
    border-radius: 8px;
    font-size: 15px;
    font-family: var(--ucb-font);
    color: var(--ucb-text);
    background: #ffffff;
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.ucb-date-select:focus {
    border-color: var(--ucb-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* ============================================================
   Bouton d'envoi / confirmation
   ============================================================ */
.ucb-btn {
    flex-shrink: 0;
    padding: 9px 18px;
    background: var(--ucb-primary);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--ucb-font);
    cursor: pointer;
    transition: background 0.15s;
}

.ucb-btn:hover {
    background: var(--ucb-primary-dark);
}

.ucb-btn:active {
    transform: scale(0.97);
}

/* ============================================================
   Options radio / checkbox
   ============================================================ */
.ucb-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.ucb-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--ucb-border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    font-size: 14px;
}

.ucb-option:hover {
    background: #f3f4f6;
    border-color: var(--ucb-primary);
}

.ucb-option input[type="radio"],
.ucb-option input[type="checkbox"] {
    accent-color: var(--ucb-primary);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ============================================================
   Types de boutons — Story 7.1
   ============================================================ */
.ucb-option.btn-type-primary {
    background-color: var(--ucb-btn-type-primary-bg, #4F46E5);
    color: var(--ucb-btn-type-primary-text, #ffffff);
    border-color: var(--ucb-btn-type-primary-bg, #4F46E5);
}
.ucb-option.btn-type-secondary {
    background-color: var(--ucb-btn-type-secondary-bg, #6B7280);
    color: var(--ucb-btn-type-secondary-text, #ffffff);
    border-color: var(--ucb-btn-type-secondary-bg, #6B7280);
}
.ucb-option.btn-type-success {
    background-color: var(--ucb-btn-type-success-bg, #10B981);
    color: var(--ucb-btn-type-success-text, #ffffff);
    border-color: var(--ucb-btn-type-success-bg, #10B981);
}
.ucb-option.btn-type-danger {
    background-color: var(--ucb-btn-type-danger-bg, #EF4444);
    color: var(--ucb-btn-type-danger-text, #ffffff);
    border-color: var(--ucb-btn-type-danger-bg, #EF4444);
}
.ucb-option.btn-type-warning {
    background-color: var(--ucb-btn-type-warning-bg, #F59E0B);
    color: var(--ucb-btn-type-warning-text, #111827);
    border-color: var(--ucb-btn-type-warning-bg, #F59E0B);
}
.ucb-option.btn-type-info {
    background-color: var(--ucb-btn-type-info-bg, #3B82F6);
    color: var(--ucb-btn-type-info-text, #ffffff);
    border-color: var(--ucb-btn-type-info-bg, #3B82F6);
}
.ucb-option.btn-type-highlight {
    background-color: var(--ucb-btn-type-highlight-bg, #F59E0B);
    color: var(--ucb-btn-type-highlight-text, #111827);
    border-color: var(--ucb-btn-type-highlight-bg, #F59E0B);
}

/* ============================================================
   Dropdown — Story 7.2
   ============================================================ */
.ucb-dropdown {
    width: 100%;
    position: relative;
}
.ucb-dropdown-filter {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--ucb-border);
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--ucb-font);
    color: var(--ucb-text);
    outline: none;
    transition: border-color 0.15s;
    margin-bottom: 4px;
    box-sizing: border-box;
}
.ucb-dropdown-filter:focus {
    border-color: var(--ucb-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.ucb-dropdown-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
}
.ucb-dropdown-item {
    padding: 8px 12px;
    border: 1px solid var(--ucb-border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    font-size: 14px;
}
.ucb-dropdown-item:hover {
    background: #f3f4f6;
    border-color: var(--ucb-primary);
}
.ucb-dropdown-item.hidden {
    display: none;
}
.ucb-dropdown-empty {
    padding: 8px 12px;
    color: var(--ucb-text-light);
    font-style: italic;
}
.ucb-dropdown-empty.hidden {
    display: none;
}

/* ============================================================
   Responsive — mobile
   ============================================================ */
@media (max-width: 480px) {
    .ucb-widget {
        max-width: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
    }

    .ucb-messages {
        max-height: 55vh;
    }

    .ucb-message {
        max-width: 92%;
    }

    .ucb-input-area {
        padding: 10px 12px;
    }
}
