/**
 * Balizas DGT - Estilos principales
 * 
 * Diseño: Dark theme con acentos de colores de severidad
 * Tipografía: Outfit (UI) + JetBrains Mono (datos técnicos)
 */

/* ============================================
   CSS Variables
   ============================================ */
:root {
    /* Colores base */
    --bg-primary: #0f0f14;
    --bg-secondary: #16161d;
    --bg-tertiary: #1e1e28;
    --bg-elevated: #252532;
    
    /* Texto */
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;
    
    /* Acentos */
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-glow: rgba(99, 102, 241, 0.3);
    
    /* Severidad */
    --severity-highest: #dc2626;
    --severity-high: #f97316;
    --severity-medium: #eab308;
    --severity-low: #22c55e;
    --severity-unknown: #6b7280;
    
    /* Bordes */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    
    /* Sombras */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    
    /* Transiciones */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    
    /* Dimensiones */
    --header-height: 60px;
    --footer-height: 36px;
    
    /* Tipografía */
    --font-ui: 'Outfit', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    /* Prevenir overscroll en móvil */
    overscroll-behavior: none;
}

body {
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Prevenir selección accidental en móvil */
    -webkit-tap-highlight-color: transparent;
    /* Asegurar que ocupa toda la pantalla */
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

/* ============================================
   Header
   ============================================ */
.app-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: relative;
    z-index: 1000;
}

.header-content {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.logo-icon {
    font-size: 24px;
    filter: drop-shadow(0 0 8px rgba(234, 179, 8, 0.5));
}

.logo h1 {
    font-size: 20px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    padding-left: 16px;
    border-left: 1px solid var(--border-color);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    font-size: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--severity-medium);
    animation: pulse 2s infinite;
}

.status-indicator.connected .status-dot {
    background: var(--severity-low);
}

.status-indicator.error .status-dot {
    background: var(--severity-highest);
    animation: none;
}

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

.last-update {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.last-update .label {
    color: var(--text-muted);
}

.last-update .time {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============================================
   Map Style Button
   ============================================ */
.btn-map-style {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-ui);
    font-size: 13px;
    /* Mejor soporte táctil en móvil */
    -webkit-tap-highlight-color: rgba(99, 102, 241, 0.3);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    min-height: 44px;
    min-width: 44px;
}

.btn-map-style:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.btn-map-style:active,
.btn-map-style.touching {
    transform: scale(0.97);
    background: var(--accent-primary);
    color: white;
}

.btn-map-style .map-style-label {
    font-weight: 500;
}

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

/* ============================================
   Main Layout
   ============================================ */
.app-main {
    display: flex;
    flex-direction: column;
    height: calc(var(--app-height, 100vh) - var(--header-height) - var(--footer-height));
    position: relative;
}

/* Loading & Empty States */
.loading-state,
.empty-state,
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--bg-elevated);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

/* ============================================
   Floating Buttons (above FAQ)
   ============================================ */
.floating-buttons {
    position: fixed;
    bottom: 80px;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 1000;
    pointer-events: none;
    flex-wrap: wrap;
    padding: 0 12px;
}

.btn-floating {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
    transition: all var(--transition-fast);
    pointer-events: auto;
    white-space: nowrap;
}

.btn-floating:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(99, 102, 241, 0.3);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.btn-floating:active {
    transform: translateY(0) scale(0.97);
}

.btn-floating.active {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-color: transparent;
    color: white;
    box-shadow: 0 3px 16px rgba(99, 102, 241, 0.4);
}

.btn-floating.active:hover {
    box-shadow: 0 5px 24px rgba(99, 102, 241, 0.5);
}

.btn-floating svg {
    flex-shrink: 0;
}

.btn-floating-icon {
    font-size: 14px;
    line-height: 1;
}

.btn-floating-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.btn-floating-count {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.2);
    padding: 1px 6px;
    border-radius: 8px;
    min-width: 20px;
    text-align: center;
}

.btn-floating:not(.active) .btn-floating-count {
    background: rgba(255, 255, 255, 0.08);
}

#btnCenterSpain.btn-floating {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-color: transparent;
    color: white;
    box-shadow: 0 3px 16px rgba(99, 102, 241, 0.4);
}

#btnCenterSpain.btn-floating:hover {
    box-shadow: 0 5px 24px rgba(99, 102, 241, 0.5);
}

@keyframes subtle-pulse-btn {
    0%, 100% { box-shadow: 0 3px 16px rgba(99, 102, 241, 0.4); }
    50% { box-shadow: 0 3px 20px rgba(99, 102, 241, 0.6); }
}

#btnCenterSpain.pulse {
    animation: subtle-pulse-btn 2s ease-in-out infinite;
}

/* ============================================
   Map Container
   ============================================ */
.map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
}

/* Leaflet custom styles */
.leaflet-container {
    font-family: var(--font-ui);
}

.leaflet-popup-content-wrapper {
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.leaflet-popup-content {
    margin: 0;
    color: var(--text-primary);
}

.leaflet-popup-tip {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-left: none;
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow-md) !important;
}

.leaflet-control-zoom a {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-elevated) !important;
}

.leaflet-control-attribution {
    background: rgba(15, 15, 20, 0.8) !important;
    color: var(--text-muted) !important;
    font-size: 10px;
}

.leaflet-control-attribution a {
    color: var(--text-secondary) !important;
}

/* Custom marker cluster */
.marker-cluster {
    background: rgba(99, 102, 241, 0.4);
    border: 2px solid var(--accent-primary);
}

.marker-cluster div {
    background: var(--accent-primary);
    color: white;
    font-weight: 600;
    font-family: var(--font-mono);
}

.marker-cluster-small {
    background: rgba(34, 197, 94, 0.4);
    border-color: var(--severity-low);
}
.marker-cluster-small div { background: var(--severity-low); }

.marker-cluster-medium {
    background: rgba(234, 179, 8, 0.4);
    border-color: var(--severity-medium);
}
.marker-cluster-medium div { background: var(--severity-medium); }

.marker-cluster-large {
    background: rgba(249, 115, 22, 0.4);
    border-color: var(--severity-high);
}
.marker-cluster-large div { background: var(--severity-high); }

/* Map Controls */
.map-controls {
    position: absolute;
    bottom: 30px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.map-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
}

.map-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.map-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 15, 20, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.map-loading.visible {
    opacity: 1;
    pointer-events: all;
}

/* ============================================
   Legend
   ============================================ */
.legend {
    position: fixed;
    bottom: 30px;
    left: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
}

.legend-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.legend-items {
    display: flex;
    gap: 16px;
}

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

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* ============================================
   Popup Content
   ============================================ */
.popup-content {
    padding: 16px;
    min-width: 280px;
}

.popup-header {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.popup-road {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.popup-type {
    display: inline-block;
    font-size: 11px;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.popup-details {
    margin-bottom: 12px;
}

.popup-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
}

.popup-row:last-child {
    border-bottom: none;
}

.popup-label {
    font-size: 12px;
    color: var(--text-muted);
}

.popup-value {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
}

.popup-severity {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.popup-severity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.popup-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.popup-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.popup-btn-google {
    background: linear-gradient(135deg, #4ade80, #22c55e);
    color: #0a2010;
    font-weight: 600;
}

.popup-btn-google:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.5);
}

.popup-btn-waze {
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
    color: #0c1829;
    font-weight: 600;
}

.popup-btn-waze:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.5);
}

/* Botón compartir */
.popup-btn-share {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    margin-top: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    border-radius: 10px;
    color: white;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.popup-btn-share:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
    background: linear-gradient(135deg, #818cf8, #a78bfa);
}

.popup-btn-share:active {
    transform: translateY(0);
}

.popup-btn-share svg {
    flex-shrink: 0;
}

/* Toast notification */
.toast-notification {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 14px 24px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 600;
    border-radius: 50px;
    box-shadow: 0 8px 30px rgba(34, 197, 94, 0.4);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast-notification.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Marcador ubicación compartida */
.shared-marker svg {
    filter: drop-shadow(0 0 10px rgba(255, 107, 53, 0.8));
    animation: pulse-shared 2s ease-in-out infinite;
}

@keyframes pulse-shared {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Popup ubicación compartida */
.popup-type-shared {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
    color: white !important;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 20px;
}

.popup-coords {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent-v16);
    background: rgba(255, 107, 53, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
}

.shared-popup .popup-header {
    border-bottom: 2px solid var(--accent-v16);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
    .subtitle {
        display: none;
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: 56px;
        --footer-height: 50px;
    }
    
    .app-main {
        height: calc(var(--app-height, 100vh) - var(--header-height) - var(--footer-height));
        overflow: hidden;
    }
    
    .map-container {
        flex: 1;
        width: 100%;
        height: 100% !important;
        position: relative;
    }
    
    #map {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        height: 100% !important;
    }
    
    .legend {
        left: 10px;
        bottom: 10px;
        padding: 8px 12px;
        font-size: 11px;
    }
    
    .legend-items {
        gap: 10px;
    }
    
    .map-controls {
        bottom: 10px;
        right: 10px;
    }
    
    .header-content {
        padding: 0 12px;
    }
    
    .header-right {
        gap: 8px;
    }
    
    .last-update {
        display: none;
    }
    
    .status-indicator {
        padding: 4px 10px;
        font-size: 11px;
    }
    
    .btn-map-style {
        padding: 8px 12px;
        min-height: 44px;
        min-width: 44px;
    }
    
    .btn-map-style .map-style-label {
        display: none;
    }

    .floating-buttons {
        bottom: 96px;
        gap: 6px;
        padding: 0 8px;
    }
    
    .btn-floating {
        padding: 7px 10px;
        gap: 4px;
    }
    
    .btn-floating-icon {
        font-size: 13px;
    }
    
    .btn-floating-label {
        font-size: 10px;
    }
    
    .btn-floating-count {
        font-size: 9px;
        padding: 1px 5px;
        min-width: 18px;
    }
}

@media (max-width: 480px) {
    :root {
        --header-height: 50px;
        --footer-height: 56px;
    }
    
    .header-left {
        gap: 6px;
    }
    
    .logo-icon {
        font-size: 20px;
    }
    
    .logo h1 {
        font-size: 14px;
    }
    
    .btn-map-style {
        padding: 8px 12px;
        font-size: 12px;
        min-height: 40px;
        min-width: 40px;
    }
    
    .btn-map-style .map-style-label {
        display: none;
    }
    
    .btn-map-style svg {
        width: 20px;
        height: 20px;
    }
    
    .legend {
        left: 8px;
        bottom: 8px;
        padding: 6px 10px;
    }
    
    .legend-title {
        font-size: 9px;
        margin-bottom: 4px;
    }
    
    .legend-items {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .legend-item {
        font-size: 10px;
    }
    
    .legend-color {
        width: 10px;
        height: 10px;
    }
    
    .map-controls {
        right: 8px;
        bottom: 8px;
    }
    
    .map-btn {
        width: 36px;
        height: 36px;
    }
    
    .popup-content {
        min-width: 240px;
        padding: 12px;
    }
    
    .popup-road {
        font-size: 15px;
    }
    
    .popup-actions {
        flex-direction: column;
    }
    
    .popup-btn {
        padding: 12px;
    }

    .floating-buttons {
        bottom: 100px;
        gap: 5px;
        padding: 0 6px;
    }
    
    .btn-floating {
        padding: 6px 8px;
        gap: 3px;
    }
    
    .btn-floating-icon {
        font-size: 12px;
    }
    
    .btn-floating-label {
        font-size: 9px;
    }
    
    .btn-floating-count {
        display: none;
    }
    
    .btn-floating svg {
        width: 14px;
        height: 14px;
    }
}

/* ============================================
   Footer
   ============================================ */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 36px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    padding: 0 20px;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1400px;
    gap: 20px;
}

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

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    transition: color var(--transition-fast);
}

.footer-links a:hover {
    color: var(--accent-primary);
}

.footer-divider {
    color: var(--text-muted);
    font-size: 10px;
}

.footer-credits {
    font-size: 11px;
    color: var(--text-muted);
}

.footer-credits a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-credits a:hover {
    color: var(--accent-primary);
}

/* Ajustar elementos para dejar espacio al footer en desktop */
@media (min-width: 769px) {
    .legend {
        bottom: 50px;
    }
    
    .map-controls {
        bottom: 50px;
    }
}

/* Footer responsive - móvil */
@media (max-width: 768px) {
    .app-footer {
        height: auto;
        min-height: var(--footer-height);
        padding: 8px 12px;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 4px;
        text-align: center;
    }
    
    .footer-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
    }
    
    .footer-links a {
        font-size: 11px;
    }
    
    .footer-credits {
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .app-footer {
        padding: 6px 10px;
    }
    
    .footer-links a {
        font-size: 10px;
    }
    
    .footer-divider {
        font-size: 8px;
    }
}

/* ============================================
   Estilos específicos para Balizas V16
   ============================================ */

/* Color V16 (naranja emergencia) */
:root {
    --v16-primary: #ff6b35;
    --v16-glow: rgba(255, 107, 53, 0.4);
}

/* Badge V16 en tarjetas */
.beacon-badge-v16 {
    font-size: 10px;
    padding: 3px 8px;
    background: linear-gradient(135deg, var(--v16-primary), #ff4444);
    border-radius: 4px;
    color: white;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px var(--v16-glow);
}

/* Tarjeta de baliza V16 */
.beacon-card.beacon-v16::before {
    background: linear-gradient(180deg, var(--v16-primary), #ff4444);
}

.beacon-card.beacon-v16:hover {
    border-color: var(--v16-primary);
}

.beacon-card.beacon-v16.active {
    border-color: var(--v16-primary);
    box-shadow: 0 0 0 2px var(--v16-glow);
}

/* Popup tipo V16 - Incidencia general */
.popup-type-v16 {
    background: linear-gradient(135deg, var(--v16-primary), #ff4444) !important;
    color: white !important;
    font-weight: 600;
}

/* Popup tipo DANGER - Carretera cortada */
.popup-type-danger {
    background: linear-gradient(135deg, #dc2626, #991b1b) !important;
    color: white !important;
    font-weight: 600;
}

/* Popup tipo WARNING - Circulación restringida */
.popup-type-warning {
    background: linear-gradient(135deg, #f97316, #c2410c) !important;
    color: white !important;
    font-weight: 600;
}

/* Popup tipo SLOW - Tráfico lento */
.popup-type-slow {
    background: linear-gradient(135deg, #eab308, #a16207) !important;
    color: white !important;
    font-weight: 600;
}

/* Subtipo de incidencia */
.popup-subtipo {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    margin: 8px 0;
    font-style: italic;
}

/* Fuente de datos */
.popup-source {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

/* Duración en popup */
.popup-duration {
    color: var(--v16-primary);
    font-weight: 600;
}

/* Leyenda V16 */
.legend-v16 {
    max-width: 280px;
}

.legend-v16 .legend-items {
    flex-direction: column;
    gap: 8px;
}

.legend-v16 .legend-item {
    gap: 10px;
}

.legend-icon-v16 {
    display: flex;
    align-items: center;
    justify-content: center;
}

.legend-icon-v16 svg {
    filter: drop-shadow(0 2px 4px var(--v16-glow));
}

.legend-info {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.legend-info p {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
}

/* Cluster V16 */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background: rgba(255, 107, 53, 0.4) !important;
    border-color: var(--v16-primary) !important;
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background: var(--v16-primary) !important;
}

/* Responsive para leyenda V16 */
@media (max-width: 768px) {
    .legend-v16 {
        max-width: 200px;
    }
    
    .legend-info p {
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .legend-v16 {
        max-width: 160px;
    }
    
    .legend-icon-v16 svg {
        width: 16px;
        height: 20px;
    }
    
    .legend-info {
        display: none;
    }
}

/* ============================================
   Cámaras DGT
   ============================================ */

/* Icono de cámara */
.camera-marker {
    background: transparent !important;
    border: none !important;
}

.camera-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
    transition: transform var(--transition-fast);
}

.camera-marker:hover .camera-icon {
    transform: scale(1.15);
}

/* Cluster de cámaras */
.marker-cluster-camera {
    background: rgba(33, 150, 243, 0.3) !important;
    border: 2px solid #2196F3 !important;
}

.marker-cluster-camera div {
    background: #2196F3 !important;
    color: white !important;
    font-weight: 600;
    font-size: 11px;
}

/* Popup de cámara */
.camera-popup-container .leaflet-popup-content {
    margin: 0;
    width: 340px !important;
}

.camera-popup .popup-header {
    background: linear-gradient(135deg, #1565C0 0%, #2196F3 100%);
}

.popup-type-camera {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Contenedor de imagen de cámara */
.camera-image-container {
    position: relative;
    background: var(--bg-primary);
    border-radius: 6px;
    overflow: hidden;
    margin: 10px;
}

.camera-image {
    width: 100%;
    height: auto;
    min-height: 180px;
    max-height: 220px;
    object-fit: cover;
    display: block;
    background: var(--bg-tertiary);
}

.camera-refresh-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    backdrop-filter: blur(4px);
}

.camera-refresh-btn:hover {
    background: rgba(33, 150, 243, 0.8);
    transform: scale(1.1);
}

.camera-refresh-btn.spinning {
    animation: spin 0.8s linear infinite;
}

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

/* Footer del popup de cámara */
.popup-camera-footer {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.popup-camera-footer small {
    color: var(--text-muted);
    font-size: 10px;
}

.popup-camera-footer a {
    color: #2196F3;
    text-decoration: none;
}

.popup-camera-footer a:hover {
    text-decoration: underline;
}

/* ============================================
   Accident Markers
   ============================================ */
.accident-marker {
    background: transparent !important;
    border: none !important;
}

.marker-cluster-accident {
    background: rgba(239, 68, 68, 0.3) !important;
    border: 2px solid #ef4444 !important;
}
.marker-cluster-accident div {
    background: #ef4444 !important;
    color: white !important;
    font-weight: 600;
    font-size: 11px;
}

/* Popup accidente */
.popup-type-accident {
    background: linear-gradient(135deg, #ef4444, #b91c1c) !important;
    color: white !important;
    font-weight: 600;
}

/* ============================================
   Radar Markers
   ============================================ */
.radar-marker {
    background: transparent !important;
    border: none !important;
}

.marker-cluster-radar-fijo {
    background: rgba(234, 179, 8, 0.3) !important;
    border: 2px solid #eab308 !important;
}
.marker-cluster-radar-fijo div {
    background: #eab308 !important;
    color: #000 !important;
    font-weight: 600;
    font-size: 11px;
}

.marker-cluster-radar-movil {
    background: rgba(16, 185, 129, 0.3) !important;
    border: 2px solid #10b981 !important;
}
.marker-cluster-radar-movil div {
    background: #10b981 !important;
    color: white !important;
    font-weight: 600;
    font-size: 11px;
}

.popup-type-radar {
    background: linear-gradient(135deg, #eab308, #a16207) !important;
    color: white !important;
    font-weight: 600;
}

.popup-type-radar-movil {
    background: linear-gradient(135deg, #10b981, #047857) !important;
    color: white !important;
    font-weight: 600;
}

/* Cámaras en la lista de resultados */
.beacon-camera {
    border-left-color: #2196F3;
}

.beacon-camera:hover {
    border-left-color: #1976D2;
    background: rgba(33, 150, 243, 0.1);
}

.beacon-badge-camera {
    background: #2196F3;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

/* Divisor de sección en la lista */
.list-section-divider {
    padding: 10px 16px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    margin-top: 8px;
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Responsive cámaras */
@media (max-width: 768px) {
    .camera-popup-container .leaflet-popup-content {
        width: 300px !important;
    }
    
    .camera-image {
        min-height: 150px;
        max-height: 180px;
    }
}

@media (max-width: 480px) {
    .camera-popup-container .leaflet-popup-content {
        width: 260px !important;
    }
    
    .camera-image {
        min-height: 120px;
        max-height: 150px;
    }
}

/* ============================================
   FAQ Footer Expandible
   ============================================ */
.faq-footer {
    position: fixed;
    bottom: 36px; /* Altura del footer legal */
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    transition: transform 0.3s ease;
}

.faq-footer.collapsed {
    transform: translateY(calc(100% - 44px));
}

.faq-footer-toggle {
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.1), rgba(255, 107, 53, 0.05));
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all var(--transition-fast);
}

.faq-footer-toggle:hover {
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.15), rgba(255, 107, 53, 0.08));
}

.faq-toggle-icon {
    font-size: 10px;
    color: #ff6b35;
    transition: transform 0.3s ease;
}

.faq-footer.collapsed .faq-toggle-icon {
    transform: rotate(180deg);
}

.faq-toggle-text {
    color: var(--text-primary);
}

.faq-footer-content {
    max-height: 60vh;
    overflow-y: auto;
    background: var(--bg-primary);
}

.faq-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 24px;
}

/* Intro */
.faq-intro {
    text-align: center;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.faq-intro h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.faq-intro p {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
    max-width: 700px;
    margin: 0 auto;
}

/* Grid de FAQs */
.faq-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.faq-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    transition: all var(--transition-fast);
}

.faq-item:hover {
    border-color: rgba(255, 107, 53, 0.3);
    transform: translateY(-2px);
}

.faq-item h3 {
    font-size: 1rem;
    color: #ff6b35;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.faq-item h3::before {
    content: "?";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: rgba(255, 107, 53, 0.2);
    color: #ff6b35;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
}

.faq-item p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
}

.faq-item strong {
    color: var(--text-primary);
}

/* Texto SEO adicional */
.faq-seo-text {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-color);
}

.faq-seo-text h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.faq-seo-text p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.7;
    margin-bottom: 12px;
}

.faq-seo-text p:last-child {
    margin-bottom: 0;
}

.faq-seo-text strong {
    color: var(--text-primary);
}

/* Ajustar footer legal cuando FAQ está visible */
.app-footer {
    position: relative;
    z-index: 1001;
}

/* Responsive */
@media (max-width: 768px) {
    .faq-footer {
        bottom: 54px; /* Espacio suficiente para el footer legal que crece en móvil */
    }
    
    .faq-footer-toggle {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .faq-toggle-icon {
        font-size: 8px;
    }
    
    .faq-container {
        padding: 20px 16px;
    }
    
    .faq-intro h2 {
        font-size: 1.25rem;
    }
    
    .faq-intro p {
        font-size: 0.9rem;
    }
    
    .faq-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .faq-item {
        padding: 16px;
    }
    
    .faq-item h3 {
        font-size: 0.95rem;
    }
    
    .faq-item p {
        font-size: 0.85rem;
    }
    
    .faq-seo-text {
        padding: 16px;
    }
    
    .faq-seo-text h3 {
        font-size: 1rem;
    }
    
    .faq-seo-text p {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .faq-footer-content {
        max-height: 70vh;
    }
    
    .faq-toggle-text {
        font-size: 12px;
    }
}

/* ============================================
   Camera Lightbox
   ============================================ */
.camera-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(8px);
}

.camera-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-container {
    background: var(--bg-secondary);
    border-radius: 16px;
    max-width: 95vw;
    max-height: 95vh;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    border: 1px solid var(--border-color);
}

.camera-lightbox.active .lightbox-container {
    transform: scale(1);
}

.lightbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.15), rgba(33, 150, 243, 0.05));
    border-bottom: 1px solid var(--border-color);
}

.lightbox-info h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.lightbox-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

.lightbox-actions {
    display: flex;
    gap: 8px;
}

.lightbox-refresh-btn,
.lightbox-close-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.lightbox-refresh-btn:hover {
    background: #2196f3;
    border-color: #2196f3;
    color: white;
}

.lightbox-close-btn:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
}

.lightbox-refresh-btn.spinning svg {
    animation: spin 1s linear infinite;
}

.lightbox-image-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #0a0a0f;
    min-height: 300px;
    position: relative;
}

.lightbox-image-wrapper img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.lightbox-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

.lightbox-source {
    font-size: 0.8rem;
    color: #2196f3;
    font-weight: 500;
}

.lightbox-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Hint en el popup de cámara */
.camera-zoom-hint {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.camera-image-container:hover .camera-zoom-hint {
    opacity: 1;
}

/* Responsive lightbox */
@media (max-width: 768px) {
    .camera-lightbox {
        padding: 10px;
    }
    
    .lightbox-container {
        max-width: 100%;
        max-height: 100%;
        border-radius: 12px;
    }
    
    .lightbox-header {
        padding: 12px 16px;
    }
    
    .lightbox-info h3 {
        font-size: 1rem;
    }
    
    .lightbox-image-wrapper {
        padding: 12px;
        min-height: 200px;
    }
    
    .lightbox-image-wrapper img {
        max-height: 60vh;
    }
    
    .lightbox-footer {
        padding: 10px 16px;
        flex-direction: column;
        gap: 4px;
        text-align: center;
    }
    
    .lightbox-refresh-btn,
    .lightbox-close-btn {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 480px) {
    .lightbox-info h3 {
        font-size: 0.9rem;
    }
    
    .lightbox-info p {
        font-size: 0.75rem;
    }
    
    .lightbox-image-wrapper img {
        max-height: 50vh;
    }
}
