/* ===== Global Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #1F2937;
    overflow: hidden;
    background-color: #F3F4F6;
}

/* ===== Header ===== */
.header {
    background: white;
    color: #1F2937;
    padding: 0 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    position: relative;
    height: 70px;
    border-bottom: 1px solid #E5E7EB;
}

.header-content h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.1rem;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-content h1 i {
    color: #3B82F6;
}

.header-subtitle {
    font-size: 0.875rem;
    color: #6B7280;
    margin-left: 2rem;
}

.header-stats {
    display: flex;
    gap: 2.5rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.stat-label {
    font-size: 0.7rem;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1F2937;
    line-height: 1.2;
}

/* ===== Filter Bar ===== */
.filter-bar {
    background: white;
    padding: 0 2rem;
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    gap: 0.75rem;
    z-index: 999;
    position: relative;
    flex-wrap: wrap;
    height: 56px;
    align-items: center;
}

.filter-btn {
    background: white;
    border: 1px solid #D1D5DB;
    padding: 0.4rem 0.875rem;
    border-radius: 2rem;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #4B5563;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-btn:hover {
    background: #F9FAFB;
    border-color: #9CA3AF;
    color: #1F2937;
}

.filter-btn.active {
    background: #EFF6FF;
    color: #2563EB;
    border-color: #3B82F6;
    box-shadow: 0 1px 2px rgba(59, 130, 246, 0.1);
}

/* ===== Main App Container ===== */
.app-container {
    display: flex;
    height: calc(100vh - 126px);
    position: relative;
    overflow: hidden;
}

#map {
    flex-grow: 1;
    height: 100%;
    z-index: 1;
    background: #F3F4F6;
}

/* ===== Insight Sidebar ===== */
.sidebar {
    width: 400px;
    background: white;
    box-shadow: -5px 0 25px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    z-index: 2000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    transform: translateX(0);
    border-left: 1px solid #E5E7EB;
}

.sidebar.hidden {
    transform: translateX(100%);
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.sidebar-header h2 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #9CA3AF;
    font-weight: 600;
}

.icon-btn {
    background: white;
    border: 1px solid #E5E7EB;
    cursor: pointer;
    color: #6B7280;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: #F3F4F6;
    color: #1F2937;
    border-color: #D1D5DB;
}

.sidebar-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 1.5rem 1.5rem 1.5rem;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9CA3AF;
    text-align: center;
    padding: 2rem;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #E5E7EB;
}

/* Sidebar Details Styling */
.detail-section {
    margin-bottom: 2rem;
}

.detail-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #6B7280;
    margin-bottom: 1rem;
    letter-spacing: 0.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #F3F4F6;
}

.detail-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: #F3F4F6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    flex-shrink: 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.detail-title h2 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    color: #111827;
    font-weight: 700;
    line-height: 1.2;
}

.type-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    letter-spacing: 0.3px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    background: #F9FAFB;
    padding: 1.25rem;
    border-radius: 0.75rem;
    border: 1px solid #F3F4F6;
}

.info-item label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #9CA3AF;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.info-item span {
    font-size: 0.9375rem;
    color: #1F2937;
    font-weight: 500;
}

/* List Cards for Dependencies */
.dependency-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dependency-item {
    display: flex;
    align-items: center;
    padding: 0.875rem;
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.dependency-item:hover {
    border-color: #3B82F6;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.dependency-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #E5E7EB;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    font-size: 0.875rem;
    color: white;
    flex-shrink: 0;
}

.dependency-info {
    flex-grow: 1;
    min-width: 0;
}

.dependency-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dependency-type {
    font-size: 0.75rem;
    color: #9CA3AF;
}

/* Risk Meter */
.risk-meter {
    height: 6px;
    background: #E5E7EB;
    border-radius: 3px;
    margin-top: 0.75rem;
    overflow: hidden;
}

.risk-meter-fill {
    height: 100%;
    transition: width 0.5s ease;
}

/* ===== Welcome Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 700px;
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid #F3F4F6;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    background: white;
    padding: 2rem 2rem 0 2rem;
    text-align: center;
}

.modal-header h2 {
    color: #111827;
    font-size: 1.75rem;
    font-weight: 800;
}

.modal-body {
    padding: 2rem;
}

.lead-text {
    font-size: 1.125rem;
    color: #6B7280;
    margin-bottom: 2.5rem;
    text-align: center;
    max-width: 80%;
    margin-left: auto;
    margin-right: auto;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.guide-card {
    text-align: center;
    padding: 1.5rem;
    background: #F9FAFB;
    border-radius: 1rem;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.guide-card:hover {
    border-color: #E5E7EB;
    background: white;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}

.icon-box {
    width: 56px;
    height: 56px;
    background: white;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #3B82F6;
    margin: 0 auto 1rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.guide-card h3 {
    color: #111827;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.guide-card p {
    font-size: 0.875rem;
    color: #6B7280;
    line-height: 1.5;
}

.modal-footer {
    padding: 1.5rem 2rem;
    background: white;
    display: flex;
    justify-content: center;
    padding-bottom: 2.5rem;
}

.primary-btn {
    background: #111827;
    color: white;
    border: none;
    padding: 0.875rem 2rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.primary-btn:hover {
    background: #1F2937;
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* ===== Legend Panel Updates ===== */
.legend-panel {
    position: absolute; 
    bottom: 2rem;
    left: 2rem;
    z-index: 1000;
    background: white;
    border-radius: 1rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    padding: 1.25rem;
    max-width: 280px; /* Øget bredde fra 240px til 280px */
    border: 1px solid #F3F4F6;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 80vh; /* Begræns højde */
    overflow-y: auto; /* Scroll hvis for lang */
}

/* Scrollbar styling for legend */
.legend-panel::-webkit-scrollbar {
    width: 6px;
}
.legend-panel::-webkit-scrollbar-track {
    background: transparent;
}
.legend-panel::-webkit-scrollbar-thumb {
    background-color: #E5E7EB;
    border-radius: 20px;
}

/* Collapsed State */
.legend-panel.collapsed {
    width: 48px;
    height: 48px;
    padding: 0;
    overflow: hidden;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* Hide content when collapsed */
.legend-panel.collapsed h3,
.legend-panel.collapsed .legend-section,
.legend-panel.collapsed .legend-scroll-area {
    opacity: 0;
    pointer-events: none;
}

/* Toggle Button Styling */
.legend-toggle-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.5rem; /* Flyttet lidt mere til højre (var 0.75rem) */
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #9CA3AF;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.legend-toggle-btn:hover {
    background: #F3F4F6;
    color: #1F2937;
}

/* Center toggle button when collapsed and change icon */
.legend-panel.collapsed .legend-toggle-btn {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 0;
}

.legend-panel.collapsed .legend-toggle-btn i::before {
    content: "\f0c9"; /* skift til 'list' icon (bars) eller lignende */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
}

.legend-panel.collapsed:hover {
    transform: scale(1.1);
}

.legend-panel h3 {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
    color: #9CA3AF;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-right: 20px; /* Ekstra plads til højre for teksten så den ikke rammer knappen */
}

.legend-section {
    margin-bottom: 1.25rem;
}

.legend-section:last-child {
    margin-bottom: 0;
}

.legend-section h4 {
    font-size: 0.7rem;
    font-weight: 600;
    color: #4B5563;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem 0.5rem;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 6px;
    margin-bottom: 2px;
}

.legend-item:hover {
    background-color: #F3F4F6;
}

/* Disabled state for legend items */
.legend-item.disabled {
    opacity: 0.5;
    background-color: transparent;
}

.legend-item.disabled .legend-label {
    text-decoration: line-through;
    color: #9CA3AF;
}

.legend-item.disabled .legend-dot {
    background-color: #D1D5DB !important; /* Force gray dot */
    box-shadow: none;
}

.legend-item.disabled .legend-icon {
    color: #D1D5DB !important; /* Force gray icon */
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px white, 0 0 0 3px rgba(0,0,0,0.05);
}

.legend-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    flex-shrink: 0;
    margin-right: 0.25rem;
}

.legend-line {
    width: 20px;
    height: 0;
    flex-shrink: 0;
}

.legend-label {
    color: #4B5563;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay.hidden {
    display: none !important;
}

.loading-overlay p {
    margin-top: 1.5rem;
    color: #6B7280;
    font-weight: 500;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #E5E7EB;
    border-top-color: #111827;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Leaflet Popup Content Styling */
.leaflet-popup-content-wrapper {
    border-radius: 0.75rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.leaflet-popup-content {
    margin: 0.75rem 1rem;
    font-family: 'Inter', sans-serif;
}

.popup-header {
    font-size: 1rem;
    font-weight: 700;
    color: #1F2937;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.popup-type {
    font-size: 0.75rem;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    display: inline-block;
    margin-bottom: 0.5rem;
}

.popup-detail {
    font-size: 0.8rem;
    color: #6B7280;
    margin: 0.25rem 0;
}

/* Custom Marker Styles */
.custom-marker {
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* Link Animations & Styles */
@keyframes flow {
    to {
        stroke-dashoffset: -200;
    }
}

.leaflet-overlay-pane path {
    transition: stroke 0.3s, stroke-width 0.3s, opacity 0.3s;
}

.link-flow {
    animation: flow 30s linear infinite;
}

.link-critical {
    animation: flow 60s linear infinite;
}

/* Focus Mode / Path Tracing Styles */
.map-dimmed .leaflet-marker-icon,
.map-dimmed .leaflet-marker-shadow,
.map-dimmed path.leaflet-interactive {
    opacity: 0.02 !important;
    filter: grayscale(100%);
    transition: all 0.3s ease;
    stroke-width: 1px !important;
}

.map-dimmed .highlighted {
    opacity: 1.0 !important;
    filter: none !important;
    z-index: 1000 !important;
}

.map-dimmed path.highlighted {
    opacity: 1.0 !important;
    filter: none !important;
    stroke-opacity: 1.0 !important;
    fill-opacity: 1.0 !important;
    stroke-width: 4px !important;
}

path.highlighted {
    stroke-width: 4px !important;
    stroke-opacity: 1.0 !important;
    filter: drop-shadow(0 0 4px rgba(59, 130, 246, 0.5));
}

.custom-marker.highlighted {
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.8), 0 0 15px rgba(59, 130, 246, 0.8);
    z-index: 1000 !important;
    transform: scale(1.2);
}
