/* Chat System Console */
#chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    height: 250px;
    background: rgba(15, 15, 15, 0.85);
    border: 2px solid #444;
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    z-index: 100;
    font-family: Arial, sans-serif;
}

#chat-history {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    font-size: 12px;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Chat Scrollbar Styling */
#chat-history::-webkit-scrollbar {
    width: 6px;
}

#chat-history::-webkit-scrollbar-track {
    background: transparent;
}

#chat-history::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

/* Input Area and Form Elements */
#chat-input-area {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px;
    background: #111;
    border-top: 1px solid #333;
    border-radius: 0 0 8px 8px;
}

#chat-input {
    border-radius: 0 4px 4px 0 !important;
    flex-grow: 1;
    background: #222;
    color: #fff;
    border: 1px solid #444;
    padding: 6px;
    outline: none;
}

#chat-send {
    background: #1565c0;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

/* Table reaction cluster — quick-react strip on its own row above the
   compose field (S4b). The chat console is always dark, so chrome is
   built from translucent overlays that adapt to any panel background;
   the palette is centralised in scoped custom properties (no scattered
   fixed hex) so it stays theme-safe and tunable. */
.table-reaction-bar {
    --pe-react-surface: rgba(255, 255, 255, 0.05);
    --pe-react-surface-hover: rgba(255, 255, 255, 0.14);
    --pe-react-border: rgba(255, 255, 255, 0.1);
    --pe-react-border-hover: rgba(255, 255, 255, 0.28);
    --pe-react-focus: rgba(120, 190, 255, 0.75);
    --pe-react-ink: #fff;

    order: -1;
    flex: 0 0 100%;
    display: flex;
    align-items: stretch;
    gap: 4px;
    margin: 0;
    padding: 3px;
    border-radius: 9px;
    background: var(--pe-react-surface);
    border: 1px solid var(--pe-react-border);
}

.table-reaction-bar[hidden] {
    display: none;
}

.table-reaction-btn {
    flex: 1 1 0;
    min-width: 0;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--pe-react-ink);
    cursor: pointer;
    font-size: 17px;
    line-height: 1;
    transition: transform 0.12s ease, background 0.15s ease,
        border-color 0.15s ease;
}

.table-reaction-btn:hover:not(:disabled),
.table-reaction-btn:focus-visible {
    background: var(--pe-react-surface-hover);
    border-color: var(--pe-react-border-hover);
}

.table-reaction-btn:focus-visible {
    outline: 2px solid var(--pe-react-focus);
    outline-offset: 1px;
}

.table-reaction-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

@media (prefers-reduced-motion: no-preference) {
    .table-reaction-btn:hover:not(:disabled) {
        transform: translateY(-1px);
    }

    .table-reaction-btn:active:not(:disabled) {
        transform: translateY(0) scale(0.92);
    }
}

/* Message Components */
.chat-timestamp {
    color: #777;
    font-size: 10px;
    font-family: monospace;
    margin-right: 5px;
}

#emoji-btn {
    background: #222;
    border: 1px solid #444;
    border-right: none;
    color: #fff;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 4px 0 0 4px;
    font-size: 14px;
    transition: background 0.2s;
}

#emoji-btn:hover {
    background: #333;
}

/* Premium Emoji Picker */
#emoji-picker {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 0;
    background: rgba(20, 20, 20, 0.85) !important;
    backdrop-filter: blur(15px) !important;
    -webkit-backdrop-filter: blur(15px) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 12px !important;
    padding: 15px !important;
    display: grid !important;
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 12px !important;
    width: max-content !important;
    z-index: 101;
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.8),
        inset 0 1px 1px rgba(255, 255, 255, 0.2) !important;
    transform-origin: bottom left;
}

#emoji-picker.hidden {
    display: none !important;
}

/* Picker Entrance Animation */
#emoji-picker:not(.hidden) {
    animation: popUpPicker 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popUpPicker {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(20px);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Emoji Individual Items */
.emoji-item {
    cursor: pointer;
    font-size: 26px;
    text-align: center;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    justify-content: center;
    align-items: center;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: transparent;
    filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.8));
}

.emoji-item:hover {
    transform: scale(1.4) translateY(-5px);
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.4);
    filter: drop-shadow(0 8px 15px rgba(0, 210, 255, 0.9));
    z-index: 2;
}

/* Message Type Styling */
.msg-chat {
    color: #fff;
}

.msg-chat .username {
    color: #64b5f6;
    font-weight: bold;
}

.msg-system {
    color: #888;
    font-style: italic;
}

.msg-action {
    color: #ffb300;
}

/* Winner and Showdown Visuals */
.msg-winner {
    color: #4ade80;
    font-weight: bold;
}

.chat-showdown {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
    padding: 5px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
}

.chat-card-group {
    display: flex;
    gap: 3px;
}

.chat-mini-card {
    width: 18px;
    height: 26px;
    background: #fff;
    border-radius: 3px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 11px;
    font-weight: bold;
    border: 1px solid #777;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    transition: all 0.2s;
}

.chat-divider {
    color: #888;
    font-size: 14px;
}

.chat-mini-card.winning-glow {
    box-shadow: 0 0 8px 2px #00d2ff !important;
    border: 1px solid #00d2ff !important;
    transform: scale(1.1);
    z-index: 2;
}
