/* ============================================================
   MULTIPLAYER SYSTEM - MARMOTTE WORLD
   Styles pour le lobby, salon, et jeux multijoueur
   ============================================================ */

/* === MODAL MULTIJOUEUR === */
.multiplayer-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
}

.multiplayer-modal.hidden {
    display: none;
}

.mp-modal-content {
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.95), rgba(20, 20, 40, 0.98));
    border: 2px solid rgba(139, 92, 246, 0.3);
    border-radius: 24px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5), 0 0 40px rgba(139, 92, 246, 0.2);
}

.mp-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.mp-modal-close:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #ef4444;
    transform: rotate(90deg);
}

/* === HEADER DU JEU === */
.mp-game-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.05));
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}

.mp-game-icon {
    font-size: 3rem;
    filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.5));
}

.mp-game-info {
    flex: 1;
}

.mp-game-name {
    display: block;
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
}

.mp-players-info {
    display: block;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0.25rem;
}

/* === VUES DU LOBBY === */
.lobby-view {
    padding: 1.5rem;
}

.lobby-view.hidden {
    display: none;
}

/* === VUE CHOIX (CREER / REJOINDRE) === */
.lobby-choice-btns {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.lobby-choice-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.lobby-choice-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.lobby-choice-btn.create {
    border-color: rgba(16, 185, 129, 0.3);
}

.lobby-choice-btn.create:hover {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.5);
}

.lobby-choice-btn.join {
    border-color: rgba(59, 130, 246, 0.3);
}

.lobby-choice-btn.join:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.5);
}

.choice-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
}

.lobby-choice-btn.create .choice-icon {
    background: rgba(16, 185, 129, 0.15);
}

.lobby-choice-btn.join .choice-icon {
    background: rgba(59, 130, 246, 0.15);
}

.choice-info {
    flex: 1;
}

.choice-title {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

.choice-desc {
    display: block;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.25rem;
}

/* === VUE REJOINDRE === */
.join-form {
    text-align: center;
}

.join-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 1.5rem;
}

.join-input-wrapper {
    margin-bottom: 1rem;
}

.join-input {
    width: 100%;
    max-width: 250px;
    padding: 1rem 1.5rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 800;
    text-align: center;
    letter-spacing: 0.5rem;
    text-transform: uppercase;
    font-family: 'Nunito', sans-serif;
}

.join-input:focus {
    outline: none;
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
}

.join-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
    letter-spacing: 0.3rem;
}

.mp-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.mp-error.hidden {
    display: none;
}

.join-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

/* === BOUTONS MP === */
.btn-mp-primary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-mp-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(16, 185, 129, 0.4);
}

.btn-mp-secondary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1.5rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-mp-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

/* === VUE SALON / ROOM === */
.lobby-room-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Header du salon */
.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.room-game-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.room-game-icon {
    font-size: 2rem;
}

.room-game-name {
    display: block;
    font-weight: 700;
    color: #fff;
}

.room-game-mode {
    display: block;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
}

.room-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 20px;
    font-size: 0.75rem;
    color: #fbbf24;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #fbbf24;
    border-radius: 50%;
    animation: pulse-status 1.5s infinite;
}

@keyframes pulse-status {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Section code */
.lobby-code-section {
    text-align: center;
    padding: 1.25rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.code-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
}

.code-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.code-value {
    font-size: 2rem;
    font-weight: 900;
    color: #fff;
    letter-spacing: 0.4rem;
    font-family: 'Nunito', monospace;
    text-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
}

.btn-copy {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-copy:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.4);
    color: #fff;
}

.code-hint {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 0.75rem;
}

/* === AFFICHAGE CODE LOBBY === */
.lobby-code-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 1rem 0;
}

.lobby-code-value {
    font-size: 2.5rem;
    font-weight: 900;
    color: #fff;
    letter-spacing: 0.6rem;
    text-shadow: 0 0 30px rgba(139, 92, 246, 0.6);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(99, 102, 241, 0.1));
    padding: 1rem 2rem;
    border-radius: 16px;
    border: 2px solid rgba(139, 92, 246, 0.3);
    font-family: 'Courier New', monospace;
}

.btn-copy-code {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.2rem;
    border: 2px solid rgba(139, 92, 246, 0.4);
    border-radius: 12px;
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-copy-code:hover {
    background: rgba(139, 92, 246, 0.3);
    border-color: rgba(139, 92, 246, 0.6);
    color: #fff;
    transform: scale(1.05);
}

/* Join avec scanner QR */
.join-or-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.85rem;
}

.join-or-divider::before,
.join-or-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.btn-scan-qr {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1rem;
    border: 2px dashed rgba(139, 92, 246, 0.3);
    border-radius: 12px;
    background: rgba(139, 92, 246, 0.05);
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-scan-qr:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.5);
    color: #fff;
}

.scan-icon {
    font-size: 1.5rem;
}

/* QR Scanner Modal */
.qr-scanner-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
}

.qr-scanner-modal.hidden {
    display: none;
}

.qr-scanner-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.qr-scanner-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.5rem;
}

.qr-scanner-subtitle {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
}

.qr-scanner-container {
    position: relative;
    width: 280px;
    height: 280px;
    border-radius: 20px;
    overflow: hidden;
    background: #000;
}

.qr-scanner-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.qr-scanner-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.qr-scanner-frame {
    position: absolute;
    inset: 40px;
    border: 3px solid rgba(139, 92, 246, 0.8);
    border-radius: 15px;
}

.qr-scanner-frame::before,
.qr-scanner-frame::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border-color: #8b5cf6;
    border-style: solid;
}

.qr-scanner-frame::before {
    top: -3px;
    left: -3px;
    border-width: 4px 0 0 4px;
    border-radius: 10px 0 0 0;
}

.qr-scanner-frame::after {
    top: -3px;
    right: -3px;
    border-width: 4px 4px 0 0;
    border-radius: 0 10px 0 0;
}

.qr-scanner-corners-bottom {
    position: absolute;
    inset: 40px;
    pointer-events: none;
}

.qr-scanner-corners-bottom::before,
.qr-scanner-corners-bottom::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border-color: #8b5cf6;
    border-style: solid;
}

.qr-scanner-corners-bottom::before {
    bottom: -3px;
    left: -3px;
    border-width: 0 0 4px 4px;
    border-radius: 0 0 0 10px;
}

.qr-scanner-corners-bottom::after {
    bottom: -3px;
    right: -3px;
    border-width: 0 4px 4px 0;
    border-radius: 0 0 10px 0;
}

.qr-scanner-line {
    position: absolute;
    left: 40px;
    right: 40px;
    height: 2px;
    background: linear-gradient(90deg, transparent, #8b5cf6, transparent);
    animation: scan-line 2s ease-in-out infinite;
}

@keyframes scan-line {
    0%, 100% { top: 45px; }
    50% { top: calc(100% - 45px); }
}

.qr-scanner-actions {
    margin-top: 1.5rem;
}

.btn-close-scanner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 2rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-close-scanner:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

/* Section joueurs */
.players-section {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1rem;
}

.players-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.players-title {
    font-weight: 700;
    color: #fff;
}

.players-count {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.6rem;
    border-radius: 10px;
}

.lobby-players {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.lobby-player {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.lobby-player.ready {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
}

.lobby-player.host {
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.3);
}

.player-avatar {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.player-info {
    flex: 1;
}

.player-name {
    display: block;
    font-weight: 600;
    color: #fff;
}

.player-status {
    display: block;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.lobby-player.ready .player-status {
    color: #10b981;
}

/* Actions du lobby */
.lobby-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.btn-action {
    flex: 1;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-ready {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
}

.btn-ready:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(16, 185, 129, 0.4);
}

.btn-ready.is-ready {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.btn-start {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: #fff;
}

.btn-start:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(139, 92, 246, 0.4);
}

.btn-start:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-leave {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.btn-leave:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* === MODAL CHOIX SOLO/MULTI (si besoin) === */
.game-mode-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    padding: 1rem;
}

.game-mode-modal.hidden {
    display: none;
}

.gm-modal-content {
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.95), rgba(20, 20, 40, 0.98));
    border: 2px solid rgba(139, 92, 246, 0.3);
    border-radius: 24px;
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    position: relative;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
}

.gm-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
}

.gm-modal-close:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.gm-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.gm-game-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
}

.gm-game-name {
    font-size: 1.3rem;
    font-weight: 800;
    color: #fff;
}

.gm-title {
    text-align: center;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 1.25rem;
}

.gm-view.hidden {
    display: none;
}

.gm-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.gm-option-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.gm-option-btn:hover {
    transform: translateX(5px);
}

.gm-option-btn.solo {
    border-color: rgba(59, 130, 246, 0.3);
}

.gm-option-btn.solo:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.5);
}

.gm-option-btn.multi {
    border-color: rgba(16, 185, 129, 0.3);
}

.gm-option-btn.multi:hover {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.5);
}

.gm-option-icon {
    font-size: 1.75rem;
    width: 45px;
    text-align: center;
}

.gm-option-info {
    flex: 1;
}

.gm-option-title {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
}

.gm-option-desc {
    display: block;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
}

.gm-option-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
}

/* === RESPONSIVE === */
@media (max-width: 500px) {
    .mp-modal-content,
    .gm-modal-content {
        border-radius: 20px;
        margin: 0.5rem;
    }

    .mp-game-header {
        padding: 1rem;
    }

    .mp-game-icon {
        font-size: 2.5rem;
    }

    .mp-game-name {
        font-size: 1.2rem;
    }

    .lobby-view {
        padding: 1rem;
    }

    .code-value {
        font-size: 1.5rem;
        letter-spacing: 0.3rem;
    }

    .lobby-actions {
        flex-direction: column;
    }

    .btn-action {
        width: 100%;
    }
}
