/* Botón flotante del chat (izquierda) */
.chat-toggle-btn {
    position: fixed;
    bottom: 25px;
    right: 25px;
    background: #1a120b;
    border: 2px solid #489748;
    padding: 6px;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    color: #ccaa4b;
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    border-color: #4bcc4f;
    box-shadow: 0 0 15px rgba(75, 204, 75, 0.4);
}

/* Panel del Chat */
.global-chat-panel {
    position: fixed;
    bottom: 20px;
    /* Encima del botón */
    left: 25px;
    width: 550px;
    height: 450px;
    background: rgba(13, 10, 8, 0.85);
    /* Fondo oscuro semitransparente */
    border: 2px solid #715539;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    opacity: 0.5;
    filter: blur(1px) brightness(0.5);
    /* Opacidad reducida por defecto */
    transition: opacity 0.3s ease, border-color 0.3s ease, filter 0.6s ease;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    font-family: 'Courier New', Courier, monospace;
}

/* Al hacer hover, se vuelve totalmente visible */
.global-chat-panel:hover,
.global-chat-panel:focus-within {
    opacity: 1;
    filter: blur(0px) brightness(1);
    border-color: #ccaa4b;
    transition: opacity 0.3s ease, border-color 0.3s ease, filter 0.2s ease;
}

.chat-header {
    background: rgba(26, 18, 11, 0.9);
    padding: 10px;
    border-bottom: 1px solid #4b3621;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    color: #ccaa4b;
    font-size: 0.9rem;
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-minimize-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

.chat-minimize-btn:hover {
    color: #fff;
}

@keyframes chatMsgPop {
    0% { opacity: 0; transform: translateY(15px) scale(0.9); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes chatPanelPulse {
    0% { opacity: 0; filter: blur(4px) brightness(2); transform: scale(0.95); }
    25% { opacity: 0.9; filter: blur(0px) brightness(1.2); transform: scale(1.02); box-shadow: 0 0 20px rgba(255, 215, 0, 0.5); }
    50% { opacity: 0.3; filter: blur(0px) brightness(2); transform: scale(1.02); }
    75% { opacity: 0.9; filter: blur(0px) brightness(1.2); transform: scale(1.02); box-shadow: 0 0 20px rgba(255, 215, 0, 0.5); }
    50% { opacity: 0.2; filter: blur(0px) brightness(2); transform: scale(1.02); }
}

.global-chat-panel.pulse-open {
    animation: chatPanelPulse 1.1s ease-out;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Scrollbar personalizado delgado */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

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

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.4;
    animation: chatMsgPop 0.3s ease-out forwards;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

.chat-msg .sender {
    font-size: 0.75rem;
    margin-bottom: 3px;
    font-weight: bold;
    border-bottom: 1px solid #4b3621;
}

.chat-msg .content {
    color: #e0e6ed;
}

/* Others' messages (Left side) */
.chat-msg:not(.self):not(.system) {
    align-self: flex-start;
    background: rgba(30, 40, 50, 0.85);
    border: 1px solid #2e4453;
    border-bottom-left-radius: 2px;
}

.chat-msg:not(.self):not(.system) .sender {
    color: #8fa1b3;
}

/* Own messages (Right side) */
.chat-msg.self {
    align-self: flex-end;
    background: rgba(60, 45, 20, 0.85);
    border: 1px solid #715539;
    border-bottom-right-radius: 2px;
    align-items: flex-end;
}

.chat-msg.self .sender {
    color: #ccaa4b;
}

.chat-msg.self .content {
    color: #f5deb3;
    text-align: right;
}

.chat-msg.system {
    align-self: center;
    background: transparent;
    box-shadow: none;
    color: #ffd700;
    font-style: italic;
    text-align: center;
    font-size: 0.8rem;
    margin: 5px 0;
    opacity: 0.8;
}

.chat-msg.dev .sender {
    color: #ff6b6b;
    text-shadow: 0 0 5px red;
}

/* Indicador de notificación para mensajes no leídos */
.chat-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: chatBadgePulse 2s infinite;
    padding: 0 4px;
    box-sizing: border-box;
    transition: opacity 0.2s;
}

.chat-notification-badge.hidden {
    display: none;
    opacity: 0;
}

.chat-toggle-btn.has-unread {
    animation: chatBadgePulse 2s infinite;
    border-color: #ff6b6b;
    box-shadow: 0 0 15px rgba(255, 107, 107, 0.6);
}

@keyframes chatBadgePulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(255, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 68, 68, 0); }
}

.chat-input-area {
    padding: 10px;
    background: rgba(0, 0, 0, 0.6);
    border-top: 1px solid #333;
    display: flex;
    gap: 5px;
}

.chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #444;
    color: #ddd;
    padding: 8px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
}

.chat-input:focus {
    border-color: #704214;
    background: rgba(255, 255, 255, 0.1);
}

.chat-send-btn {
    background: #4b3621;
    color: #ccaa4b;
    border: 1px solid #664a2d;
    border-radius: 4px;
    padding: 0 12px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.chat-send-btn:hover {
    background: #5e4328;
}

/* Estado oculto (minimizado) */
.global-chat-panel.hidden {
    display: none;
}