/* ==========================================================================
   Hovr — Styles
   ========================================================================== */

/* Variables */
:root {
    --color-primary: #007AFF;
    --color-background: #F2F2F7;
    --color-text: #1C1C1E;
    --color-text-secondary: #8E8E93;
    --color-white: #FFFFFF;
    --color-shadow: rgba(0, 0, 0, 0.15);

    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 8px var(--color-shadow);
    --shadow-md: 0 4px 16px var(--color-shadow);
    --shadow-lg: 0 8px 32px var(--color-shadow);

    --transition: 0.2s ease;
}

/* Reset */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: var(--font-family);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Map
   ========================================================================== */

#map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
}

/* ==========================================================================
   Header
   ========================================================================== */

#header {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
    background: var(--color-white);
    padding: 8px 16px;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    width: 28px;
    height: 28px;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
}

/* ==========================================================================
   Filters
   ========================================================================== */

#filters {
    position: fixed;
    top: 16px;
    right: 16px;
    left: auto;
    z-index: 100;
    max-width: calc(100% - 160px);
}

#filters-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--color-white);
    border: 2px solid transparent;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
    transition: var(--transition);
    user-select: none;
}

.filter-chip:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.filter-chip.active {
    border-color: currentColor;
}

.filter-chip.inactive {
    opacity: 0.5;
}

.filter-chip-icon {
    font-size: 16px;
    line-height: 1;
}

.filter-chip-label {
    white-space: nowrap;
}

/* Responsive filters */
@media (max-width: 768px) {
    #filters {
        top: auto;
        bottom: 16px;
        left: 16px;
        right: 16px;
        max-width: none;
    }

    #filters-container {
        justify-content: center;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-bottom: 4px;
    }

    #filters-container::-webkit-scrollbar {
        display: none;
    }

    .filter-chip {
        flex-shrink: 0;
    }
}

/* ==========================================================================
   Hovr Detail Panel - Phylactère BD
   ========================================================================== */

#hovr-detail {
    position: fixed;
    bottom: 55%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    background: var(--color-white);
    border-radius: 20px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
    padding: 20px;
    max-width: 380px;
    width: calc(100% - 32px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: bubblePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 60vh;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#hovr-detail::-webkit-scrollbar {
    display: none;
}

/* Queue du phylactère (triangle) */
#hovr-detail::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 15px solid var(--color-white);
    filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.1));
}

@keyframes bubblePop {
    0% {
        opacity: 0;
        transform: translateX(-50%) scale(0.5) translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) scale(1) translateY(0);
    }
}

#hovr-detail.hidden {
    display: none;
}

#hovr-detail-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border: none;
    background: var(--color-background);
    border-radius: var(--radius-full);
    font-size: 18px;
    line-height: 1;
    color: var(--color-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-weight: bold;
}

#hovr-detail-close:hover {
    background: #E5E5EA;
    color: var(--color-text);
    transform: scale(1.1);
}

.hovr-detail-category {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hovr-detail-category-icon {
    font-size: 16px;
}

.hovr-detail-content {
    font-size: 18px;
    line-height: 1.5;
    color: var(--color-text);
    margin-bottom: 16px;
    word-wrap: break-word;
    font-weight: 500;
}

.hovr-detail-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--color-text-secondary);
    padding-top: 12px;
    border-top: 2px dashed #E5E5EA;
}

.hovr-detail-author {
    font-weight: 600;
    color: var(--color-primary);
}

/* ==========================================================================
   Reactions Section
   ========================================================================== */

.hovr-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 2px dashed #E5E5EA;
}

.hovr-reactions-title {
    width: 100%;
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.reaction-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--color-background);
    border-radius: var(--radius-full);
    font-size: 14px;
    border: 2px solid #E5E5EA;
    transition: var(--transition);
}

.reaction-badge:hover {
    transform: scale(1.1);
    border-color: var(--color-primary);
}

.reaction-emoji {
    font-size: 18px;
}

.reaction-count {
    font-weight: 700;
    color: var(--color-text);
}

.no-reactions {
    font-size: 13px;
    color: var(--color-text-secondary);
    font-style: italic;
}

/* ==========================================================================
   Comments Section
   ========================================================================== */

.hovr-comments {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 2px dashed #E5E5EA;
}

.hovr-comments-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.comments-count {
    background: var(--color-primary);
    color: white;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.comments-list::-webkit-scrollbar {
    display: none;
}

.comment-item {
    background: var(--color-background);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    border-left: 4px solid var(--color-primary);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.comment-author {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-primary);
}

.comment-date {
    font-size: 11px;
    color: var(--color-text-secondary);
}

.comment-content {
    font-size: 14px;
    line-height: 1.4;
    color: var(--color-text);
}

.no-comments {
    font-size: 13px;
    color: var(--color-text-secondary);
    font-style: italic;
    text-align: center;
    padding: 12px;
}

/* Responsive detail panel */
@media (max-width: 768px) {
    #hovr-detail {
        bottom: 50%;
        left: 16px;
        right: 16px;
        transform: none;
        width: auto;
        max-height: 50vh;
        overflow-y: auto;
    }

    #hovr-detail::after {
        left: 50%;
        transform: translateX(-50%);
    }

    @keyframes bubblePop {
        0% {
            opacity: 0;
            transform: scale(0.5) translateY(20px);
        }
        100% {
            opacity: 1;
            transform: scale(1) translateY(0);
        }
    }
}

/* ==========================================================================
   Mapbox Markers
   ========================================================================== */

/* Forcer les marqueurs Mapbox à être cliquables */
.mapboxgl-marker {
    cursor: pointer !important;
    pointer-events: auto !important;
}

.hovr-marker {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    font-size: 18px;
    border: 3px solid var(--color-white);
    z-index: 10;
    pointer-events: auto !important;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.hovr-marker:hover {
    transform: scale(1.15);
    box-shadow: var(--shadow-lg);
}

.hovr-marker.selected {
    transform: scale(1.2);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.3), var(--shadow-lg);
}

/* Cluster marker */
.hovr-marker.cluster-marker {
    width: 44px;
    height: 44px;
    position: relative;
}

.hovr-marker.cluster-marker .cluster-count {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--color-white);
    color: inherit;
    font-size: 14px;
    font-weight: 700;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================================================
   Cluster Detail List
   ========================================================================== */

.cluster-header {
    margin-bottom: 16px;
}

.cluster-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
}

.cluster-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.cluster-list::-webkit-scrollbar {
    display: none;
}

.cluster-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--color-background);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.cluster-item:hover {
    background: #E5E5EA;
}

.cluster-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.cluster-item-content {
    flex: 1;
    min-width: 0;
}

.cluster-item-category {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.cluster-item-text {
    font-size: 14px;
    line-height: 1.4;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.cluster-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 4px;
}

.cluster-item-chevron {
    font-size: 20px;
    color: var(--color-text-secondary);
    flex-shrink: 0;
}

/* ==========================================================================
   Loader
   ========================================================================== */

#loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#loader.hidden {
    display: none;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-background);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Mapbox Popup Override (optionnel)
   ========================================================================== */

.mapboxgl-popup-content {
    padding: 0;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.mapboxgl-popup-close-button {
    font-size: 20px;
    padding: 8px;
    color: var(--color-text-secondary);
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
