/**
 * Estilos do jogo de Sinuca Online
 * Design moderno e responsivo
 */

/* ============ RESET E BASE ============ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Cores principais */
    --color-bg: #1a1a2e;
    --color-bg-light: #16213e;
    --color-bg-dark: #0f0f1a;
    --color-primary: #e94560;
    --color-primary-dark: #c73e54;
    --color-secondary: #0f3460;
    --color-accent: #53d769;
    --color-warning: #f5a623;
    --color-danger: #e74c3c;
    
    /* Texto */
    --color-text: #ffffff;
    --color-text-muted: #a0a0a0;
    
    /* Discord */
    --color-discord: #5865F2;
    --color-discord-dark: #4752C4;
    
    /* Mesa de sinuca */
    --table-felt: #0f6b3a;
    --table-rail: #4a2c0a;
    --table-pocket: #1a1a1a;
    
    /* Dimensões */
    --header-height: 60px;
    --footer-height: 50px;
    
    /* Animações */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

html, body {
    height: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    overflow: hidden;
}

/* ============ TELAS ============ */

.screen {
    display: none;
    width: 100%;
    height: 100%;
}

.screen.active {
    display: flex;
}

/* ============ TELA DE LOGIN ============ */

#login-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--color-bg-dark) 0%, var(--color-bg) 50%, var(--color-secondary) 100%);
}

.login-container {
    text-align: center;
    padding: 40px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logo {
    margin-bottom: 30px;
}

.logo-icon {
    font-size: 64px;
    display: block;
    margin-bottom: 10px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(45deg, var(--color-primary), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo p {
    color: var(--color-text-muted);
    font-size: 1.1rem;
    margin-top: 5px;
}

/* ============ BOTÕES ============ */

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    transition: all var(--transition-fast);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-discord {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background: var(--color-discord);
    border-radius: 10px;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

.btn-discord:hover {
    background: var(--color-discord-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(88, 101, 242, 0.4);
}

.discord-icon {
    width: 24px;
    height: 24px;
}

.btn-primary {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--color-primary);
    border-radius: 8px;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
}

.btn-secondary {
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text);
    background: var(--color-secondary);
    border-radius: 8px;
}

.btn-secondary:hover {
    background: #1a4a7a;
}

.btn-danger {
    background: var(--color-danger);
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-large {
    padding: 18px 36px;
    font-size: 1.2rem;
    width: 100%;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-tiny {
    padding: 4px 8px;
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.btn-icon {
    margin-right: 8px;
}

/* ============ STATS DO LOGIN ============ */

.server-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 30px;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* ============ TELA DE LOBBY ============ */

#lobby-screen {
    flex-direction: column;
}

.lobby-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--color-bg-light);
    border-radius: 12px;
    margin-bottom: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--color-primary);
}

.user-details {
    display: flex;
    flex-direction: column;
}

.username {
    font-weight: 600;
    font-size: 1.1rem;
}

.rating {
    color: var(--color-accent);
    font-size: 0.9rem;
}

/* ============ CONTEÚDO DO LOBBY ============ */

.lobby-main {
    display: grid;
    grid-template-columns: 1fr 300px;
    grid-template-rows: auto 1fr;
    gap: 20px;
    flex: 1;
    overflow: hidden;
}

.lobby-actions {
    grid-row: span 2;
    background: var(--color-bg-light);
    border-radius: 12px;
    padding: 25px;
}

.lobby-actions h2 {
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.lobby-ranking, .lobby-stats {
    background: var(--color-bg-light);
    border-radius: 12px;
    padding: 20px;
}

.lobby-ranking h2, .lobby-stats h2 {
    margin-bottom: 15px;
    font-size: 1.1rem;
}

/* ============ STATUS DE MATCHMAKING ============ */

.status-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-top: 15px;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* ============ SALA PRIVADA ============ */

.divider {
    text-align: center;
    color: var(--color-text-muted);
    margin: 20px 0;
    position: relative;
}

.divider::before, .divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.divider::before { left: 0; }
.divider::after { right: 0; }

.private-room {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.room-code {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px;
    background: rgba(83, 215, 105, 0.1);
    border: 1px solid var(--color-accent);
    border-radius: 8px;
}

.room-code strong {
    font-family: monospace;
    font-size: 1.3rem;
    letter-spacing: 2px;
    color: var(--color-accent);
}

.join-room {
    display: flex;
    gap: 10px;
}

.join-room input {
    flex: 1;
    padding: 12px 16px;
    font-size: 1rem;
    background: var(--color-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
}

.join-room input::placeholder {
    text-transform: none;
    letter-spacing: normal;
}

.join-room input:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* ============ RANKING ============ */

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.ranking-position {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    border-radius: 50%;
    background: var(--color-secondary);
}

.ranking-position.gold { background: #ffd700; color: #000; }
.ranking-position.silver { background: #c0c0c0; color: #000; }
.ranking-position.bronze { background: #cd7f32; color: #000; }

.ranking-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-rating {
    color: var(--color-accent);
    font-weight: 600;
}

/* ============ ESTATÍSTICAS ============ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.stat-item {
    text-align: center;
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* ============ FOOTER DO LOBBY ============ */

.lobby-footer {
    display: flex;
    justify-content: space-between;
    padding: 15px 20px;
    background: var(--color-bg-light);
    border-radius: 12px;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

#server-status {
    color: var(--color-accent);
}

/* ============ TELA DE JOGO ============ */

#game-screen {
    flex-direction: column;
}

.game-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--color-bg-dark);
}

/* ============ HEADER DO JOGO ============ */

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: var(--color-bg-light);
    height: var(--header-height);
}

.player-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    min-width: 200px;
}

.player-panel.active {
    background: rgba(83, 215, 105, 0.15);
    border: 1px solid var(--color-accent);
}

.player-panel .avatar {
    width: 40px;
    height: 40px;
}

.player-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.player-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.balltype-pill {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.3px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--color-text);
    user-select: none;
}

.balltype-pill.solid {
    border-color: rgba(255, 165, 0, 0.35);
}

.balltype-pill.stripe {
    border-color: rgba(0, 102, 204, 0.35);
}

.balls-count {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    user-select: none;
}

.player-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.ball-indicator {
    display: flex;
    gap: 4px;
}

.ball-indicator .ball-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(0, 0, 0, 0.35);
}
.ball-indicator .ball-dot.stripe {
    border: 1px solid rgba(255, 255, 255, 0.35);
}
.ball-indicator .ball-dot.pocketed { opacity: 0.3; }

.turn-indicator {
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 4px;
    background: var(--color-secondary);
    opacity: 0.5;
}

.player-panel.active .turn-indicator {
    background: var(--color-accent);
    color: #000;
    opacity: 1;
}

.game-info-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.turn-timer {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text);
    font-family: monospace;
}

.turn-timer.warning {
    color: var(--color-warning);
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.game-status {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* ============ ÁREA DO JOGO ============ */

.game-main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow: hidden;
}

.table-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    max-height: 100%;
}

#game-canvas {
    display: block;
    position: relative;
    z-index: 1;
    border-radius: 10px;
    touch-action: none;
    box-shadow: 
        0 0 0 8px var(--table-rail),
        0 0 0 12px #2a1a05,
        0 10px 40px rgba(0, 0, 0, 0.5);
}


/* ============ BARRA DE FORÇA ============ */

.power-bar-container {
    position: absolute;
    right: -80px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.power-bar-container.active {
    opacity: 1;
}

.power-bar {
    width: 24px;
    height: 210px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.power-fill {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: linear-gradient(to top, #00ff00, #ffff00, #ff0000);
    transition: height 0.05s linear;
}

.power-label {
    font-weight: 700;
    font-size: 0.9rem;
}

/* ============ FOOTER DO JOGO ============ */

.game-footer {
    padding: 10px 20px;
    background: var(--color-bg-light);
    height: var(--footer-height);
}

.game-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shot-instructions {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.quick-chat {
    display: flex;
    gap: 8px;
}

.emote-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    color: var(--color-text);
}

.emote-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============ MODAL DE FIM DE JOGO ============ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--color-bg-light);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    animation: modalIn 0.3s ease;
    max-width: 400px;
    width: 90%;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.result-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.modal-content h2 {
    font-size: 2rem;
    margin-bottom: 10px;
}

.modal-content p {
    color: var(--color-text-muted);
    margin-bottom: 25px;
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 30px;
}

.result-stats .stat-value {
    color: var(--color-accent);
}

.result-stats .stat-value.negative {
    color: var(--color-danger);
}

/* ============ TOAST ============ */

#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 20px;
    background: var(--color-bg-light);
    border-radius: 8px;
    border-left: 4px solid var(--color-primary);
    animation: toastIn 0.3s ease;
    max-width: 300px;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success { border-left-color: var(--color-accent); }
.toast.error { border-left-color: var(--color-danger); }
.toast.warning { border-left-color: var(--color-warning); }

/* ============ SCROLLBAR ============ */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============ RESPONSIVO ============ */

@media (max-width: 900px) {
    .lobby-main {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .lobby-actions {
        grid-row: auto;
    }

    .game-header {
        flex-wrap: wrap;
        height: auto;
        padding: 10px;
        gap: 10px;
    }

    .player-panel {
        min-width: auto;
        flex: 1;
    }

    .game-info-center {
        order: -1;
        width: 100%;
    }

    .power-bar-container {
        left: 10px;
        top: 10px;
        transform: none;
        flex-direction: row;
    }

    .power-bar {
        width: 150px;
        height: 20px;
    }

    .power-fill {
        left: 0;
        height: 100%;
        width: 0;
        background: linear-gradient(to right, #00ff00, #ffff00, #ff0000);
    }
}

@media (max-width: 600px) {
    .login-container {
        padding: 25px;
        margin: 10px;
    }

    .logo h1 {
        font-size: 1.8rem;
    }

    .lobby-container {
        padding: 10px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .game-main {
        padding: 10px;
    }
}
