/* Interactive Hiking Maps - Styles CSS pour MapLibre GL JS */

/* Base styles */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f7fa; }

.ihm-track-container {
    max-width: 1200px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ihm-track-header {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.ihm-track-title {
    font-size: 28px;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 12px;
    line-height: 1.2;
}

.ihm-track-description {
    color: #718096;
    font-size: 16px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.ihm-track-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.ihm-stat {
    text-align: center;
    padding: 16px 12px;
    background: #f7fafc;
    border-radius: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ihm-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ihm-stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 4px;
}

.ihm-stat-label {
    display: block;
    font-size: 12px;
    color: #718096;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Conteneur de carte MapLibre */
.ihm-map-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    margin-bottom: 24px;
    position: relative;
}

/* Styles spécifiques MapLibre GL JS */
.maplibregl-map {
    border-radius: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.maplibregl-popup {
    max-width: 300px;
}

.maplibregl-popup-content {
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
    padding: 12px 16px;
}

.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
    border-bottom-color: #fff;
}

.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
    border-top-color: #fff;
}

.maplibregl-popup-anchor-left .maplibregl-popup-tip {
    border-right-color: #fff;
}

.maplibregl-popup-anchor-right .maplibregl-popup-tip {
    border-left-color: #fff;
}

/* Contrôles MapLibre personnalisés */
.maplibregl-ctrl-group {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.9);
}

.maplibregl-ctrl-group button {
    background: transparent;
    border: none;
    transition: all 0.2s ease;
}

.maplibregl-ctrl-group button:hover {
    background: rgba(0, 0, 0, 0.05);
}

.maplibregl-ctrl-group button:first-child {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.maplibregl-ctrl-group button:last-child {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* Attribution personnalisée */
.maplibregl-ctrl-attrib {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border-radius: 6px;
    font-size: 11px;
    padding: 4px 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Conteneur profil altimétrique */
.ihm-elevation-container {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    margin-bottom: 24px;
}

.ihm-elevation-container h4 {
    font-size: 20px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 16px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 8px;
    display: flex;
    align-items: center;
}

.ihm-elevation-container h4::before {
    content: "📊";
    margin-right: 8px;
}

#elevationChart { 
    max-height: 300px; 
}

/* Composition du tracé */
.ihm-composition-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.ihm-composition-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.ihm-section-title {
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 16px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 8px;
    display: flex;
    align-items: center;
}

.ihm-path-type, .ihm-surface-type {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f7fafc;
    transition: background-color 0.2s ease;
}

.ihm-path-type:hover, .ihm-surface-type:hover {
    background-color: #f7fafc;
    margin: 0 -12px;
    padding-left: 12px;
    padding-right: 12px;
    border-radius: 6px;
}

.ihm-path-type:last-child, .ihm-surface-type:last-child {
    border-bottom: none;
}

.ihm-type-info {
    display: flex;
    align-items: center;
}

.ihm-type-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    margin-right: 12px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ihm-type-name {
    font-weight: 500;
    color: #2d3748;
}

.ihm-type-stats {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ihm-type-distance {
    font-weight: 600;
    color: #2d3748;
}

.ihm-type-percent {
    color: #718096;
    font-size: 12px;
    background: #f7fafc;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

/* Grille des randonnées */
.ihm-tracks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.ihm-track-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.ihm-track-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.ihm-track-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #e74c3c, #f39c12, #27ae60);
}

.ihm-track-card h4 {
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 12px;
    line-height: 1.3;
}

.ihm-track-card p {
    color: #718096;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 16px;
}

.ihm-track-mini-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.ihm-track-mini-stats span {
    background: #f7fafc;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #2d3748;
    border: 1px solid #e2e8f0;
}

.ihm-view-track {
    display: inline-block;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(231, 76, 60, 0.3);
}

.ihm-view-track:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(231, 76, 60, 0.4);
}

/* Messages et notifications */
.ihm-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px 0;
    display: flex;
    align-items: center;
    font-weight: 500;
}

.ihm-message::before {
    margin-right: 8px;
    font-size: 16px;
}

.ihm-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.ihm-message.success::before {
    content: "✅";
}

.ihm-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.ihm-message.error::before {
    content: "❌";
}

.ihm-message.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.ihm-message.warning::before {
    content: "⚠️";
}

.ihm-message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #b8daff;
}

.ihm-message.info::before {
    content: "ℹ️";
}

/* Responsive Design */
@media (max-width: 768px) {
    .ihm-track-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .ihm-composition-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .ihm-tracks-grid {
        grid-template-columns: 1fr;
    }
    
    .ihm-track-header {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .ihm-track-title {
        font-size: 24px;
    }
    
    .ihm-elevation-container,
    .ihm-composition-section {
        padding: 16px;
    }
    
    .ihm-map-container {
        margin-bottom: 16px;
    }
    
    .ihm-track-mini-stats {
        flex-direction: column;
        gap: 8px;
    }
    
    .ihm-track-mini-stats span {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .ihm-track-container {
        padding: 0 10px;
    }
    
    .ihm-track-stats {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .ihm-stat {
        padding: 12px 8px;
    }
    
    .ihm-stat-value {
        font-size: 18px;
    }
    
    .ihm-track-card {
        padding: 16px;
    }
}

/* Contrôles MapLibre personnalisés pour mobile */
@media (max-width: 768px) {
    .maplibregl-ctrl-top-right {
        top: 10px;
        right: 10px;
    }
    
    .maplibregl-ctrl-group {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }
    
    .maplibregl-ctrl-group button {
        width: 32px;
        height: 32px;
    }
}

/* Animation de chargement */
.ihm-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: #718096;
    font-weight: 500;
}

.ihm-loading::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #e74c3c;
    border-radius: 50%;
    animation: ihm-spin 1s linear infinite;
    margin-left: 12px;
}

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

/* Styles pour l'administration */
.ihm-admin-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

.ihm-upload-section, .ihm-tracks-list {
    background: white;
    padding: 24px;
    border: 1px solid #ccd0d4;
    box-shadow: 0 1px 1px rgba(0,0,0,0.04);
    border-radius: 8px;
}

.ihm-upload-section h2, .ihm-tracks-list h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #23282d;
    display: flex;
    align-items: center;
}

.ihm-upload-section h2::before {
    content: "📁";
    margin-right: 8px;
}

.ihm-tracks-list h2::before {
    content: "🗂️";
    margin-right: 8px;
}

.ihm-gpx-preview {
    background: linear-gradient(135deg, #f0f8ff, #e6f3ff);
    padding: 16px;
    border-radius: 8px;
    margin: 15px 0;
    border: 1px solid #b8daff;
}

.ihm-preview-stats {
    display: flex;
    gap: 15px;
    margin: 10px 0;
    flex-wrap: wrap;
}

.ihm-preview-stats span {
    background: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #2d3748;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ihm-progress-bar {
    width: 100%;
    height: 24px;
    background: #f0f0f1;
    border-radius: 12px;
    overflow: hidden;
    margin-top: 10px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ihm-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00a32a, #46b450, #00a32a);
    background-size: 200% 100%;
    width: 0%;
    transition: width 0.3s ease;
    animation: ihm-progress-wave 2s infinite;
    border-radius: 12px;
}

@keyframes ihm-progress-wave {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.ihm-shortcode-info {
    margin-top: 30px;
    background: white;
    padding: 24px;
    border: 1px solid #ccd0d4;
    border-radius: 8px;
}

.ihm-shortcode-info h3 {
    margin-top: 0;
    color: #23282d;
    display: flex;
    align-items: center;
}

.ihm-shortcode-info h3::before {
    content: "💡";
    margin-right: 8px;
}

.ihm-shortcode-info code {
    background: #f6f7f7;
    padding: 8px 12px;
    font-family: 'Monaco', 'Menlo', monospace;
    border-radius: 4px;
    display: inline-block;
    margin: 4px 0;
    border: 1px solid #e1e5e9;
    color: #e74c3c;
    font-weight: 600;
}

.ihm-track-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
}

.ihm-track-item:hover {
    background-color: #f8f9fa;
    margin: 0 -12px;
    padding-left: 12px;
    padding-right: 12px;
    border-radius: 6px;
}

.ihm-track-item:last-child {
    border-bottom: none;
}

.ihm-track-shortcode {
    background: #f6f7f7;
    padding: 6px 12px;
    font-family: 'Monaco', 'Menlo', monospace;
    border-radius: 4px;
    font-size: 12px;
    color: #666;
    border: 1px solid #e1e5e9;
    user-select: all;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ihm-track-shortcode:hover {
    background: #e9ecef;
    border-color: #dee2e6;
}

/* Test MapLibre */
.ihm-maplibre-test {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
    border: 2px solid #dee2e6;
}

.ihm-maplibre-test h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #2d3748;
    display: flex;
    align-items: center;
}

#test-results {
    margin-top: 15px;
    padding: 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    font-size: 14px;
}

#test-results p {
    margin: 5px 0;
}

#test-results strong {
    color: #2d3748;
}

/* Tooltips personnalisés */
.ihm-tooltip {
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(4px);
}

.ihm-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* États de chargement spécifiques */
.ihm-map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    font-weight: 500;
    color: #718096;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(4px);
}

.ihm-map-loading::before {
    content: "🗺️";
    margin-right: 8px;
    font-size: 18px;
}

/* Améliorations visuelles pour les écrans haute résolution */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .ihm-track-container {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    .maplibregl-map {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* Mode sombre (si supporté par le thème) */
@media (prefers-color-scheme: dark) {
    .ihm-track-container {
        background: #1a202c;
        color: #e2e8f0;
    }
    
    .ihm-track-header,
    .ihm-elevation-container,
    .ihm-composition-section {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .ihm-track-title {
        color: #f7fafc;
    }
    
    .ihm-track-description {
        color: #a0aec0;
    }
    
    .ihm-stat {
        background: #4a5568;
        color: #e2e8f0;
    }
    
    .ihm-stat-value {
        color: #f7fafc;
    }
    
    .ihm-stat-label {
        color: #a0aec0;
    }
}