/* Smart Chatbot - Frontend Styles */

:root {
    --sc-primary-color: #0066cc;
    --sc-bg-color: #ffffff;
    --sc-text-color: #333333;
    --sc-border-radius: 12px;
    --sc-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Widget Container */
.sc-widget {
    position: fixed;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.sc-widget.sc-bottom-left {
    bottom: 20px;
    left: 20px;
}

.sc-widget.sc-bottom-right {
    bottom: 20px;
    right: 20px;
}

.sc-widget.sc-center-left {
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
}

.sc-widget.sc-center-right {
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
}

/* Toggle Button */
.sc-toggle-button {
    width: 60px;
    height: 60px;
    background: var(--sc-primary-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--sc-shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    /* overflow: hidden retiré pour permettre au badge de dépasser */
}

.sc-toggle-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

.sc-toggle-button img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.sc-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: pulse 2s infinite;
    box-shadow: 0 2px 8px rgba(255, 68, 68, 0.4);
}

/* Bulle d'accueil */
.sc-welcome-bubble {
    position: absolute;
    bottom: 70px;
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    font-size: 14px;
    color: #333;
    animation: slideInBounce 0.6s ease-out;
    max-width: 200px;
    line-height: 1.4;
}

.sc-widget.sc-bottom-left .sc-welcome-bubble,
.sc-widget.sc-center-left .sc-welcome-bubble {
    left: 0;
}

.sc-widget.sc-bottom-right .sc-welcome-bubble,
.sc-widget.sc-center-right .sc-welcome-bubble {
    right: 0;
}

.sc-welcome-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    width: 12px;
    height: 12px;
    background: white;
    transform: rotate(45deg);
}

.sc-widget.sc-bottom-left .sc-welcome-bubble::after,
.sc-widget.sc-center-left .sc-welcome-bubble::after {
    left: 20px;
}

.sc-widget.sc-bottom-right .sc-welcome-bubble::after,
.sc-widget.sc-center-right .sc-welcome-bubble::after {
    right: 20px;
}

.sc-welcome-bubble.fade-out {
    animation: fadeOut 0.4s ease-out forwards;
}

@keyframes slideInBounce {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
    }
    60% {
        opacity: 1;
        transform: translateY(-5px) scale(1.05);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(10px);
    }
}

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

/* Chat Window */
.sc-chat-window {
    position: absolute;
    width: 380px;
    height: 550px;
    background: var(--sc-bg-color);
    border-radius: var(--sc-border-radius);
    box-shadow: var(--sc-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

.sc-widget.sc-bottom-right .sc-chat-window,
.sc-widget.sc-center-right .sc-chat-window {
    right: 0;
    bottom: 80px;
}

.sc-widget.sc-bottom-left .sc-chat-window,
.sc-widget.sc-center-left .sc-chat-window {
    left: 0;
    bottom: 80px;
}

.sc-widget.sc-center-left .sc-chat-window,
.sc-widget.sc-center-right .sc-chat-window {
    bottom: auto;
    top: -280px; /* Centré par rapport au bouton */
}

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

/* Header */
.sc-chat-header {
    background: var(--sc-primary-color);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sc-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sc-header-icon {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.sc-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.sc-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
}

.sc-status:before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4caf50;
    border-radius: 50%;
    margin-right: 6px;
    animation: blink 2s infinite;
}

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

.sc-close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.sc-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages */
.sc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

.sc-messages::-webkit-scrollbar {
    width: 6px;
}

.sc-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.sc-message {
    display: flex;
    margin-bottom: 20px;
    animation: fadeIn 0.3s;
}

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

.sc-message-avatar {
    width: 35px;
    height: 35px;
    margin-right: 10px;
    flex-shrink: 0;
}

.sc-message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid #e0e0e0;
}

.sc-message-content {
    max-width: 75%;
}

.sc-message-content p {
    margin: 0;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 14px;
}

.sc-bot-message .sc-message-content p {
    background: white;
    color: var(--sc-text-color);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

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

.sc-user-message .sc-message-avatar {
    margin-left: 10px;
    margin-right: 0;
}

.sc-user-message .sc-message-content {
    text-align: right;
}

.sc-user-message .sc-message-content p {
    background: var(--sc-primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Typing Indicator */
.sc-typing-indicator {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.sc-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    margin: 0 3px;
    animation: typing 1.4s infinite;
}

.sc-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.sc-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

/* Input Area */
.sc-input-area {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

#sc-chat-form {
    display: flex;
    gap: 10px;
}

#sc-user-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#sc-user-input:focus {
    border-color: var(--sc-primary-color);
}

.sc-send-btn {
    width: 45px;
    height: 45px;
    background: var(--sc-primary-color);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
    flex-shrink: 0;
}

.sc-send-btn:hover {
    transform: scale(1.05);
    background: #0052a3;
}

.sc-send-btn:active {
    transform: scale(0.95);
}

.sc-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 768px) {
    /* Bouton plus gros sur mobile */
    .sc-toggle-button {
        width: 70px;
        height: 70px;
    }
    
    /* Fenêtre plein écran sur mobile */
    .sc-chat-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        animation: slideUpMobile 0.3s ease-out;
    }
    
    @keyframes slideUpMobile {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
    
    /* Widget positionné correctement sur mobile */
    .sc-widget.sc-bottom-left,
    .sc-widget.sc-bottom-right,
    .sc-widget.sc-center-left,
    .sc-widget.sc-center-right {
        bottom: 20px !important;
        right: 20px !important;
        left: auto !important;
        top: auto !important;
        transform: none !important;
    }
    
    /* En-tête plus grand sur mobile */
    .sc-chat-header {
        padding: 20px;
        min-height: 70px;
    }
    
    .sc-header-icon {
        width: 50px !important;
        height: 50px !important;
    }
    
    .sc-header-info h3 {
        font-size: 18px;
    }
    
    .sc-close-btn {
        width: 40px;
        height: 40px;
        font-size: 32px;
    }
    
    /* Messages plus lisibles */
    .sc-messages {
        padding: 15px;
        font-size: 15px;
    }
    
    .sc-message-content p {
        font-size: 15px;
        padding: 14px 18px;
    }
    
    /* Zone de saisie adaptée au mobile */
    .sc-input-area {
        padding: 15px;
        padding-bottom: max(15px, env(safe-area-inset-bottom));
    }
    
    #sc-user-input {
        font-size: 16px; /* Évite le zoom automatique sur iOS */
        padding: 14px 18px;
    }
    
    .sc-send-btn {
        width: 50px;
        height: 50px;
    }
    
    /* Bulle d'accueil mobile */
    .sc-welcome-bubble {
        bottom: 85px;
        right: 0;
        left: auto;
        max-width: 160px;
        font-size: 13px;
        padding: 10px 14px;
    }
    
    .sc-widget.sc-bottom-left .sc-welcome-bubble::after,
    .sc-widget.sc-center-left .sc-welcome-bubble::after,
    .sc-widget.sc-bottom-right .sc-welcome-bubble::after,
    .sc-widget.sc-center-right .sc-welcome-bubble::after {
        right: 25px;
        left: auto;
    }
}

@media (max-width: 360px) {
    /* Très petits écrans */
    .sc-toggle-button {
        width: 60px;
        height: 60px;
    }
    
    .sc-welcome-bubble {
        max-width: 140px;
        font-size: 12px;
    }
}