/**
 * chat-styles.css - v1 CORRIGÉE
 * Styles pour le système de chat VStream 2
 * Utilise les variables CSS du DesignManager
 */

/* ========================================
   CONTAINER PRINCIPAL
   ======================================== */

.chat-section {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    height: 450px;
    overflow: hidden;
}

.chat-section-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* ========================================
   HEADER
   ======================================== */

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--color-primary, #7C3AED), var(--color-secondary, #EC4899));
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.chat-header-left {
    flex: 1;
}

.chat-header-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header-count {
    font-size: 14px;
    font-weight: 400;
    opacity: 0.9;
}

.chat-header-right {
    display: flex;
    gap: 8px;
}

.chat-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.2s;
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-header-btn:active {
    background: rgba(255, 255, 255, 0.4);
}

/* ========================================
   MESSAGES CONTAINER
   ======================================== */

.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f9fafb;
}

.chat-messages-list {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Scrollbar custom */
.chat-messages-list::-webkit-scrollbar {
    width: 8px;
}

.chat-messages-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages-list::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.chat-messages-list::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* ========================================
   MESSAGES - ÉTATS
   ======================================== */

.chat-messages-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #718096;
}

.chat-messages-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--color-primary, #7C3AED);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.chat-messages-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #718096;
    text-align: center;
}

.chat-messages-empty p:first-child {
    font-size: 24px;
    margin: 0 0 8px 0;
}

.chat-messages-empty p:last-child {
    font-size: 14px;
    margin: 0;
    color: #a0aec0;
}

.chat-messages-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--color-danger, #EF4444);
    text-align: center;
}

.chat-messages-error button {
    margin-top: 16px;
    padding: 8px 16px;
    background: var(--color-primary, #7C3AED);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.chat-messages-loading-more {
    text-align: center;
    padding: 12px;
    color: #718096;
    font-size: 14px;
}

/* ========================================
   MESSAGE INDIVIDUEL
   ======================================== */

.chat-message {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s;
}

.chat-message:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Message de l'utilisateur actuel */
.chat-message-own {
    background: linear-gradient(135deg, var(--color-primary-light, #7C3AED20), var(--color-secondary-light, #EC489920));
    border-left: 3px solid var(--color-primary, #7C3AED);
}

/* Message admin */
.chat-message-admin {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-left: 3px solid #f59e0b;
}

/* ========================================
   MESSAGE HEADER
   ======================================== */

.chat-message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.chat-message-author {
    font-weight: 600;
    font-size: 14px;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-admin-badge {
    background: #f59e0b;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-message-time {
    font-size: 12px;
    color: #a0aec0;
}

/* ========================================
   MESSAGE CONTENT
   ======================================== */

.chat-message-content {
    color: #4a5568;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-message-edited {
    font-size: 12px;
    color: #a0aec0;
    font-style: italic;
    margin-top: 4px;
}

/* ========================================
   INPUT CONTAINER
   ======================================== */

.chat-input-container {
    border-top: 1px solid #e2e8f0;
    background: white;
    padding: 16px 20px;
    flex-shrink: 0;
}

.chat-input-error {
    background: var(--color-danger-light, #EF444415);
    color: var(--color-danger, #EF4444);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    border-left: 3px solid var(--color-danger, #EF4444);
}

.chat-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-input-textarea {
    width: 100%;
    min-height: 60px;
    max-height: 120px;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
}

.chat-input-textarea:focus {
    outline: none;
    border-color: var(--color-primary, #7C3AED);
}

.chat-input-textarea:disabled {
    background: #f7fafc;
    color: #a0aec0;
    cursor: not-allowed;
}

/* ========================================
   INPUT FOOTER
   ======================================== */

.chat-input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chat-input-info {
    flex: 1;
    display: flex;
    gap: 16px;
}

.chat-input-char-count {
    font-size: 12px;
    color: #718096;
}

.chat-input-char-count.over-limit {
    color: var(--color-danger, #EF4444);
    font-weight: 600;
}

.chat-input-send-btn {
    padding: 10px 24px;
    background: var(--color-primary, #7C3AED);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 100px;
}

.chat-input-send-btn:hover:not(:disabled) {
    background: var(--color-secondary, #EC4899);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.chat-input-send-btn:active:not(:disabled) {
    transform: translateY(0);
}

.chat-input-send-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .chat-section {
        height: 400px;
        max-height: 400px;
    }

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

    .chat-header-title {
        font-size: 16px;
    }

    .chat-messages-list {
        padding: 16px;
        gap: 12px;
    }

    .chat-message {
        padding: 10px 12px;
    }

    .chat-input-container {
        padding: 12px 16px;
    }

    .chat-input-textarea {
        min-height: 50px;
        max-height: 100px;
    }
}

/* ========================================
   LOADING STATE
   ======================================== */

.chat-section.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.chat-section.error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: var(--color-danger, #EF4444);
}

.chat-section.error .error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}