/**
 * Chat Widget — Floating Support Chat
 * Matches the dark gaming theme of the site.
 */

/* Floating chat button */
.chat-fab {
    position: fixed;
    bottom: calc(var(--nav-height, 64px) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--fire-orange, #FF6B00), var(--fire-red, #FF2D2D));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 200;
    box-shadow: 0 4px 20px rgba(255, 107, 0, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}
.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(255, 107, 0, 0.6);
}
.chat-fab:active {
    transform: scale(0.95);
}
.chat-fab.open {
    transform: rotate(90deg);
    background: var(--bg-card, #1A1A2E);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Unread badge on FAB */
.chat-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: var(--green, #00FF88);
    color: #000;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    line-height: 1;
}
.chat-fab-badge.show {
    display: flex;
}

/* Chat panel */
.chat-panel {
    position: fixed;
    bottom: calc(var(--nav-height, 64px) + 80px);
    right: 16px;
    width: calc(100vw - 32px);
    max-width: 380px;
    height: 480px;
    max-height: calc(100vh - var(--nav-height, 64px) - 110px);
    background: var(--bg-dark, #0D0D1A);
    border: 1px solid var(--border, #2a2a4a);
    border-radius: 16px;
    z-index: 200;
    display: none;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    animation: chatSlideIn 0.25s ease-out;
}
.chat-panel.open {
    display: flex;
}
@keyframes chatSlideIn {
    from { opacity: 0; transform: translateY(16px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Chat header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-card, #1A1A2E);
    border-bottom: 1px solid var(--border, #2a2a4a);
}
.chat-header-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary, #fff);
}
.chat-header-status {
    font-size: 11px;
    color: var(--green, #00FF88);
    margin-left: 6px;
}
.chat-close-btn {
    background: none;
    border: none;
    color: var(--text-muted, #64748B);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.chat-close-btn:hover {
    color: var(--text-primary, #fff);
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bg-dark, #0D0D1A);
}
.chat-messages::-webkit-scrollbar {
    width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border, #2a2a4a);
    border-radius: 2px;
}

/* Single message */
.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: chatMsgIn 0.2s ease-out;
}
@keyframes chatMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.chat-msg.player {
    align-self: flex-end;
    align-items: flex-end;
}
.chat-msg.admin {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}
.chat-msg.player .chat-msg-bubble {
    background: linear-gradient(135deg, var(--fire-orange, #FF6B00), #e05500);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg.admin .chat-msg-bubble {
    background: var(--bg-card, #1A1A2E);
    border: 1px solid var(--border, #2a2a4a);
    color: var(--text-primary, #fff);
    border-bottom-left-radius: 4px;
}
.chat-msg-sender {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted, #64748B);
    margin-bottom: 2px;
    padding: 0 4px;
}
.chat-msg.admin .chat-msg-sender {
    color: var(--diamond-blue, #00D4FF);
}
.chat-msg-time {
    font-size: 10px;
    color: var(--text-muted, #64748B);
    margin-top: 2px;
    padding: 0 4px;
    opacity: 0.7;
}

/* Chat input area */
.chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-card, #1A1A2E);
    border-top: 1px solid var(--border, #2a2a4a);
}
.chat-input {
    flex: 1;
    background: var(--bg-input, #0D0D1A);
    border: 1px solid var(--border, #2a2a4a);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-primary, #fff);
    outline: none;
    font-family: var(--font, 'Segoe UI', sans-serif);
    resize: none;
}
.chat-input::placeholder {
    color: var(--text-muted, #64748B);
}
.chat-input:focus {
    border-color: var(--fire-orange, #FF6B00);
}
.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--fire-orange, #FF6B00), #e05500);
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, opacity 0.15s;
}
.chat-send-btn:hover {
    transform: scale(1.05);
}
.chat-send-btn:active {
    transform: scale(0.92);
}
.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: default;
    transform: none;
}

/* Not logged in / login prompt */
.chat-login-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 12px;
    padding: 30px;
    text-align: center;
}
.chat-login-prompt-icon {
    font-size: 40px;
}
.chat-login-prompt-text {
    font-size: 14px;
    color: var(--text-secondary, #94A3B8);
    line-height: 1.6;
}
.chat-login-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--fire-orange, #FF6B00), #e05500);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
}
.chat-login-btn:hover {
    transform: scale(1.03);
}

/* Empty state */
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 8px;
    padding: 30px;
    text-align: center;
}
.chat-empty-icon {
    font-size: 36px;
}
.chat-empty-text {
    font-size: 13px;
    color: var(--text-muted, #64748B);
}

/* Closed conversation notice */
.chat-closed-notice {
    padding: 10px 14px;
    background: rgba(255,45,45,0.1);
    border: 1px solid rgba(255,45,45,0.2);
    border-radius: 8px;
    text-align: center;
    font-size: 12px;
    color: var(--fire-red, #FF2D2D);
    margin: 4px 0;
}

/* Typing indicator */
.chat-typing {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 4px 16px;
    font-size: 11px;
    color: var(--text-muted, #64748B);
}
.chat-typing.show {
    display: flex;
}
.chat-typing-dots span {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-muted, #64748B);
    animation: chatTyping 1.2s infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatTyping {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

/* Error / status toast in chat */
.chat-status {
    display: none;
    padding: 6px 12px;
    font-size: 12px;
    text-align: center;
    color: var(--fire-red, #FF2D2D);
    background: rgba(255,45,45,0.08);
}
.chat-status.show {
    display: block;
}

/* Responsive: on very small screens */
@media (max-width: 360px) {
    .chat-panel {
        right: 8px;
        width: calc(100vw - 16px);
        bottom: calc(var(--nav-height, 64px) + 72px);
        height: 420px;
    }
    .chat-fab {
        right: 12px;
        bottom: calc(var(--nav-height, 64px) + 12px);
        width: 50px;
        height: 50px;
        font-size: 22px;
    }
}
