/* Reset et styles de base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: #f5f5f7;
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* Container principal */
.chat-container {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
    width: 100vw;
    background: #ffffff;
    position: relative;
    overflow: hidden;
    border: 1px solid #e5e5e7;
}

/* En-tête */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #ffffff;
    color: #1d1d1f;
    min-height: 60px;
    border-bottom: 1px solid #e5e5e7;
    position: relative;
    z-index: 100;
}

.status-indicator {
    width: 8px;
    height: 8px;
    background: #30d158;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.chat-header h1 {
    font-size: 17px;
    font-weight: 600;
    flex: 1;
    text-align: center;
    margin: 0 16px;
    color: #1d1d1f;
}

.close-btn {
    background: #f2f2f7;
    border: none;
    color: #1d1d1f;
    width: 32px;
    height: 32px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #e5e5ea;
}

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

/* Zone des messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #c7c7cc;
    border-radius: 2px;
}

/* Messages */
.message {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

.message.user {
    align-items: flex-end;
}

.message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 16px;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* Messages du bot */
.message:not(.user) .message-content {
    background: #f2f2f7;
    color: #1d1d1f;
    border-bottom-left-radius: 4px;
}

/* Messages de l'utilisateur */
.message.user .message-content {
    background: #007aff;
    color: white;
    border-bottom-right-radius: 4px;
}

/* Zone de saisie */
.chat-input-area {
    bottom: env(safe-area-inset-bottom, 0);
    flex: 0 0 auto;
    padding: 16px 20px 20px;
    background: #ffffff;
    border-top: 1px solid #e5e5e7;
}

/* Boutons de réponse rapide */
.quick-responses {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 60px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.quick-responses.slide-up {
    opacity: 1;
    transform: translateY(0);
}

.response-btn {
    background: #f2f2f7;
    border: 1px solid #e5e5e7;
    color: #1d1d1f;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.response-btn:hover {
    background: #e5e5ea;
    border-color: #d1d1d6;
}

.response-btn:active {
    transform: scale(0.98);
    background: #d1d1d6;
}

/* Zone de saisie de texte */
.text-input {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f2f2f7;
    border-radius: 24px;
    margin-top: -20px;
    margin-bottom: 20px;
    padding: 4px;
    transform: translateY(20px);
    transition: all 0.3s ease;
    border: 1px solid #e5e5e7;
    min-height: 52px;
}

.text-input.slide-up {
    opacity: 1;
    transform: translateY(0);
}

.text-input textarea {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 16px;
    font-size: 16px;
    line-height: 1.4;
    resize: none;
    outline: none;
    min-height: 44px;
    max-height: 120px;
    font-family: inherit;
    color: #1d1d1f;
    width: 100%;
}

.text-input textarea::placeholder {
    color: #8e8e93;
}

.send-btn {
    background: #007aff;
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
    flex-shrink: 0;
}

.send-btn:disabled {
    background: #c7c7cc;
    cursor: not-allowed;
}

.send-btn:not(:disabled):hover {
    background: #0056b3;
    transform: scale(1.05);
}

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

/* Indicateur de frappe */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #ffffff;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.typing-indicator:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #c7c7cc;
    border-radius: 50%;
    animation: typing 1.5s infinite;
}

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

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

/* États cachés */
.hidden {
    display: none !important;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

/* Responsive mobile */
@media (max-width: 768px) {
    .chat-messages {
        padding: 16px;
    }
    
    .chat-input-area {
        padding: 12px 16px 16px;
    }
    
    .message-content {
        max-width: 90%;
        font-size: 16px;
    }
    
    .response-btn {
        padding: 12px 14px;
        font-size: 16px;
    }
}

/* Accessibilité */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mode sombre potentiel */
@media (prefers-color-scheme: dark) {
    body {
        background: #000000;
    }
    
    .chat-container {
        background: #1c1c1e;
        border-color: #38383a;
    }
    
    .chat-header {
        background: #1c1c1e;
        border-color: #38383a;
        color: #ffffff;
    }
    
    .chat-header h1 {
        color: #ffffff;
    }
    
    .close-btn {
        background: #2c2c2e;
        color: #ffffff;
    }
    
    .close-btn:hover {
        background: #48484a;
    }
    
    .chat-messages {
        background: #1c1c1e;
    }
    
    .message:not(.user) .message-content {
        background: #2c2c2e;
        color: #ffffff;
    }
    
    .chat-input-area {
        background: #1c1c1e;
        border-color: #38383a;
    }
    
    .response-btn {
        background: #2c2c2e;
        border-color: #38383a;
        color: #ffffff;
    }
    
    .response-btn:hover {
        background: #48484a;
        border-color: #48484a;
    }
    
    .text-input {
        background: #f2f2f2;
        border-color: #38383a;
    }
    
    .text-input textarea {
        color: #2c2c2c;
    }
    
    .text-input textarea::placeholder {
        color: #8e8e93;
    }
    
    .typing-indicator {
        background: #1c1c1e;
    }
}
