/* =========================================
   CHATBOT ORIA
   Messages: bot à gauche, user à droite
   Mobile: header du site visible (top: 70px)
   ========================================= */

:root {
    --oria-gradient: linear-gradient(135deg, #e63946 0%, #c13584 50%, #7f56d9 100%);
    --oria-gradient-header: linear-gradient(135deg, #d63447 0%, #b8296d 50%, #9333ea 100%);
    --oria-gradient-hover: linear-gradient(135deg, #c53038 0%, #a02870 50%, #6941c6 100%);
    --oria-pink: #c13584;
    --oria-radius: 12px;
}

/* ========================================
   BACKDROP
   ======================================== */
.oria-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9999998;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.oria-backdrop.show {
    opacity: 1;
}

/* ========================================
   CONTAINER
   ======================================== */
.oria-container {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 450px;
    display: none;
    flex-direction: column;
    background: #fff;
    border-left: 1px solid #e0e0e0;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 9999999;
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.oria-container.show {
    transform: translateX(0);
}

/* ========================================
   HEADER ORIA
   ======================================== */
.oria-header {
    flex-shrink: 0;
    padding: 14px 20px;
    background: var(--oria-gradient-header);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.oria-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0%   { left: -100%; }
    100% { left: 100%; }
}

.oria-header h1 {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.oria-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    position: relative;
    z-index: 1;
}

.header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.08);
}

.header-btn img {
    width: 18px;
    height: 18px;
    filter: brightness(0) invert(1);
}

.new-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================================
   BODY — Zone de messages
   ======================================== */
.oria-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f7f7f8;
    min-height: 0;
    scroll-behavior: smooth;
}

.oria-body::-webkit-scrollbar { width: 5px; }
.oria-body::-webkit-scrollbar-track { background: transparent; }
.oria-body::-webkit-scrollbar-thumb {
    background: var(--oria-gradient);
    border-radius: 10px;
}

/* ========================================
   MESSAGES — Structure
   msg-row > msg-bubble > msg-avatar + msg-text
   ======================================== */
.msg-row {
    display: flex;
    margin-bottom: 14px;
    animation: msgIn 0.3s ease;
}

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

.msg-row--bot {
    justify-content: flex-start;
}

.msg-row--user {
    justify-content: flex-end;
}

.msg-bubble {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 85%;
}

.msg-bubble--user {
    flex-direction: row-reverse;
}

/* Avatar */
.msg-avatar {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    margin-top: 2px;
}

.msg-avatar img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: block;
}

.msg-bubble--user .msg-avatar img {
    filter: brightness(0) invert(1);
    background: var(--oria-gradient);
    padding: 4px;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    box-sizing: border-box;
}

/* Texte */
.msg-text {
    padding: 10px 14px;
    border-radius: var(--oria-radius);
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}

.msg-bubble--bot .msg-text {
    background: #eef0f4;
    color: #2d2d2d;
    border-top-left-radius: 4px;
}

.msg-bubble--user .msg-text {
    background: var(--oria-gradient);
    color: #fff;
    border-top-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(193, 53, 132, 0.2);
}

/* ========================================
   Message initial (bot-bubble legacy)
   ======================================== */
.bot-message {
    display: flex;
    margin-bottom: 14px;
}

.bot-bubble {
    background: #eef0f4;
    border-radius: var(--oria-radius);
    border-top-left-radius: 4px;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.55;
    color: #2d2d2d;
    max-width: 85%;
}

.bot-bubble button {
    border: none;
    background: none;
    padding: 0;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

.bot-bubble button img {
    width: 25px;
    height: 25px;
    border-radius: 50%;
}

/* ========================================
   CONTENU BOT — Liens, listes
   ======================================== */
.msg-bubble--bot .msg-text a,
.bot-bubble a {
    color: var(--oria-pink);
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid rgba(193, 53, 132, 0.3);
    transition: border-color 0.2s;
}

.msg-bubble--bot .msg-text a:hover,
.bot-bubble a:hover {
    border-bottom-color: var(--oria-pink);
}

.msg-bubble--bot .msg-text ul,
.bot-bubble ul {
    margin: 8px 0 4px;
    padding-left: 8px;
    list-style: none;
}

.msg-bubble--bot .msg-text ul li,
.bot-bubble ul li {
    margin: 5px 0;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 13px;
}

.msg-bubble--bot .msg-text ul li:hover,
.bot-bubble ul li:hover {
    background: rgba(193, 53, 132, 0.08);
    color: var(--oria-pink);
}

/* Quick replies */
.quick-replies ul {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.quick-replies ul li {
    background: rgba(193, 53, 132, 0.08);
    border: 1px solid rgba(193, 53, 132, 0.2);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: #5a2d4a;
}

.quick-replies ul li:hover {
    background: var(--oria-gradient);
    color: #fff;
    border-color: transparent;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(193, 53, 132, 0.25);
}

/* ========================================
   TYPING INDICATOR
   ======================================== */
.typing-loader {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 4px;
}

.typing-loader span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-loader span:nth-child(1) { background: #e63946; animation-delay: 0s; }
.typing-loader span:nth-child(2) { background: #c13584; animation-delay: 0.2s; }
.typing-loader span:nth-child(3) { background: #7f56d9; animation-delay: 0.4s; }

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

/* ========================================
   INPUT AREA
   ======================================== */
.input-area {
    flex-shrink: 0;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #e5e5e5;
}

.input-wrapper {
    position: relative;
}

.input-wrapper textarea {
    width: 100%;
    height: 52px;
    padding: 14px 48px 14px 14px;
    border: 2px solid #d5d5d5;
    border-radius: var(--oria-radius);
    resize: none;
    font-family: inherit;
    font-size: 14px;
    box-sizing: border-box;
    background: #f9fafb;
    transition: border-color 0.2s, box-shadow 0.2s;
    overflow: hidden;
}

.input-wrapper textarea::placeholder {
    color: #999;
}

.input-wrapper textarea:focus {
    outline: none;
    border-color: var(--oria-pink);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(193, 53, 132, 0.1);
}

.char-counter {
    position: absolute;
    bottom: -18px;
    right: 2px;
    font-size: 10px;
    color: #aaa;
}

.char-counter.warning {
    color: #e63946;
    font-weight: 600;
}

.send-button {
    position: absolute;
    right: 6px;
    bottom: 8px;
    background: var(--oria-gradient);
    border: none;
    padding: 9px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-button:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 3px 12px rgba(193, 53, 132, 0.4);
}

.send-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.send-button i {
    font-size: 15px;
    color: #fff;
}

#loadingIcon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ========================================
   BOUTON FLOTTANT
   ======================================== */
.oria-footer {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 999999;
}

.oria-footer .action-button {
    background: var(--oria-gradient);
    color: #fff !important;
    border: none;
    padding: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    box-shadow: 0 4px 16px rgba(193, 53, 132, 0.4);
    transition: all 0.3s ease;
    text-decoration: none !important;
    position: relative;
    overflow: hidden;
}

.oria-footer .action-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(193, 53, 132, 0.55);
}

.oria-footer .action-button img {
    width: 19px;
    height: 19px;
    position: relative;
    z-index: 1;
}

/* ========================================
   MODAL CONFIRMATION
   ======================================== */
#oriaConfirmOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 99999999;
}

#oriaConfirmModal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 24px;
    z-index: 999999999;
    width: 90%;
    max-width: 340px;
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translate(-50%, -45%); }
    to   { opacity: 1; transform: translate(-50%, -50%); }
}

#oriaConfirmModal p {
    margin-bottom: 20px;
    font-size: 14px;
    color: #333;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

#oriaCancelBtn {
    background: #f0f0f0;
    color: #333;
}

#oriaCancelBtn:hover { background: #e0e0e0; }

#oriaConfirmBtn {
    background: var(--oria-gradient);
    color: #fff;
}

#oriaConfirmBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(193, 53, 132, 0.35);
}

/* ========================================
   RESPONSIVE MOBILE — Un seul bloc
   ======================================== */
@media (max-width: 768px) {
    .oria-container {
        max-width: 100%;
        top: 70px;
        left: 0;
        right: 0;
        bottom: 0;
        height: calc(100vh - 70px);
        border-left: none;
        border-radius: 0;
    }

    .oria-header {
        padding: 12px 16px;
    }

    .oria-header h1 {
        font-size: 16px;
    }

    .oria-body {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
        padding: 14px;
    }

    .input-area {
        flex-shrink: 0;
        padding: 10px 12px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }

    .msg-bubble {
        max-width: 90%;
    }

    .msg-text {
        font-size: 13.5px;
    }

    .msg-avatar {
        width: 24px;
        height: 24px;
    }

    .msg-avatar img {
        width: 24px;
        height: 24px;
    }

    .msg-bubble--user .msg-avatar img {
        width: 24px;
        height: 24px;
    }

    .bot-bubble {
        font-size: 13.5px;
    }
}