/**
 * Styles du widget de chat Tom — design minimaliste
 *
 * @package Tom
 */

/* Container principal */
.tom-chat-widget {
    max-width: 800px;
    margin: 0 auto;
    background: #faf9f7;
    border-radius: 4px;
    border: 1px solid #e5e2dd;
    overflow: hidden;
    font-family: "DM Sans", -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Corps du chat */
.tom-chat-body {
    padding: 24px;
    overflow-y: auto;
    background: #faf9f7;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Scrollbar */
.tom-chat-body::-webkit-scrollbar {
    width: 4px;
}

.tom-chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.tom-chat-body::-webkit-scrollbar-thumb {
    background: #e5e2dd;
    border-radius: 2px;
}

.tom-chat-body::-webkit-scrollbar-thumb:hover {
    background: #c9a96e;
}

/* Messages */
.tom-message {
    display: flex;
    gap: 12px;
    animation: tom-fadeIn 0.2s ease-out;
}

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

.tom-message-assistant {
    align-items: flex-start;
}

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

.tom-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.87em;
    flex-shrink: 0;
}

.tom-message-assistant .tom-message-avatar {
    background: #1a1a1a;
    color: #faf9f7;
}

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

.tom-message-content {
    flex: 1;
    min-width: 0;
}

.tom-message-text {
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 0.93em;
    line-height: 1.65;
    word-wrap: break-word;
}

.tom-message-assistant .tom-message-text {
    background: #faf9f7;
    border: 1px solid #e5e2dd;
    color: #1a1a1a;
    max-width: 90%;
}

.tom-message-user .tom-message-text {
    background: #1a1a1a;
    color: #faf9f7;
    border: 1px solid #1a1a1a;
    max-width: 80%;
    margin-left: auto;
}

/* Sources */
.tom-message-sources {
    margin-top: 8px;
    padding-top: 8px;
}

.tom-message-sources-title {
    font-size: 0.73em;
    font-weight: 600;
    color: #8a8480;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: none;
}

.tom-message-sources-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.tom-message-source-link {
    font-size: 0.8em;
    color: #c9a96e;
    text-decoration: none !important;
    display: flex;
    align-items: center;
    gap: 5px;
}

.tom-message-source-link:hover {
    text-decoration: underline !important;
}

.tom-message-source-link::before {
    content: "→";
    font-weight: 500;
}

/* Zone de saisie */
.tom-chat-input-container {
    padding: 16px 24px;
    background: #faf9f7;
    border-top: 1px solid #e5e2dd;
}

.tom-chat-welcome {
    margin: 0 0 12px 0;
    font-size: 0.93em;
    line-height: 1.6;
    color: #5a5753;
}

.tom-chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: #ffffff;
    border: 1px solid #e5e2dd;
    border-radius: 4px;
    padding: 8px 12px;
    transition: border-color 0.15s;
}

.tom-chat-input-wrapper:focus-within {
    border-color: #c9a96e;
}

.tom-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 0.93em;
    font-family: inherit;
    line-height: 1.5;
    max-height: 120px;
    min-height: 24px;
    outline: none;
    color: #1a1a1a;
}

.tom-chat-input::placeholder {
    color: #b5b0aa;
}

.tom-chat-send-btn {
    /* Reset anti-thème */
    all: unset;
    box-sizing: border-box !important;
    /* Dimensions fixes */
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    /* Style */
    border: none !important;
    border-radius: 3px !important;
    background: #1a1a1a !important;
    color: #faf9f7 !important;
    opacity: 1 !important;
    visibility: visible !important;
    /* Layout */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    /* Interaction */
    cursor: pointer !important;
    transition: background-color 0.15s !important;
    /* Touch mobile */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.tom-chat-send-btn:hover {
    background: #c9a96e !important;
}

.tom-chat-send-btn:active {
    background: #b8924a !important;
}

.tom-chat-send-btn:disabled {
    background: #e5e2dd !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
}

/* S'assurer que le SVG à l'intérieur ne bloque pas les clics */
.tom-chat-send-btn svg {
    display: block;
    pointer-events: none;
    flex-shrink: 0;
}

.tom-chat-info-text {
    margin-top: 8px;
    text-align: center;
    font-size: 0.73em;
    color: #b5b0aa;
}

.tom-chat-info-text a {
    color: #c9a96e;
    text-decoration: none;
}

.tom-chat-info-text a:hover {
    text-decoration: underline;
}

/* Loader */
.tom-chat-loader {
    padding: 16px;
    display: flex;
    justify-content: flex-start;
}

.tom-chat-loader-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

.tom-chat-loader-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c9a96e;
    animation: tom-bounce 1.4s infinite ease-in-out both;
}

.tom-chat-loader-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.tom-chat-loader-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes tom-bounce {
    0%, 80%, 100% {
        transform: scale(0.5);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Erreur */
.tom-error {
    padding: 14px 16px;
    background: #faf9f7;
    border: 1px solid #e5e2dd;
    border-left: 3px solid #c9a96e;
    border-radius: 4px;
    color: #5a5753;
    font-size: 0.93em;
}

.tom-error a {
    color: #c9a96e;
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .tom-chat-widget {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .tom-chat-body {
        padding: 20px 16px;
    }

    .tom-chat-input-container {
        padding: 12px 16px;
    }

    .tom-chat-input-wrapper {
        padding: 10px 12px;
        gap: 8px;
        align-items: center;
    }

    .tom-chat-input {
        font-size: 16px; /* evite le zoom auto sur iOS */
        min-height: 28px;
    }

    /* Bouton plus grand pour un meilleur tap sur mobile */
    .tom-chat-send-btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        border-radius: 4px !important;
    }

    .tom-message-user .tom-message-text {
        max-width: 90%;
    }
}
