/* ==================== CHAT WIDGET ==================== */

.chat-widget {
    --chat-width: 320px;
    --chat-bottom-height: 350px;
    --chat-float-w: 380px;
    --chat-float-h: 500px;
    visibility: hidden;
}

.chat-widget.chat-ready {
    visibility: visible;
}

/* --- Icône minimisée --- */
.chat-minimized-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--border-color-1), #3a7bd5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 900;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-size: 20px;
    color: white;
}

.chat-minimized-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

/* --- Badge notifications --- */
.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--red-color, var(--red-color));
    color: white;
    font-size: 10px;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}


/* --- Panneau du chat (commun) --- */
.chat-panel {
    position: fixed;
    z-index: 900;
    background: var(--main-bg-color-full, #0d1117);
    border: 1px solid var(--border-color-3, #30363d);
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

/* ==================== MODES DE POSITION ==================== */

/* --- DROITE --- */
.chat-position-right .chat-panel {
    right: 0;
    top: 0;
    bottom: 0;
    width: var(--chat-width);
    border-radius: 0;
    border-right: none;
}

/* --- GAUCHE --- */
.chat-position-left .chat-panel {
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--chat-width);
    border-radius: 0;
    border-left: none;
}

/* --- BAS --- */
.chat-position-bottom .chat-panel {
    left: 200px;
    right: 200px;
    bottom: 0;
    height: var(--chat-bottom-height);
    border-radius: 8px 8px 0 0;
}

/* --- FLOTTANT --- */
.chat-position-floating .chat-panel {
    right: 20px;
    bottom: 70px;
    width: var(--chat-float-w);
    height: var(--chat-float-h);
    border-radius: 8px;
}

/* --- Drag flottant --- */
.chat-position-floating .chat-header {
    cursor: grab;
}

.chat-position-floating .chat-panel.chat-dragging {
    transition: none;
    user-select: none;
}

.chat-position-floating .chat-panel.chat-dragging .chat-header {
    cursor: grabbing;
}

.chat-position-floating .chat-panel.chat-fullscreen {
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    height: auto;
    border-radius: 8px;
}

/* ==================== EN-TÊTE ==================== */

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, var(--second-bg-color, #161b22), var(--main-bg-color, #0d1117));
    border-bottom: 1px solid var(--border-color-3, #30363d);
    flex-shrink: 0;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    font-size: 12px;
    color: var(--font-color, #c9d1d9);
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-header-title {
    color: var(--panel-header-color, #58a6ff);
}

.chat-online-dot {
    color: var(--green-color, #3fb950);
    font-size: 8px;
}

/* --- Boutons d'en-tête --- */
.chat-btn-icon {
    background: none;
    border: none;
    color: var(--font-color-2, #8b949e);
    font-size: 14px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.chat-btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--font-color, #c9d1d9);
}

/* --- Dropdown position --- */
.chat-position-selector {
    position: relative;
}

.chat-position-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--main-bg-color-full, #0d1117);
    border: 1px solid var(--border-color-3, #30363d);
    border-radius: 6px;
    padding: 4px;
    display: flex;
    gap: 2px;
    z-index: 901;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.chat-position-dropdown button {
    background: none;
    border: none;
    color: var(--font-color-2, #8b949e);
    font-size: 14px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.chat-position-dropdown button:hover,
.chat-position-dropdown button.active {
    background: var(--border-color-1, #1f6feb);
    color: white;
}

/* ==================== ONGLETS CANAUX ==================== */

.chat-channels {
    display: flex;
    padding: 0;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-color-3, #30363d);
    flex-shrink: 0;
    overflow-x: auto;
}

.chat-channel-tab {
    flex: 1;
    padding: 6px 8px;
    text-align: center;
    font-size: 10px;
    color: var(--font-color-2, #8b949e);
    cursor: pointer;
    border: none;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
    background: none;
}

.chat-channel-tab:hover {
    color: var(--font-color, #c9d1d9);
    background: rgba(255, 255, 255, 0.03);
}

.chat-channel-tab.active {
    color: var(--border-color-1, #1f6feb);
    border-bottom-color: var(--border-color-1, #1f6feb);
}

.chat-channel-badge {
    position: absolute;
    top: 2px;
    right: 4px;
    background: var(--badge-alert-bg);
    color: white;
    font-size: 8px;
    min-width: 14px;
    height: 14px;
    border-radius: 7px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

/* ==================== PANEL JOUEURS EN LIGNE ==================== */

.chat-online-panel {
    border-bottom: 1px solid var(--border-color-3, #30363d);
    max-height: 150px;
    overflow-y: auto;
    flex-shrink: 0;
}

.chat-online-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: bold;
    color: var(--font-color-1, #c9d1d9);
    background: rgba(0, 0, 0, 0.15);
}

.chat-online-list {
    padding: 4px 10px;
    font-size: 11px;
}

.chat-online-user {
    padding: 2px 0;
    color: var(--font-color-2, #8b949e);
    cursor: pointer;
}

.chat-online-user:hover {
    color: var(--font-color, #c9d1d9);
}

.chat-online-user::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--green-color, #3fb950);
    border-radius: 50%;
    margin-right: 6px;
}

/* --- Compteur en ligne (cliquable) --- */
.chat-online-count {
    cursor: pointer;
    font-size: 10px;
    color: var(--font-color-2, #8b949e);
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-online-count:hover {
    color: var(--font-color, #c9d1d9);
}

/* ==================== ZONE DE MESSAGES ==================== */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
}

.chat-messages-loading {
    text-align: center;
    color: var(--font-color-2, #8b949e);
    padding: 20px;
    font-size: 11px;
}

/* --- Séparateur de jour --- */
.chat-date-separator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0 2px;
    font-size: 9px;
    color: var(--font-color-2, #8b949e);
}

.chat-date-separator::before,
.chat-date-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color-3, #30363d);
}

.chat-date-separator span {
    white-space: nowrap;
}

/* --- Message individuel --- */
.chat-msg {
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1.4;
    animation: chat-fadein 0.3s ease;
}

@keyframes chat-fadein {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg:hover {
    background: rgba(255, 255, 255, 0.03);
}

.chat-msg-pseudo {
    font-weight: bold;
    color: var(--font-color-1, #c9d1d9);
    cursor: pointer;
    margin-right: 4px;
}

.chat-msg-pseudo:hover {
    color: var(--font-color, #fff);
    text-decoration: underline;
}

.chat-msg-time {
    font-size: 9px;
    color: var(--font-color-2, #8b949e);
    margin-right: 4px;
}

.chat-msg-content {
    color: var(--font-color, #c9d1d9);
    word-break: break-word;
}

.chat-msg-system {
    color: var(--yellow-color, #d29922);
    font-style: italic;
    font-size: 10px;
}

.chat-msg-system .chat-msg-pseudo {
    color: var(--yellow-color, #d29922);
}

/* --- Mentions --- */
.chat-mention {
    color: var(--border-color-1, #1f6feb);
    font-weight: bold;
    background: rgba(31, 111, 235, 0.1);
    padding: 0 2px;
    border-radius: 2px;
}

.chat-mention-self {
    background: rgba(31, 111, 235, 0.25);
    color: var(--yellow-color, #d29922);
}

/* ==================== ZONE DE SAISIE ==================== */

.chat-input-area {
    display: flex;
    padding: 8px;
    border-top: 1px solid var(--border-color-3, #30363d);
    gap: 6px;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.1);
}

.chat-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border-color-3, #30363d);
    background: var(--second-bg-color, #161b22);
    color: var(--font-color, #c9d1d9);
    border-radius: 16px;
    font-size: 11px;
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-input:focus {
    border-color: var(--border-color-1, #1f6feb);
}

.chat-input::placeholder {
    color: var(--font-color-2, #8b949e);
    font-size: 10px;
}

/* --- Bouton & panneau emoji --- */
.chat-emoji-wrapper {
    position: relative;
    flex-shrink: 0;
}

.chat-emoji-btn {
    background: none;
    border: none;
    color: var(--font-color-2, #8b949e);
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-emoji-btn:hover,
.chat-emoji-btn.active {
    color: var(--font-color, #c9d1d9);
    background: rgba(255, 255, 255, 0.1);
}

.chat-emoji-panel {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 6px;
    max-height: 200px;
    overflow-y: auto;
    background: var(--main-bg-color-full, #0d1117);
    border: 1px solid var(--border-color-3, #30363d);
    border-radius: 8px;
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    z-index: 910;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.chat-emoji-panel span {
    font-size: 18px;
    cursor: pointer;
    text-align: center;
    padding: 3px;
    border-radius: 4px;
    transition: background 0.15s ease;
    line-height: 1.2;
}

.chat-emoji-panel span:hover {
    background: rgba(255, 255, 255, 0.12);
}

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

.chat-emoji-panel::-webkit-scrollbar-thumb {
    background: var(--border-color-3, #30363d);
    border-radius: 2px;
}

.chat-send-btn {
    background: linear-gradient(135deg, var(--border-color-1, #1f6feb), #3a7bd5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.1);
}

/* ==================== SCROLLBAR ==================== */

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color-3, #30363d);
    border-radius: 2px;
}

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

.chat-online-panel::-webkit-scrollbar-thumb {
    background: var(--border-color-3, #30363d);
    border-radius: 2px;
}

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

@media screen and (max-width: 800px) {
    .chat-widget .chat-panel {
        right: 0 !important;
        left: 0 !important;
        top: auto !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 60vh !important;
        border-radius: 12px 12px 0 0 !important;
    }

    .chat-widget .chat-panel.chat-fullscreen {
        height: 100vh !important;
        top: 0 !important;
        border-radius: 0 !important;
    }

    .chat-minimized-icon {
        bottom: 15px;
        right: 15px;
        width: 44px;
        height: 44px;
    }

    .chat-position-selector {
        display: none;
    }

    .chat-fullscreen-btn {
        display: flex !important;
    }

    .chat-position-bottom .chat-panel {
        left: 0 !important;
        right: 0 !important;
    }
}