/* Reset et base */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary-color: #4a6fa5; 
    --secondary-color: #166088; 
    --accent-color: #ff6b6b;
    --dark-color: #2c3e50; 
    --light-color: #ecf0f1; 
    --success-color: #2ecc71;
    --warning-color: #f39c12; 
    --danger-color: #e74c3c; 
    --grid-color: rgba(0, 0, 0, 0.1);
    --shadow-light: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-medium: 0 5px 15px rgba(0,0,0,0.2);
    --shadow-heavy: 0 10px 30px rgba(0,0,0,0.3);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh; 
    color: var(--dark-color);
    line-height: 1.6;
    overflow-x: hidden;
}

.container { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 20px;
    width: 100%;
}

/* Header */
.main-header { 
    text-align: center; 
    color: white; 
    margin-bottom: 40px; 
    padding: 20px; 
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3); 
}
.main-header h1 { 
    font-size: clamp(2rem, 5vw, 3rem); 
    margin-bottom: 10px; 
    word-wrap: break-word;
}
.subtitle { 
    font-size: clamp(1rem, 2vw, 1.2rem); 
    opacity: 0.9; 
}

/* Cartes d'action */
.action-cards { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); 
    gap: 30px; 
    margin: 40px 0; 
}
.card { 
    background: white; 
    border-radius: 15px; 
    padding: clamp(20px, 3vw, 30px); 
    text-align: center; 
    box-shadow: var(--shadow-medium); 
    transition: transform 0.3s, box-shadow 0.3s; 
    height: 100%;
    display: flex;
    flex-direction: column;
}
.card:hover { 
    transform: translateY(-5px); 
    box-shadow: var(--shadow-heavy); 
}
.card-icon { 
    font-size: clamp(3rem, 8vw, 4rem); 
    color: var(--primary-color); 
    margin-bottom: 20px; 
}
.player-card .card-icon { color: var(--success-color); }
.mj-card .card-icon { color: var(--secondary-color); }
.card h3 { 
    margin-bottom: 15px; 
    color: var(--dark-color); 
    font-size: clamp(1.3rem, 3vw, 1.5rem);
}
.card p { 
    color: #666; 
    margin-bottom: 25px; 
    line-height: 1.6;
    flex-grow: 1;
}

/* Boutons */
.btn { 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    gap: 10px; 
    padding: 12px 24px; 
    border: none; 
    border-radius: 8px; 
    font-size: 1rem; 
    font-weight: 600; 
    cursor: pointer; 
    text-decoration: none; 
    transition: all 0.3s; 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--secondary-color); transform: translateY(-2px); }
.btn-secondary { background: var(--secondary-color); color: white; }
.btn-danger { background: var(--danger-color); color: white; }
.btn-success { background: var(--success-color); color: white; }
.btn-warning { background: var(--warning-color); color: white; }
.btn-block { display: block; width: 100%; }
.btn-outline { background: transparent; border: 2px solid var(--primary-color); color: var(--primary-color); }
.btn-outline:hover { background: var(--primary-color); color: white; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.875rem; line-height: 1.5; }

/* Formulaires */
.form-group { margin-bottom: 20px; }
.form-group label { 
    display: block; 
    margin-bottom: 8px; 
    font-weight: 600; 
    color: var(--dark-color); 
}
.form-group input, .form-group select, .form-group textarea { 
    width: 100%; 
    padding: 12px; 
    border: 2px solid #ddd; 
    border-radius: 8px; 
    font-size: 1rem; 
    transition: border-color 0.3s; 
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { 
    outline: none; 
    border-color: var(--primary-color); 
}
.form-row { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); 
    gap: 15px; 
    margin-bottom: 15px; 
}

/* Espace MJ */
.mj-header { 
    display: flex; 
    flex-wrap: wrap;
    justify-content: space-between; 
    align-items: center; 
    background: white; 
    padding: clamp(15px, 3vw, 20px); 
    border-radius: 10px; 
    margin-bottom: 20px; 
    box-shadow: var(--shadow-light); 
    gap: 15px;
}
.mj-nav { 
    display: flex; 
    flex-wrap: wrap;
    gap: 10px; 
    margin-bottom: 30px; 
    background: white; 
    padding: 15px; 
    border-radius: 10px; 
    box-shadow: var(--shadow-light); 
}
.nav-item { 
    padding: 10px 20px; 
    text-decoration: none; 
    color: var(--dark-color); 
    border-radius: 5px; 
    transition: all 0.3s; 
    flex: 1;
    min-width: 150px;
    text-align: center;
}
.nav-item:hover, .nav-item.active { background: var(--primary-color); color: white; }

/* Dashboard MJ */
.dashboard-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(min(350px, 100%), 1fr)); 
    gap: 20px; 
}
.dashboard-card { 
    background: white; 
    padding: clamp(15px, 3vw, 20px); 
    border-radius: 10px; 
    box-shadow: var(--shadow-light); 
}
.game-item { 
    display: flex; 
    flex-wrap: wrap;
    justify-content: space-between; 
    align-items: center; 
    padding: 15px; 
    border: 1px solid #eee; 
    border-radius: 8px; 
    margin-bottom: 10px; 
    transition: all 0.3s; 
    gap: 10px;
}
.game-item:hover { border-color: var(--primary-color); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1); }
.game-actions { 
    display: flex; 
    gap: 5px; 
    flex-wrap: wrap;
    align-items: center; 
}
.game-actions .btn { 
    padding: 5px 8px; 
    font-size: 12px; 
    white-space: nowrap; 
}

/* ✅ CORRECTION: Images de personnages uniformes */
.character-card .character-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    border-radius: 10px 10px 0 0;
}

.character-card .character-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.character-card:hover .character-image img {
    transform: scale(1.05);
}

/* Interface jeu - Responsive */
.game-container { 
    display: flex; 
    flex-direction: column;
    height: 100vh; 
    width: 100vw; 
}

@media (min-width: 1024px) {
    .game-container {
        flex-direction: row;
    }
}

.map-section { 
    flex: 1; 
    position: relative; 
    background: #1a1a1a; 
    overflow: auto;
    min-height: 300px;
}
.map-display { 
    position: relative; 
    width: 100%; 
    height: 100%; 
}
.map-image-container { 
    position: relative; 
    width: 100%; 
    height: 100%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}
#battlemapImage { 
    max-width: 100%; 
    max-height: 100%; 
    object-fit: contain; 
}

/* Grille et personnages */
.grid-overlay { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    pointer-events: none; 
}
.grid-cell { 
    position: absolute; 
    border: 1px solid rgba(255, 255, 255, 0.2); 
    box-sizing: border-box; 
    background: transparent; 
}
.movement-cell { 
    position: absolute; 
    border: 2px solid #2ecc71; 
    background: rgba(46, 204, 113, 0.3); 
    box-sizing: border-box; 
    cursor: pointer; 
    pointer-events: auto; 
    z-index: 5; 
}
.movement-cell:hover { background: rgba(46, 204, 113, 0.5); }

.characters-container { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    pointer-events: none; 
}
.character-on-map { 
    position: absolute; 
    z-index: 10; 
    border: 2px solid white; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.4); 
    transform: translate(-50%, -50%); 
    cursor: pointer; 
    pointer-events: auto; 
    border-radius: 50%; 
    overflow: hidden; 
    transition: transform 0.2s; 
}
.character-on-map.pj { border-color: #2ecc71; }
.character-on-map.pnj { border-color: #e74c3c; }
.character-on-map.selected { 
    border-color: #f39c12; 
    border-width: 3px; 
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.4); 
    transform: translate(-50%, -50%) scale(1.1); 
    z-index: 20; 
}
.character-on-map img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
}
.character-on-map .character-initial { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    width: 100%; 
    height: 100%; 
    color: white; 
    font-weight: bold; 
    font-size: clamp(12px, 2vw, 14px); 
}

/* Badges */
.badge { 
    display: inline-block; 
    padding: 4px 8px; 
    border-radius: 4px; 
    font-size: 0.8rem; 
    font-weight: bold; 
}
.badge-pj { background: var(--success-color); color: white; }
.badge-pnj { background: var(--primary-color); color: white; }
.status-badge { 
    padding: 4px 8px; 
    border-radius: 4px; 
    font-size: 0.8rem; 
    font-weight: bold; 
}
.status-badge.active { background: var(--success-color); color: white; }
.status-badge.inactive { background: #ddd; color: #666; }

/* Authentification */
.auth-main { 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    min-height: 70vh; 
    padding: 20px;
}
.auth-container { 
    background: white; 
    border-radius: 15px; 
    padding: clamp(20px, 4vw, 30px); 
    width: 100%; 
    max-width: 500px; 
    box-shadow: var(--shadow-heavy); 
}
.auth-tabs { 
    display: flex; 
    margin-bottom: 30px; 
    border-bottom: 2px solid #eee; 
    overflow-x: auto;
}
.auth-tab { 
    flex: 1; 
    padding: 15px; 
    border: none; 
    background: none; 
    font-size: 1.1rem; 
    font-weight: 600; 
    color: #666; 
    cursor: pointer; 
    transition: all 0.3s; 
    position: relative; 
    min-width: 120px;
}
.auth-tab.active { color: var(--primary-color); }
.auth-tab.active::after { 
    content: ''; 
    position: absolute; 
    bottom: -2px; 
    left: 0; 
    right: 0; 
    height: 3px; 
    background: var(--primary-color); 
}
.auth-form { display: none; }
.auth-form.active { display: block; }

/* Modal */
.modal { 
    position: fixed; 
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0; 
    background: rgba(0, 0, 0, 0.5); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    z-index: 1000; 
    padding: 20px;
}
.modal-content { 
    background: white; 
    border-radius: 10px; 
    padding: clamp(20px, 4vw, 30px); 
    width: 100%; 
    max-width: 500px; 
    max-height: 90vh; 
    overflow-y: auto; 
}
.modal-actions { 
    display: flex; 
    justify-content: flex-end; 
    gap: 10px; 
    margin-top: 20px; 
    flex-wrap: wrap;
}

/* Loading */
.loading-overlay { 
    position: fixed; 
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0; 
    background: rgba(0, 0, 0, 0.8); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    z-index: 1000; 
}
.loading-content { 
    text-align: center; 
    color: white; 
    padding: 20px;
}

/* Toast notifications */
.toast { 
    position: fixed; 
    bottom: 20px; 
    right: 20px; 
    padding: 15px 25px; 
    background: white; 
    border-radius: 8px; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.2); 
    transform: translateX(150%); 
    transition: transform 0.3s; 
    z-index: 1000; 
    max-width: min(400px, 90vw);
    word-wrap: break-word;
}
.toast.show { transform: translateX(0); }
.toast.success { border-left: 4px solid var(--success-color); }
.toast.error { border-left: 4px solid var(--danger-color); }
.toast.info { border-left: 4px solid var(--primary-color); }

/* Responsive */
@media (max-width: 768px) {
    .container { padding: 10px; }
    .mj-header { flex-direction: column; text-align: center; }
    .mj-nav { flex-direction: column; }
    .nav-item { min-width: 100%; }
    .game-item { flex-direction: column; align-items: stretch; }
    .game-actions { justify-content: center; }
    .form-row { grid-template-columns: 1fr; }
    .modal-content { 
        padding: 15px; 
        margin: 10px; 
        max-height: 80vh;
    }
    .toast {
        bottom: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .action-cards { gap: 15px; }
    .card { padding: 15px; }
    .btn { padding: 10px 15px; font-size: 0.9rem; }
    .modal-actions { flex-direction: column; }
    .modal-actions .btn { width: 100%; }
}

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

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

.pulse {
    animation: pulse 2s infinite;
}

/* Accessibilité */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible pour accessibilité */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Scrollbar personnalisée */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}