/* =============================================================================
   ROADBOOK - Styles CSS (Mobile-First PWA)
   ============================================================================= */

:root {
    /* Couleurs MCPL - Vert */
    --primary: #487854;
    --primary-dark: #3a6344;
    --primary-light: #5a9468;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
    --dark: #1f2937;
    --gray: #6b7280;
    --light: #f5f6f7;
    --white: #ffffff;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    --radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--light);
    color: var(--dark);
    min-height: 100vh;
    line-height: 1.5;
}

/* Container */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 1rem;
}

.container-wide {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* =============================================================================
   Page de Connexion (Login)
   ============================================================================= */

.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 2rem 1rem;
}

.login-logo {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.login-title {
    color: var(--white);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    text-align: center;
}

.login-box {
    background: var(--white);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.login-box h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--dark);
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--light);
    border-radius: var(--radius);
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-warning {
    background: var(--warning);
    color: var(--dark);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-info {
    background: var(--info);
    color: var(--white);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-icon {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-weight: 500;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* Admin link on login page */
.admin-link {
    margin-top: 1.5rem;
    text-align: center;
}

.admin-link a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 0.875rem;
}

.admin-link a:hover {
    color: var(--white);
    text-decoration: underline;
}

/* =============================================================================
   App Header
   ============================================================================= */

.app-header {
    background: var(--white);
    padding: 1rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 480px;
    margin: 0 auto;
}

.app-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.player-points {
    background: var(--success);
    color: var(--white);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.875rem;
}

.player-timer {
    background: var(--primary);
    color: var(--white);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.875rem;
    font-family: monospace;
}

/* =============================================================================
   Roadbook Stages
   ============================================================================= */

.stage-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    overflow: hidden;
}

.stage-header {
    background: var(--primary);
    color: var(--white);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stage-number {
    background: rgba(255,255,255,0.2);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
}

.stage-status {
    font-size: 0.875rem;
}

.stage-body {
    padding: 1rem;
}

/* Phase tabs */
.phase-tabs {
    display: flex;
    border-bottom: 2px solid var(--light);
    margin-bottom: 1rem;
}

.phase-tab {
    flex: 1;
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
    color: var(--gray);
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.phase-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.phase-content {
    display: none;
}

.phase-content.active {
    display: block;
}

/* Directions */
.directions-box {
    background: var(--light);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.directions-box h4 {
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gps-button {
    margin-top: 1rem;
}

/* Photo */
.stage-photo {
    width: 100%;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.photo-description {
    color: var(--gray);
    font-style: italic;
    text-align: center;
}

/* Questions */
.question-item {
    background: var(--light);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.question-points {
    background: var(--warning);
    color: var(--dark);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.question-text {
    font-weight: 500;
    margin-bottom: 1rem;
}

.question-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: var(--radius);
    font-size: 1rem;
}

.question-status {
    margin-top: 0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    text-align: center;
}

.question-status.pending { background: #fef3c7; color: #92400e; }
.question-status.correct { background: #dcfce7; color: #166534; }
.question-status.incorrect { background: #fee2e2; color: #991b1b; }

/* Camera capture */
.camera-capture {
    text-align: center;
}

.camera-preview {
    width: 100%;
    max-width: 300px;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

/* =============================================================================
   Admin Styles
   ============================================================================= */

.admin-header {
    background: var(--primary);
    color: var(--white);
    padding: 1rem;
    position: relative;
}

.admin-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.admin-header .app-logo {
    color: var(--white);
}

/* Bouton hamburger pour mobile */
.menu-toggle {
    display: none;
    background: rgba(255,255,255,0.1);
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
}

.menu-toggle:hover {
    background: rgba(255,255,255,0.2);
}

.admin-nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.admin-nav a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    transition: all 0.2s;
    font-size: 0.9rem;
}

.admin-nav a:hover,
.admin-nav a.active {
    background: rgba(255,255,255,0.1);
    color: var(--white);
}

/* Navigation dropdown */
.nav-dropdown {
    position: relative;
    display: flex;
    align-items: center;
}

.nav-dropdown-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    transition: all 0.2s;
    font-size: 0.9rem;
}

.nav-dropdown-toggle:hover,
.nav-dropdown.active .nav-dropdown-toggle {
    background: rgba(255,255,255,0.1);
    color: var(--white);
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 150px;
    z-index: 1000;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
}

.nav-dropdown.open .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-menu a {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--dark) !important;
    background: transparent !important;
    border-radius: 0;
}

.nav-dropdown-menu a:hover {
    background: var(--light) !important;
}

.nav-dropdown-menu a.active {
    color: var(--primary) !important;
    font-weight: 600;
}

/* Admin cards */
.admin-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.admin-card h3 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--light);
}

/* Player list in admin */
.player-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--light);
}

.player-row:last-child {
    border-bottom: none;
}

.player-details h4 {
    margin-bottom: 0.25rem;
}

.player-details span {
    color: var(--gray);
    font-size: 0.875rem;
}

.player-stats {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.timer-controls {
    display: flex;
    gap: 0.5rem;
}

/* Answer validation */
.answer-item {
    background: var(--light);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.answer-player {
    font-weight: 600;
    color: var(--primary);
}

.answer-question {
    color: var(--gray);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.answer-text {
    background: var(--white);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.answer-photo {
    max-width: 200px;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.validation-buttons {
    display: flex;
    gap: 0.5rem;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--gray);
    font-size: 0.875rem;
}

/* Table */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--light);
}

.table th {
    background: var(--light);
    font-weight: 600;
}

/* Data table - variante */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--light);
}

.data-table th {
    background: var(--light);
    font-weight: 600;
}

.data-table tr:hover {
    background: rgba(72, 120, 84, 0.05);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
}

.badge-success { background: var(--success); color: white; }
.badge-warning { background: var(--warning); color: var(--dark); }
.badge-danger { background: var(--danger); color: white; }
.badge-info { background: var(--info); color: white; }
.badge-primary { background: var(--primary); color: white; }

/* =============================================================================
   Focus states - Style MCPL
   ============================================================================= */

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(72, 120, 84, 0.1);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(72, 120, 84, 0.1);
}

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }

    .admin-header-inner {
        flex-wrap: wrap;
    }

    .admin-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 0.25rem;
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid rgba(255,255,255,0.2);
    }

    .admin-nav.open {
        display: flex;
    }

    .admin-nav a {
        padding: 0.75rem 1rem;
        text-align: center;
        background: rgba(255,255,255,0.05);
    }

    /* Dropdown mobile */
    .nav-dropdown {
        width: 100%;
    }

    .nav-dropdown-toggle {
        width: 100%;
        text-align: center;
    }

    .nav-dropdown-menu {
        position: static;
        box-shadow: none;
        background: rgba(255,255,255,0.1);
        margin-top: 0;
        padding: 0;
    }

    .nav-dropdown-menu a {
        color: rgba(255,255,255,0.8) !important;
        padding: 0.75rem 1rem;
        padding-left: 2rem;
    }

    .nav-dropdown-menu a:hover {
        background: rgba(255,255,255,0.1) !important;
        color: white !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .table-responsive {
        overflow-x: auto;
    }
}

/* Header joueur responsive - mode portrait mobile */
@media (max-width: 480px) {
    .app-header-inner {
        flex-direction: column;
        gap: 0.5rem;
    }

    .app-logo {
        font-size: 1.1rem;
    }

    .player-info {
        width: 100%;
        justify-content: center;
        gap: 0.4rem;
    }

    .player-points,
    .player-timer {
        padding: 0.2rem 0.5rem;
        font-size: 0.8rem;
    }

    .player-info .btn-sm {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }
}

/* PWA styles */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* =============================================================================
   Lightbox pour les photos (zoom, telecharger)
   ============================================================================= */

.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.lightbox-overlay.active {
    display: flex;
}

.lightbox-container {
    position: relative;
    max-width: 95vw;
    max-height: 85vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.lightbox-image {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    transition: transform 0.3s ease;
    cursor: grab;
    touch-action: none;
}

.lightbox-image.zoomed {
    cursor: grabbing;
    max-width: none;
    max-height: none;
}

.lightbox-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.4);
}

.lightbox-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10001;
}

.lightbox-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

.lightbox-btn:active {
    background: rgba(255, 255, 255, 0.5);
}

.lightbox-caption {
    color: white;
    text-align: center;
    padding: 15px;
    font-size: 0.95rem;
    max-width: 90%;
}

/* Photo cliquable */
.stage-photo-clickable {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stage-photo-clickable:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.stage-photo-clickable:active {
    transform: scale(0.98);
}

.photo-hint {
    text-align: center;
    color: #666;
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

/* =============================================================================
   Google Maps Embed (iframe responsive)
   ============================================================================= */

.map-embed iframe {
    width: 100%;
    height: 300px;
    border: 0;
    display: block;
}

@media (min-width: 768px) {
    .map-embed iframe {
        height: 400px;
    }
}
