/* ================================================
   SACHA CHATBOT - Frontend CSS
   ================================================ */

/* Variables */
:root {
    --sacha-primary: #3b82f6;
    --sacha-primary-dark: #1d4ed8;
    --sacha-bg: #f8fafc;
    --sacha-white: #ffffff;
    --sacha-text: #334155;
    --sacha-text-light: #64748b;
    --sacha-border: #e2e8f0;
    --sacha-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
}

/* Reset */
#sacha-bubble,
#sacha-widget,
#sacha-widget * {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* ================================================
   BULLE FLOTTANTE - Rectangulaire 10px radius
   ================================================ */
#sacha-bubble {
    position: fixed;
    bottom: 25px;
    right: 25px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px 12px 12px;
    background: linear-gradient(135deg, var(--sacha-primary) 0%, var(--sacha-primary-dark) 100%);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.35);
    cursor: pointer;
    z-index: 99998;
    transition: all 0.3s ease;
    border: none;
}

#sacha-bubble:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(59, 130, 246, 0.45);
}

#sacha-bubble img {
    width: 45px;
    height: 45px;
    border-radius: 8px;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.3);
}

.sacha-bubble-text {
    color: white;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.sacha-bubble-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: sacha-pulse 2s infinite;
}

@keyframes sacha-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

#sacha-bubble.active {
    display: none;
}

/* ================================================
   WIDGET CHAT
   ================================================ */
#sacha-widget {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 380px;
    max-height: 520px;
    background: var(--sacha-white);
    border-radius: 16px;
    box-shadow: var(--sacha-shadow);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: sacha-slideUp 0.3s ease;
}

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

/* ================================================
   HEADER
   ================================================ */
.sacha-header {
    background: linear-gradient(135deg, var(--sacha-primary) 0%, var(--sacha-primary-dark) 100%);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sacha-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sacha-header-avatar {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.3);
}

.sacha-header-text {
    display: flex;
    flex-direction: column;
}

.sacha-header-name {
    color: white;
    font-size: 16px;
    font-weight: 600;
}

.sacha-header-status {
    color: rgba(255,255,255,0.85);
    font-size: 12px;
}

.sacha-header-status::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    margin-right: 5px;
    animation: sacha-status-pulse 2s infinite;
}

@keyframes sacha-status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#sacha-close {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255,255,255,0.2);
    color: white;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#sacha-close:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

/* ================================================
   BODY - Messages
   ================================================ */
.sacha-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--sacha-bg);
    max-height: 340px;
}

#sacha-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sacha-message {
    display: flex;
    gap: 10px;
    animation: sacha-fadeIn 0.3s ease;
}

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

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

.sacha-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.sacha-message.user .sacha-msg-avatar {
    display: none;
}

.sacha-msg-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.sacha-message.bot .sacha-msg-content {
    background: var(--sacha-white);
    color: var(--sacha-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.sacha-message.user .sacha-msg-content {
    background: linear-gradient(135deg, var(--sacha-primary) 0%, var(--sacha-primary-dark) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
#sacha-typing {
    display: flex;
    gap: 10px;
    align-items: center;
    padding-top: 10px;
}

.sacha-typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--sacha-white);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.sacha-typing-dots span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: sacha-typing 1.4s infinite;
}

.sacha-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.sacha-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes sacha-typing {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(-4px); opacity: 1; }
}

/* ================================================
   FOOTER - Input
   ================================================ */
.sacha-footer {
    padding: 16px;
    background: var(--sacha-white);
    border-top: 1px solid var(--sacha-border);
    display: flex;
    gap: 10px;
}

#sacha-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--sacha-border);
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

#sacha-input:focus {
    border-color: var(--sacha-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#sacha-send {
    width: 48px;
    height: 48px;
    border: none;
    background: linear-gradient(135deg, var(--sacha-primary) 0%, var(--sacha-primary-dark) 100%);
    color: white;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

#sacha-send:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

#sacha-send:active {
    transform: scale(0.95);
}

/* ================================================
   SCROLLBAR
   ================================================ */
.sacha-body::-webkit-scrollbar {
    width: 6px;
}

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

.sacha-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.sacha-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ================================================
   RESPONSIVE
   ================================================ */
@media (max-width: 480px) {
    #sacha-bubble {
        bottom: 15px;
        right: 15px;
        padding: 8px 14px 8px 8px;
    }
    
    #sacha-bubble img {
        width: 40px;
        height: 40px;
    }
    
    .sacha-bubble-text {
        font-size: 13px;
    }
    
    #sacha-widget {
        width: calc(100% - 20px);
        right: 10px;
        left: 10px;
        bottom: 15px;
        max-height: 75vh;
    }
    
    .sacha-body {
        max-height: calc(75vh - 150px);
    }
    
    .sacha-msg-content {
        max-width: 85%;
    }
}
