/* Bouton pour ouvrir le modal */
#ricky-open-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #b8d4f0 0%, #d4b8d4 100%);
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(184, 212, 240, 0.4);
    transition: all 0.3s ease;
    z-index: 9998;
}

#ricky-open-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(184, 212, 240, 0.6);
}

/* Overlay du modal - VERSION AMÉLIORÉE */
#ricky-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(225, 239, 252, 0.7) 0%, rgba(240, 230, 239, 0.7) 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

#ricky-modal-overlay.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Modal principal */
#ricky-chat-modal {
    width: 90%;
    max-width: 1000px;  /* ← Plus large */
    height: 800px;
    background: linear-gradient(135deg, #e1effc 0%, #f0e6ef 100%);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.4s ease;
    position: relative;
}

/* Header du modal */
#ricky-modal-header {
    background: transparent;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
}

#ricky-modal-title {
    color: #333;
    font-size: 0;
    font-weight: bold;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

#ricky-modal-title::before {
    content: "";
    width: 70px;
    height: 70px;
    background-image: url('data:image/svg+xml,%3Csvg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath d="M 16 2 L 17.5 14 L 16 16 L 14.5 14 Z" fill="%237a8fb8"%3E%3C/path%3E%3Cpath d="M 16 30 L 17.5 18 L 16 16 L 14.5 18 Z" fill="%237a8fb8"%3E%3C/path%3E%3Cpath d="M 30 16 L 18 17.5 L 16 16 L 18 14.5 Z" fill="%237a8fb8"%3E%3C/path%3E%3Cpath d="M 2 16 L 14 17.5 L 16 16 L 14 14.5 Z" fill="%237a8fb8"%3E%3C/path%3E%3Cpath d="M 25 7 L 17.5 14.5 L 16 16 L 17 14 Z" fill="%237a8fb8" opacity="0.9"%3E%3C/path%3E%3Cpath d="M 7 7 L 14.5 14.5 L 16 16 L 15 14 Z" fill="%237a8fb8" opacity="0.9"%3E%3C/path%3E%3Cpath d="M 25 25 L 17.5 17.5 L 16 16 L 17 18 Z" fill="%237a8fb8" opacity="0.9"%3E%3C/path%3E%3Cpath d="M 7 25 L 14.5 17.5 L 16 16 L 15 18 Z" fill="%237a8fb8" opacity="0.9"%3E%3C/path%3E%3Ccircle cx="16" cy="16" r="2.5" fill="%23f5f5f5"%3E%3C/circle%3E%3Ccircle cx="16" cy="16" r="1.2" fill="white"%3E%3C/circle%3E%3C/svg%3E');
    background-size: contain;
    background-repeat: no-repeat;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

#ricky-modal-title::after {
    content: "Ricky";
    font-size: 24px;
    color: #7a8fb8;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(122, 143, 184, 0.2);
}

/* Boutons header - harmonisés avec le modal */
.header-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

#ricky-convs-btn,
#ricky-new-chat-btn,
#ricky-close-btn {
    background: linear-gradient(135deg, rgba(225, 239, 252, 0.6) 0%, rgba(240, 230, 239, 0.6) 100%);
    border: 2px solid rgba(184, 212, 240, 0.3);
    color: #7a8fb8;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}

#ricky-convs-btn:hover,
#ricky-new-chat-btn:hover,
#ricky-close-btn:hover {
    background: linear-gradient(135deg, rgba(225, 239, 252, 0.9) 0%, rgba(240, 230, 239, 0.9) 100%);
    border-color: rgba(184, 212, 240, 0.6);
    box-shadow: 0 4px 12px rgba(184, 212, 240, 0.3);
}

#ricky-convs-btn:hover {
    transform: scale(1.15) translateY(-2px);
}

#ricky-new-chat-btn:hover {
    transform: scale(1.15) rotate(180deg);
}

#ricky-close-btn:hover {
    transform: scale(1.15) rotate(90deg);
    color: #c4a5bf;
}

#ricky-convs-btn {
    font-size: 22px;
    font-weight: bold;
}

/* Zone de messages */
#ricky-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #ffffff;
    margin: 10px;
    border-radius: 15px;
}

/* Scrollbar personnalisée */
#ricky-messages::-webkit-scrollbar {
    width: 8px;
}

#ricky-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

#ricky-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #b8d4f0 0%, #d4b8d4 100%);
    border-radius: 10px;
}

/* Messages */
.ricky-msg {
    margin-bottom: 15px;
    animation: messageSlide 0.3s ease;
}

.ricky-msg strong {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ricky-msg.user {
    text-align: right;
}

.ricky-msg.user strong {
    color: #b8a8c8;
    text-shadow: 0 1px 2px rgba(184, 168, 200, 0.3);
}

.ricky-msg.user > div {
    background: linear-gradient(135deg, #b8d4f0 0%, #d4b8d4 100%);
    color: #4a5a7a;
    padding: 12px 16px;
    border-radius: 18px 18px 5px 18px;
    display: inline-block;
    max-width: 80%;
    word-wrap: break-word;
    box-shadow: 0 2px 10px rgba(184, 212, 240, 0.4);
}

.ricky-msg.bot strong {
    color: #8fa8c8;
    text-shadow: 0 1px 2px rgba(143, 168, 200, 0.3);
}

.ricky-msg.bot > div {
    background: #f0f0f0;
    color: #333;
    padding: 12px 16px;
    border-radius: 18px 18px 18px 5px;
    display: inline-block;
    max-width: 80%;
    word-wrap: break-word;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Animation de chargement */
.ricky-msg.loading {
    opacity: 0.7;
}

.typing {
    display: inline-block;
    animation: blink 1.4s infinite;
}

/* Barre d'input */
#ricky-input-bar {
    display: flex;
    padding: 15px;
    gap: 10px;
    background: transparent;
    border-top: 2px solid rgba(255, 255, 255, 0.3);
}

#ricky-user-input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #ccc;
    border-radius: 25px;
    outline: none;
    font-size: 15px;
    background: white;
    transition: all 0.3s;
}

#ricky-user-input:focus {
    border-color: #b8d4f0;
    box-shadow: 0 0 10px rgba(184, 212, 240, 0.5);
}

#ricky-send-btn {
    padding: 14px 24px;
    background: linear-gradient(135deg, #b8d4f0 0%, #d4b8d4 100%);
    color: #5a6d8f;
    border: 2px solid rgba(184, 212, 240, 0.5);
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    font-size: 15px;
    transition: all 0.3s;
    box-shadow: 0 2px 10px rgba(184, 212, 240, 0.4);
}

#ricky-send-btn:hover {
    transform: scale(1.05);
    background: linear-gradient(135deg, #c8e0f5 0%, #e0c8e0 100%);
    box-shadow: 0 4px 15px rgba(184, 212, 240, 0.6);
}

#ricky-send-btn:active {
    transform: scale(0.95);
}

/* Overlay derrière le modal conversations */
#conversations-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

/* Liste conversations - ajusté pour l'overlay */
#conversations-list {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    width: 400px;
    max-width: 90%;
    max-height: 80vh;
    background: rgba(30, 30, 50, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

/* Liste conversations - TRANSPARENT AMÉLIORÉ */
#conversations-list {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    max-width: 90%;
    max-height: 80vh;
    background: rgba(30, 30, 50, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    flex-direction: column;
}

.conv-list-header {
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-bottom: 2px solid rgba(255, 255, 255, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conv-list-header h3 {
    margin: 0;
    color: #ffffff;
    font-size: 20px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

#close-conv-list {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 22px;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#close-conv-list:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

.conv-list-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.conv-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 8px;  /* Réduit de 15px à 10px */
    margin: 2px 0;  /* Réduit de 5px à 3px */
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;  /* Réduit de 10px à 8px */
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    height: 50px;
    font-size: 20px;
}

.conv-item:hover {
    background: rgba(184, 212, 240, 0.25);
    border-color: rgba(184, 212, 240, 0.4);
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(184, 212, 240, 0.3);
}

.conv-item.active {
    background: linear-gradient(135deg, rgba(184, 212, 240, 0.35) 0%, rgba(212, 184, 212, 0.35) 100%);
    border-left: 4px solid #b8d4f0;
    border-color: rgba(184, 212, 240, 0.5);
}

.conv-info {
    flex: 1;
}

.conv-title {
    font-weight: bold;
    color: #ffffff;
    font-size: 14px;  /* Réduit de 15px à 14px */
    margin-bottom: 3px;  /* Réduit de 5px à 3px */
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.conv-date {
    font-size: 11px;  /* Réduit de 12px à 11px */
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.conv-delete {
    background: rgba(255, 100, 100, 0.15);
    border: 1px solid rgba(255, 100, 100, 0.3);
    border-radius: 50%;
    width: 24px;  /* Plus petit : 24px au lieu de 32px */
    height: 24px;
    font-size: 18px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: all 0.2s;
    line-height: 1;
}

.conv-delete:hover {
    opacity: 1;
    background: rgba(255, 100, 100, 0.4);
    border-color: rgba(255, 100, 100, 0.6);
    transform: scale(1.2) rotate(90deg);  /* Rotation au survol */
    box-shadow: 0 0 10px rgba(255, 100, 100, 0.4);
}

.no-convs {
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 15px;
    padding: 40px 20px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

#new-conv-btn {
    margin: 15px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(184, 212, 240, 0.3) 0%, rgba(212, 184, 212, 0.3) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #ffffff;
    border: 2px solid rgba(184, 212, 240, 0.4);
    border-radius: 10px;
    font-weight: bold;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

#new-conv-btn:hover {
    transform: scale(1.05);
    background: linear-gradient(135deg, rgba(184, 212, 240, 0.45) 0%, rgba(212, 184, 212, 0.45) 100%);
    border-color: rgba(184, 212, 240, 0.6);
    box-shadow: 0 4px 15px rgba(184, 212, 240, 0.4);
}

/* Scrollbar pour la liste conversations */
.conv-list-content::-webkit-scrollbar {
    width: 8px;
}

.conv-list-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;  /* Réduit de 10px à 8px */
}

.conv-list-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, rgba(184, 212, 240, 0.5) 0%, rgba(212, 184, 212, 0.5) 100%);
    border-radius: 10px;
}

.conv-list-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, rgba(184, 212, 240, 0.7) 0%, rgba(212, 184, 212, 0.7) 100%);
}

/* Message de bienvenue */
.welcome-msg {
    animation: fadeInSlide 0.6s ease;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes messageSlide {
    from {
        transform: translateY(10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    #ricky-chat-modal {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    
    /* Header rétréci sur mobile */
    #ricky-modal-header {
        padding: 12px 15px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    }
    
    #ricky-modal-title::before {
        width: 30px;
        height: 30px;
    }
    
    #ricky-modal-title::after {
        font-size: 18px;
    }
    
    #ricky-modal-title {
        gap: 8px;
    }
    
    .header-buttons {
        gap: 6px;
    }
    
    #ricky-convs-btn,
    #ricky-new-chat-btn,
    #ricky-close-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    #ricky-convs-btn {
        font-size: 18px;
    }
    
    #ricky-open-btn {
        width: 55px;
        height: 55px;
        bottom: 20px;
        right: 20px;
    }
    
    /* Fix bouton Envoyer mobile */
    #ricky-send-btn {
        padding: 12px 16px;
        font-size: 14px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    #ricky-user-input {
        font-size: 14px;
        padding: 12px 16px;
    }
    
    #ricky-input-bar {
        padding: 12px;
        gap: 8px;
    }
    
    #ricky-messages {
        padding: 15px;
        margin: 8px;
    }
}

@media (max-width: 480px) {
    #ricky-chat-modal {
        width: 100% !important;
        height: 100vh !important;
        max-width: 100% !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    #ricky-modal-header {
        padding: 6px 8px !important;
        flex-shrink: 0 !important;
    }
    
    #ricky-modal-title::before {
        width: 50px !important;
        height: 50px !important;
    }
    
    #ricky-modal-title::after {
        font-size: 24px !important;
    }
    
    #ricky-convs-btn,
    #ricky-new-chat-btn,
    #ricky-close-btn {
        width: 44px !important;
        height: 44px !important;
        font-size: 26px !important;
    }
    
    #ricky-convs-btn {
        font-size: 26px !important;
    }
    
    /* Messages : prend tout l'espace sauf l'input */
    #ricky-messages {
        padding: 10px !important;
        padding-bottom: 5px !important;
        margin: 5px !important;
        margin-bottom: 0 !important;
        flex: 1 !important;
        overflow-y: auto !important;
        min-height: 0 !important;
    }
    
    /* Input bar : REMONTÉE au-dessus de la barre Android */
    #ricky-input-bar {
        padding: 8px !important;
        padding-bottom: 60px !important;  /* ← IMPORTANT : Espace pour la barre Android */
        gap: 8px !important;
        flex-shrink: 0 !important;
        background: transparent !important;
        border-top: 2px solid rgba(255, 255, 255, 0.3) !important;
        position: relative !important;
        bottom: 0 !important;
    }
    
    #ricky-user-input {
        font-size: 15px !important;
        padding: 12px 14px !important;
        flex: 1 !important;
    }
    
    #ricky-send-btn {
        padding: 12px 16px !important;
        font-size: 15px !important;
        flex-shrink: 0 !important;
    }
}