/* === VARIABLES CSS === */
:root {
    --primary-color: #3B82F6;
    --secondary-color: #10B981;
    --accent-color: #F59E0B;
    --error-color: #EF4444;
    --success-color: #22C55E;
    --warning-color: #F59E0B;
    --excellent-color: #8B5CF6;
    --neutral-color: #6B7280;
    --background-color: #F8FAFC;
    --background: #F8FAFC;
    --card-background: #FFFFFF;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --primary-light: #EBF4FF;
    --shadow-light: 0 2px 4px rgba(0, 0, 0, 0.05);
    --border-radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

/* === RESET ET BASE === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

/* === LAYOUT PRINCIPAL === */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 80px 20px 20px 20px; /* Top padding pour la top bar (60px + 20px) */
    min-height: 100vh;
    position: relative;
}

/* Optimisation pour écrans larges */
@media (min-width: 1440px) {
    .container {
        max-width: 1600px;
        padding: 80px 40px 20px 40px;
    }
}

/* === TOP BAR === */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logger-toggle {
    background: var(--primary-color);
    border: none;
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    margin-left: 10px;
    box-shadow: var(--shadow);
}

.logger-toggle:hover {
    background: var(--accent-color);
    transform: translateY(-1px);
}

.top-bar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* === NETWORK STATUS INDICATOR === */
.network-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.network-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: relative;
    transition: all 0.3s ease;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.network-indicator.connecting {
    background: #F59E0B;
    animation: pulse-orange 1.5s infinite;
}

.network-indicator.online {
    background: #22C55E;
    animation: pulse-green 2s infinite;
}

.network-indicator.offline {
    background: #EF4444;
    animation: pulse-red 1s infinite;
}

.network-status-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.network-indicator.connecting + .network-status-text {
    color: #F59E0B;
}

.network-indicator.online + .network-status-text {
    color: #22C55E;
}

.network-indicator.offline + .network-status-text {
    color: #EF4444;
}

@keyframes pulse-green {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.3);
    }
}

@keyframes pulse-orange {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.4);
    }
}

@keyframes pulse-red {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.4);
    }
}

/* === OLD CONNECTION STATUS INDICATOR - DEPRECATED === */
.connection-status {
    display: none;
}

.status-indicator {
    display: none;
}

.status-icon {
    display: none;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* === PAGES === */
.page {
    display: none;
    animation: fadeIn 0.4s ease-in-out;
    background: var(--background-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 30px;
    margin-top: 20px;
}

.page.active {
    display: block;
}

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

/* === HERO SECTION === */
.hero {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 20px;
}

.hero h1 {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.hero p {
    font-size: 1.3rem;
    color: var(--text-secondary);
    font-weight: 300;
}

/* === PAGE HEADERS === */
.page-header {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.page-header .back-btn {
    position: absolute;
    left: 0;
    top: 0;
}

.page-header h2 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.page-header p {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* === CARDS SYSTEM === */
.main-options {
    display: grid;
    gap: 20px;
    max-width: 600px;
    margin: 0 auto;
}

#games-grid {
    display: block !important;
    margin-top: 20px !important;
    max-width: none !important;
    width: 100% !important;
}

.compatible-games-section,
.incompatible-games-section {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
    gap: 15px !important;
    margin-bottom: 30px !important;
}

.section-title {
    grid-column: 1 / -1 !important;
    margin-bottom: 15px !important;
    font-size: 1.2rem !important;
    font-weight: 600 !important;
    color: var(--text-primary) !important;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-top: 30px;
}

/* Optimisation pour desktop : plus de colonnes pour les jeux */
@media (min-width: 1200px) {
    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 18px;
    }

    .game-card {
        min-height: 140px;
    }
}

.option-card, .game-card, .level-card {
    background: var(--card-background);
    border: 3px solid transparent;
    border-radius: var(--border-radius);
    padding: 20px 15px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.option-card:hover, .game-card:hover, .level-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.option-card.primary {
    background: linear-gradient(135deg, var(--primary-color), #2563EB);
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
}

.option-card.primary:hover {
    background: linear-gradient(135deg, #2563EB, var(--primary-color));
    border-color: white;
}

.option-card.secondary {
    border: 2px solid var(--neutral-color);
}

.option-card span {
    display: block;
    margin-top: 10px;
}

.option-card small {
    display: block;
    margin-top: 8px;
    font-size: 0.85rem;
    opacity: 0.7;
}

/* === GAME CARDS === */
.game-card {
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 2px solid #e5e7eb;
}

.game-card:hover {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
}

.game-card .icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.game-card .title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.game-card .description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* === LEVEL CARDS === */
.level-card {
    min-height: 160px;
    border: 2px solid #e5e7eb;
}

.level-card:hover {
    border-color: var(--secondary-color);
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
}

.level-card .icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.level-card .title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.level-card .description {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* === BOUTONS === */
button {
    border: none;
    outline: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    transition: var(--transition);
    border-radius: var(--border-radius);
    padding: 12px 24px;
    font-weight: 500;
}

.back-btn {
    background: var(--neutral-color);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
}

.back-btn:hover {
    background: #4B5563;
    transform: translateX(-2px);
}

/* === MODAL === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--card-background);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
    max-width: 400px;
    margin: 20px;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-content h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 25px;
}

.modal-content button {
    background: var(--primary-color);
    color: white;
    padding: 12px 30px;
    border-radius: 25px;
}

.modal-content button:hover {
    background: #2563EB;
}

/* === LOADING === */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.loading.show {
    opacity: 1;
    visibility: visible;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .container {
        padding: 80px 15px 15px 15px;
    }

    .top-bar {
        padding: 0 15px;
    }

    .top-bar-title {
        font-size: 1rem;
    }

    .network-status-text {
        display: none; /* Masquer le texte sur mobile */
    }

    .hero h1 {
        font-size: 2.2rem;
    }

    .hero p {
        font-size: 1.1rem;
    }

    .page-header h2 {
        font-size: 2rem;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
    }

    .page {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .hero h1 {
        font-size: 1.8rem;
    }

    .option-card, .game-card, .level-card {
        padding: 20px 15px;
    }

    .modal-content {
        padding: 30px 20px;
        margin: 15px;
    }
}

/* === COMPATIBILITÉ CONTENT-GAME === */

/* Sections des jeux compatibles/incompatibles */
.compatible-games-section,
.incompatible-games-section {
    margin-bottom: 40px;
}

.section-title {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 20px;
    padding: 10px 0;
    border-bottom: 2px solid var(--border-color);
}

.compatible-games-section .section-title {
    color: var(--success-color);
    border-bottom-color: var(--success-color);
}

.incompatible-games-section .section-title {
    color: var(--warning-color);
    border-bottom-color: var(--warning-color);
}

/* Badges de compatibilité */
.compatibility-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    min-width: 80px;
    z-index: 2;
}

.compatibility-badge.excellent {
    background: linear-gradient(135deg, var(--excellent-color), #A855F7);
    color: white;
}

.compatibility-badge.good {
    background: linear-gradient(135deg, var(--success-color), #16A34A);
    color: white;
}

.compatibility-badge.compatible {
    background: linear-gradient(135deg, var(--secondary-color), #059669);
    color: white;
}

.compatibility-badge.incompatible {
    background: linear-gradient(135deg, var(--warning-color), #D97706);
    color: white;
}

.compatibility-badge.unknown {
    background: linear-gradient(135deg, var(--neutral-color), #4B5563);
    color: white;
}

/* Informations de compatibilité dans les cartes */
.compatibility-info {
    margin-top: 12px;
    padding: 10px;
    background: var(--background);
    border-radius: 8px;
    border-left: 3px solid var(--secondary-color);
}

.compatibility-score {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.9rem;
}

.compatibility-reason {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.4;
}

/* Cartes avec états de compatibilité */
.game-card.compatible {
    border: 2px solid var(--success-color);
    background: linear-gradient(135deg, #F0FDF4 0%, #DCFCE7 100%);
}

.game-card.incompatible {
    border: 2px solid var(--warning-color);
    background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
    opacity: 0.8;
    cursor: help;
}

.game-card.incompatible .compatibility-info {
    border-left-color: var(--warning-color);
}

/* Avertissement pour jeux incompatibles */
.incompatible-warning {
    margin-top: 10px;
    padding: 8px 12px;
    background: var(--warning-color);
    color: white;
    border-radius: 6px;
    font-size: 0.8rem;
    text-align: center;
    font-weight: 500;
}

/* Header des cartes avec icône et badge */
.card-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.game-card .icon {
    font-size: 2.5rem;
    margin-bottom: 0;
    z-index: 1;
}

/* Modal d'aide à la compatibilité */
.compatibility-help-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.compatibility-help-modal .modal-content {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.compatibility-help-modal .modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.compatibility-help-modal .modal-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.compatibility-help-modal .close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    color: var(--text-secondary);
    transition: var(--transition);
}

.compatibility-help-modal .close-btn:hover {
    color: var(--text-primary);
}

.compatibility-help-modal .modal-body {
    padding: 20px;
}

.compatibility-help-modal .modal-body ul {
    margin: 15px 0;
    padding-left: 20px;
}

.compatibility-help-modal .modal-body li {
    margin: 8px 0;
    color: var(--text-secondary);
}

.compatibility-help-modal .modal-actions {
    margin-top: 25px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.compatibility-help-modal .modal-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.try-anyway-btn {
    background: var(--warning-color);
    color: white;
}

.try-anyway-btn:hover {
    background: #D97706;
}

.close-modal-btn {
    background: var(--neutral-color);
    color: white;
}

.close-modal-btn:hover {
    background: #4B5563;
}

/* Animation pour les badges */
.compatibility-badge {
    animation: fadeInScale 0.3s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive pour la compatibilité */
@media (max-width: 768px) {
    .compatibility-badge {
        font-size: 0.7rem;
        padding: 3px 6px;
        min-width: 70px;
    }

    .compatibility-info {
        padding: 8px;
    }

    .compatibility-score {
        font-size: 0.8rem;
    }

    .compatibility-reason {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .compatibility-badge {
        position: relative;
        top: auto;
        right: auto;
        margin-bottom: 10px;
        display: inline-block;
    }

    .card-header {
        flex-direction: column;
        align-items: center;
    }

    .compatibility-help-modal .modal-content {
        margin: 20px;
        width: calc(100% - 40px);
    }

    .compatibility-help-modal .modal-actions {
        flex-direction: column;
    }
}