/* ============================================
   Live Chat + History Panel
   ============================================ */

/* ── Chat Toggle Button (floating) ── */
.chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 900;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-card));
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--color-gold);
    transition: all 0.2s ease;
    cursor: pointer;
}

.chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.5);
    border-color: var(--color-gold);
}

.chat-toggle__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: var(--color-red);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* ── Chat Panel ── */
.chat {
    position: fixed;
    bottom: 82px;
    right: 20px;
    width: 340px;
    height: 480px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    z-index: 899;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chat__header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 700;
}

.chat__header-title i { color: var(--color-gold); }

.chat__online {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat__online-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-green);
}

/* ── Messages ── */
.chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-light) transparent;
}

.chat__msg {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    line-height: 1.4;
    animation: chatFadeIn 0.2s ease;
}

@keyframes chatFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat__msg:hover { background: rgba(255, 255, 255, 0.02); }

.chat__msg-time {
    color: var(--text-muted);
    font-size: 0.62rem;
    flex-shrink: 0;
    opacity: 0.6;
}

.chat__msg-user {
    color: var(--color-gold);
    font-weight: 700;
    font-size: 0.72rem;
    flex-shrink: 0;
    white-space: nowrap;
}

.chat__msg-text {
    color: var(--text-secondary);
    word-break: break-word;
}

.chat__msg--self .chat__msg-user { color: var(--color-green); }
.chat__msg--self .chat__msg-text { color: var(--text-bright); }

.chat__msg--system {
    justify-content: center;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin: 4px 0;
}

.chat__msg--system .chat__msg-text {
    color: var(--text-muted);
    font-size: 0.7rem;
    text-align: center;
}

.chat__msg--system .chat__msg-text strong { color: var(--color-gold); }

/* ── Input ── */
.chat__input {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chat__input-field {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.chat__input-field:focus { border-color: var(--color-gold); }

.chat__input-field::placeholder { color: var(--text-muted); }

.chat__send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-gold);
    color: #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.chat__send:hover {
    transform: scale(1.08);
    background: #e6c44d;
}

/* Chat embedded below the betting table */
.table-chat {
    margin-top: 14px;
}

.chat--table {
    position: static;
    width: 100%;
    height: 220px;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    border-radius: var(--radius-md);
}

.chat--table .chat__messages {
    min-height: 0;
}

.chat--table .chat__header {
    background: rgba(255, 255, 255, 0.02);
}

.chat--table .chat__input-field {
    min-width: 0;
}

/* ════════════════════════════════════════════
   RESULT DISPLAY (overlay after spin)
   ════════════════════════════════════════════ */

.result-display {
    position: fixed;
    inset: 0;
    z-index: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.result-display--visible {
    opacity: 1;
    pointer-events: auto;
}

.result-display__inner {
    text-align: center;
    transform: scale(0.7);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result-display--visible .result-display__inner {
    transform: scale(1);
}

.result-display__number {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 900;
    margin: 0 auto 16px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.4);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    color: #fff;
}

.result-display__number--red {
    background: linear-gradient(135deg, #e84040, #b02020);
    box-shadow: 0 0 60px rgba(232, 64, 64, 0.4);
}

.result-display__number--black {
    background: linear-gradient(135deg, #3a3a4e, #1a1a2e);
    box-shadow: 0 0 60px rgba(50, 50, 70, 0.4);
}

.result-display__number--white {
    background: linear-gradient(135deg, #e6c44d, #c9a82f);
    color: #1a1a2e;
    box-shadow: 0 0 60px rgba(201, 168, 47, 0.5);
}

.result-display__color {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.result-display__outcome {
    font-size: 1.8rem;
    font-weight: 900;
    min-height: 44px;
}

.result-display__outcome--win {
    color: var(--color-green);
    text-shadow: 0 0 20px rgba(0, 199, 77, 0.4);
}

.result-display__outcome--loss {
    color: var(--color-red-light);
    text-shadow: 0 0 20px rgba(232, 64, 62, 0.3);
}

.result-display__outcome--none {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 600;
}

/* ── Win glow pulse ── */
.result-display--win .result-display__number {
    animation: winPulse 0.8s ease infinite alternate;
}

@keyframes winPulse {
    from { transform: scale(1); filter: brightness(1); }
    to { transform: scale(1.06); filter: brightness(1.2); }
}

/* ── Confetti Particles ── */
.confetti-particle {
    position: fixed;
    width: 8px;
    height: 8px;
    z-index: 801;
    pointer-events: none;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    0% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
    100% { opacity: 0; transform: translateY(100vh) rotate(720deg) scale(0.3); }
}

/* ── Floating win amount ── */
.floating-win {
    position: fixed;
    left: 50%;
    top: 40%;
    transform: translateX(-50%);
    font-size: 2rem;
    font-weight: 900;
    color: var(--color-green);
    text-shadow: 0 0 20px rgba(0, 199, 77, 0.5);
    z-index: 802;
    pointer-events: none;
    animation: floatUp 2s ease forwards;
}

@keyframes floatUp {
    0% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-80px); }
}

/* ════════════════════════════════════════════
   BET HISTORY PANEL
   ════════════════════════════════════════════ */

.history-panel {
    margin-top: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.history-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
    transition: background 0.2s;
}

.history-panel__header:hover { background: rgba(255, 255, 255, 0.02); }

.history-panel__header i:first-child { color: var(--color-gold); margin-right: 8px; }

.history-panel__arrow {
    transition: transform 0.3s ease;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.history-panel--open .history-panel__arrow { transform: rotate(180deg); }

.history-panel__body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.history-panel--open .history-panel__body { max-height: 400px; }

.history-panel__list {
    padding: 0 12px 12px;
    max-height: 380px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-light) transparent;
}

.history-panel__empty {
    text-align: center;
    padding: 30px 16px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.history-panel__empty i {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 8px;
    opacity: 0.3;
}

/* ── History Entry ── */
.history__entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    transition: background 0.15s;
}

.history__entry:hover { background: rgba(255, 255, 255, 0.02); }

.history__entry + .history__entry { border-top: 1px solid rgba(255, 255, 255, 0.03); }

.history__round {
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    min-width: 36px;
}

.history__result-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}

.history__result-num--red { background: var(--color-red); }
.history__result-num--black { background: var(--color-black); }
.history__result-num--white { background: var(--color-white); color: #1a1a2e; }

.history__bet-type {
    flex: 1;
    color: var(--text-secondary);
    font-weight: 600;
}

.history__amount {
    color: var(--text-muted);
    font-weight: 600;
    text-align: right;
    min-width: 65px;
}

.history__profit {
    font-weight: 800;
    text-align: right;
    min-width: 75px;
}

.history__profit--win { color: var(--color-green); }
.history__profit--loss { color: var(--color-red-light); }

/* ════════════════════════════════════════════
   RESPONSIVE — Chat + Result + History
   ════════════════════════════════════════════ */

@media (max-width: 768px) {
    .chat {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 72px;
        height: 400px;
    }

    .chat-toggle {
        bottom: 14px;
        right: 14px;
        width: 46px;
        height: 46px;
    }

    .result-display__number {
        width: 90px;
        height: 90px;
        font-size: 2.2rem;
    }

    .result-display__outcome { font-size: 1.3rem; }

    .history__entry { gap: 6px; padding: 6px 6px; font-size: 0.72rem; }
}

@media (max-width: 480px) {
    .chat {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 64px;
        height: 350px;
        border-radius: var(--radius-md);
    }

    .chat-toggle {
        bottom: 10px;
        right: 10px;
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }

    .result-display__number {
        width: 76px;
        height: 76px;
        font-size: 1.8rem;
    }

    .result-display__outcome { font-size: 1.1rem; }
    .floating-win { font-size: 1.4rem; }
}

@media (max-width: 768px) {
    .chat--table {
        width: 100%;
        right: auto;
        bottom: auto;
        height: 260px;
    }
}

@media (max-width: 480px) {
    .chat--table {
        width: 100%;
        right: auto;
        bottom: auto;
        height: 240px;
    }
}
