/* ═══════════════════════════════════════════════════════════
   Dojo eSports — Game Room Chat Panel
   Right-side collapsible chat for PvP sessions
══════════════════════════════════════════════════════════════ */

/* ─── Chat Panel Container ───────────────────────────────── */
.game-chat-panel {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    height: 100%;
    background: var(--bg-panel, rgba(10, 7, 4, 0.98));
    border-left: 1px solid var(--border-subtle, rgba(255, 107, 0, 0.12));
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
    overflow: hidden;
    transition: width 0.32s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.32s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.28s ease;
}

/* Soft glow line on left border */
.game-chat-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: -1px;
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, var(--orange-primary, #ff6b00), transparent);
    opacity: 0.22;
    pointer-events: none;
}

/* ── Collapsed state ──────────────────────────────────────── */
.game-chat-panel.chat-collapsed {
    width: 0 !important;
    min-width: 0 !important;
    opacity: 0;
    pointer-events: none;
}

/* ── Chat Header ──────────────────────────────────────────── */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px 12px;
    border-bottom: 1px solid var(--border-subtle, rgba(255, 107, 0, 0.10));
    background: rgba(255, 107, 0, 0.04);
    flex-shrink: 0;
}

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

.chat-icon {
    font-size: 1.05rem;
    filter: drop-shadow(0 0 6px rgba(255, 107, 0, 0.35));
}

.chat-title {
    font-family: 'Outfit', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary, #f5f0eb);
    letter-spacing: 0.4px;
    white-space: nowrap;
}

/* Online indicator dot */
.chat-online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4caf6e;
    box-shadow: 0 0 6px rgba(76, 175, 110, 0.60);
    animation: pulse-online 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse-online {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px rgba(76, 175, 110, 0.60); }
    50%       { opacity: 0.65; box-shadow: 0 0 12px rgba(76, 175, 110, 0.40); }
}

/* Toggle (hide) button */
.chat-toggle-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 7px;
    color: var(--text-secondary, #9a8070);
    font-size: 0.72rem;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.22s ease;
    padding: 0;
    flex-shrink: 0;
    user-select: none;
    font-family: 'Outfit', sans-serif;
}

.chat-toggle-btn:hover {
    background: rgba(255, 107, 0, 0.12);
    border-color: rgba(255, 107, 0, 0.30);
    color: var(--orange-light, #ff9a3c);
    transform: scale(1.08);
}

.chat-toggle-btn:active {
    transform: scale(0.94);
}

/* ── Messages Area ────────────────────────────────────────── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 107, 0, 0.18);
    border-radius: 3px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 107, 0, 0.35);
}

/* ── System message ───────────────────────────────────────── */
.chat-system-msg {
    font-family: 'Outfit', sans-serif;
    font-size: 0.68rem;
    color: var(--text-muted, #5a4a3a);
    text-align: center;
    padding: 6px 10px;
    background: rgba(255, 107, 0, 0.05);
    border: 1px dashed rgba(255, 107, 0, 0.12);
    border-radius: 8px;
    letter-spacing: 0.3px;
    animation: fadeInUp 0.4s ease;
}

/* ── Chat message bubble ──────────────────────────────────── */
.chat-msg {
    display: flex;
    flex-direction: column;
    gap: 3px;
    animation: fadeInUp 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 100%;
}

.chat-msg-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 4px;
}

.chat-msg-author {
    font-family: 'Outfit', sans-serif;
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.chat-msg-author.is-self {
    color: var(--orange-light, #ff9a3c);
}

.chat-msg-author.is-other {
    color: #8ab4d8;
}

.chat-msg-time {
    font-family: 'Outfit', sans-serif;
    font-size: 0.58rem;
    color: var(--text-muted, #5a4a3a);
    margin-left: auto;
}

.chat-msg-bubble {
    font-family: 'Outfit', sans-serif;
    font-size: 0.78rem;
    line-height: 1.45;
    padding: 8px 11px;
    border-radius: 10px;
    word-break: break-word;
    color: var(--text-primary, #f5f0eb);
    max-width: 100%;
}

/* Self messages: right-aligned orange */
.chat-msg.is-self {
    align-items: flex-end;
}

.chat-msg.is-self .chat-msg-bubble {
    background: linear-gradient(135deg, rgba(255, 107, 0, 0.22), rgba(255, 154, 60, 0.12));
    border: 1px solid rgba(255, 107, 0, 0.25);
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(255, 107, 0, 0.12);
}

/* Other messages: left-aligned blue-tinted */
.chat-msg.is-other {
    align-items: flex-start;
}

.chat-msg.is-other .chat-msg-bubble {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 4px;
}

/* ── Input Area ───────────────────────────────────────────── */
.chat-input-area {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 10px 12px;
    border-top: 1px solid var(--border-subtle, rgba(255, 107, 0, 0.10));
    background: rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 8px 11px;
    color: var(--text-primary, #f5f0eb);
    font-family: 'Outfit', sans-serif;
    font-size: 0.78rem;
    outline: none;
    transition: border-color 0.22s ease, box-shadow 0.22s ease;
    caret-color: var(--orange-primary, #ff6b00);
    min-width: 0;
}

.chat-input::placeholder {
    color: var(--text-muted, #5a4a3a);
}

.chat-input:focus {
    border-color: rgba(255, 107, 0, 0.40);
    box-shadow: 0 0 0 2px rgba(255, 107, 0, 0.08), 0 0 8px rgba(255, 107, 0, 0.10);
}

.chat-send-btn {
    background: linear-gradient(135deg, #ff6b00, #ff9a3c);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 0.88rem;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.22s ease;
    flex-shrink: 0;
    box-shadow: 0 0 10px rgba(255, 107, 0, 0.25);
    user-select: none;
}

.chat-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 0 18px rgba(255, 107, 0, 0.45);
}

.chat-send-btn:active {
    transform: scale(0.94);
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ── Collapsed Tab (expand button) ───────────────────────── */
.chat-collapsed-tab {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%) translateX(100%);
    background: linear-gradient(135deg, rgba(12, 8, 4, 0.96), rgba(20, 12, 5, 0.98));
    border: 1px solid rgba(255, 107, 0, 0.22);
    border-right: none;
    border-radius: 10px 0 0 10px;
    padding: 12px 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    z-index: 100;
    transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
                background 0.22s ease,
                border-color 0.22s ease;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
    user-select: none;
}

/* Show tab only when chat is collapsed */
.chat-collapsed-tab.chat-tab-visible {
    transform: translateY(-50%) translateX(0);
}

.chat-collapsed-tab:hover {
    background: linear-gradient(135deg, rgba(255, 107, 0, 0.15), rgba(255, 154, 60, 0.08));
    border-color: rgba(255, 107, 0, 0.35);
}

.chat-tab-icon {
    font-size: 1.1rem;
    filter: drop-shadow(0 0 6px rgba(255, 107, 0, 0.35));
}

/* Unread badge */
.chat-tab-badge {
    background: linear-gradient(135deg, #ff6b00, #ff9a3c);
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 0.62rem;
    font-weight: 800;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    animation: badge-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 8px rgba(255, 107, 0, 0.40);
}

.chat-tab-badge.hidden {
    display: none;
}

@keyframes badge-pop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Name picker modal (shown once per session) ───────────── */
.chat-name-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.25s ease;
}

.chat-name-modal.hidden {
    display: none;
}

.chat-name-box {
    background: rgba(14, 10, 6, 0.97);
    border: 1px solid rgba(255, 107, 0, 0.25);
    border-radius: 16px;
    padding: 28px 28px 24px;
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.70), 0 0 30px rgba(255, 107, 0, 0.08);
    animation: fadeInUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-name-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary, #f5f0eb);
    text-align: center;
}

.chat-name-subtitle {
    font-family: 'Outfit', sans-serif;
    font-size: 0.74rem;
    color: var(--text-muted, #5a4a3a);
    text-align: center;
    margin-top: -6px;
}

.chat-name-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 107, 0, 0.20);
    border-radius: 10px;
    padding: 11px 14px;
    color: var(--text-primary, #f5f0eb);
    font-family: 'Outfit', sans-serif;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.22s ease, box-shadow 0.22s ease;
    caret-color: var(--orange-primary, #ff6b00);
    text-align: center;
}

.chat-name-input:focus {
    border-color: rgba(255, 107, 0, 0.45);
    box-shadow: 0 0 0 2px rgba(255, 107, 0, 0.10);
}

.chat-name-confirm-btn {
    background: linear-gradient(135deg, #ff6b00, #ff9a3c);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 11px;
    cursor: pointer;
    transition: all 0.22s ease;
    letter-spacing: 0.4px;
    box-shadow: 0 0 15px rgba(255, 107, 0, 0.30);
}

.chat-name-confirm-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 22px rgba(255, 107, 0, 0.50);
}

.chat-name-confirm-btn:active {
    transform: scale(0.97);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Mobile: hide chat panel ─────────────────────────────── */
@media (pointer: coarse) and (max-width: 768px) {
    .game-chat-panel {
        display: none !important;
    }
    .chat-collapsed-tab {
        display: none !important;
    }
}
