* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f9fafb;
    color: #111827;
    min-height: 100vh;
    padding: 2rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.header {
    margin-bottom: 2rem;
}

#region-title {
    font-size: 2rem;
    font-weight: bold;
    color: #111827;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #6b7280;
    margin-bottom: 1.5rem;
}

.controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.controls label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

#informant-select {
    padding: 0.5rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background-color: white;
    font-size: 0.875rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

#informant-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.legend {
    background-color: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

.legend h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 1rem;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 1rem;
    height: 1rem;
    border-radius: 0.25rem;
}

.legend-item span {
    font-size: 0.875rem;
    color: #4b5563;
}

/* ----------------------------------------- */
/*            ⭐ GLOBAL SEARCH                */
/* ----------------------------------------- */

.global-search {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto 1.5rem;
}

.global-search input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
}

.global-search input:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* ✨ SEARCH SUGGESTIONS DROPDOWN STYLING ✨ */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.5rem;
    background-color: white;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
}

.search-suggestions.hidden {
    display: none;
}

.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.suggestion-item:hover {
    background-color: #f9fafb;
}

.suggestion-item strong {
    color: #111827;
    font-size: 0.875rem;
}

.suggestion-type {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background-color: #f3f4f6;
    color: #6b7280;
    border-radius: 0.25rem;
    font-weight: 500;
}

/* ----------------------------------------- */
/*          Calendar Container               */
/* ----------------------------------------- */

.calendar-container {
    background-color: white;
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    position: relative;
    overflow: hidden;
    user-select: none;
}

#calendar-svg {
    display: block;
    margin: 0 auto;
    transition: cursor 0.2s;
}

/* ✨ NEW: Zoom/Pan indicator */
.calendar-container::after {
    content: 'Ctrl+Scroll to zoom • Drag to pan • Double-click to reset';
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    font-size: 0.625rem;
    color: #9ca3af;
    background: rgba(255, 255, 255, 0.9);
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ✨ NEW: Track Guide Styling */
.track-guide {
    pointer-events: none;
}

/* ✨ NEW: Detail Panel Styling */
.detail-panel {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-top: 1.5rem;
    border: 2px solid #8b5cf6;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.detail-panel.hidden {
    display: none;
}

.detail-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e5e7eb;
}

.detail-panel-title {
    font-size: 1.25rem;
    font-weight: bold;
    color: #111827;
    flex: 1;
}

.detail-panel-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.detail-panel-close:hover {
    background-color: #f3f4f6;
    color: #111827;
}

.detail-panel-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.detail-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.detail-label {
    font-weight: 600;
    color: #374151;
    min-width: 120px;
}

.detail-value {
    color: #4b5563;
    flex: 1;
}

.detail-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.detail-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.detail-button {
    padding: 0.5rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.detail-button-edit {
    background-color: #8b5cf6;
    color: white;
}

.detail-button-edit:hover {
    background-color: #7c3aed;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(139, 92, 246, 0.3);
}

.detail-button-delete {
    background-color: #ef4444;
    color: white;
}

.detail-button-delete:hover {
    background-color: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(239, 68, 68, 0.3);
}

.detail-section {
    margin-top: 1rem;
}

.detail-section-title {
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
}

.detail-list li {
    padding: 0.25rem 0;
    color: #4b5563;
    font-size: 0.875rem;
    line-height: 1.5;
}

.detail-list li strong {
    color: #111827;
}

/* ✨ NEW: Clickable connection links styling */
.detail-connections {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.connection-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(135deg, #f3e8ff 0%, #e9d5ff 100%);
    border: 1px solid #d8b4fe;
    border-radius: 0.375rem;
    color: #6b21a8;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.connection-link:hover {
    background: linear-gradient(135deg, #e9d5ff 0%, #d8b4fe 100%);
    border-color: #c084fc;
    transform: translateX(4px);
    box-shadow: 0 2px 4px rgba(139, 92, 246, 0.2);
}

.connection-link svg {
    flex-shrink: 0;
}

.connection-link.cascade-effect {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: #fcd34d;
    color: #92400e;
}

.connection-link.cascade-effect:hover {
    background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%);
    border-color: #fbbf24;
}

.connection-link span {
    flex: 1;
    line-height: 1.4;
}

.connection-link strong {
    color: inherit;
    font-weight: 600;
}

.connection-link em {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* ✨ NEW: Connection error message styling */
.connection-error-message {
    animation: slideDown 0.3s ease;
}

.connection-error-message > div {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* ----------------------------------------- */
/*      Web View Wrapper                     */
/* ----------------------------------------- */

.web-view-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ----------------------------------------- */
/*      ❌ Remove Old Internal Searches       */
/* ----------------------------------------- */

.web-view-search,
.calendar-search {
    display: none; /* They still exist but are hidden */
}

/* ----------------------------------------- */
/* Tooltip Styles */
/* ----------------------------------------- */

.tooltip {
    position: fixed;
    background-color: white;
    border: 2px solid #d1d5db;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.2);
    padding: 1rem;
    max-width: 24rem;
    z-index: 1000;
    pointer-events: none;
}

.tooltip.hidden {
    display: none;
}

.tooltip h4 {
    font-size: 1rem;
    font-weight: bold;
    color: #111827;
    margin-bottom: 0.75rem;
}

.tooltip-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.tooltip-row {
    display: flex;
    gap: 0.5rem;
}

.tooltip-label {
    font-weight: 600;
    color: #374151;
}

.tooltip-value {
    color: #4b5563;
}

.tooltip-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

.tooltip-description {
    color: #6b7280;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    line-height: 1.4;
}

.tooltip-notes {
    font-size: 0.75rem;
    color: #6b7280;
    font-style: italic;
    margin-top: 0.5rem;
    line-height: 1.4;
}

/* ✨ NEW: Temporal change section styling */
.temporal-change-section {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    padding: 0.75rem;
    border-radius: 0.375rem;
    margin: 0.5rem 0;
    border-left: 3px solid #f59e0b;
}

.temporal-change-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    color: #92400e;
    font-weight: 600;
    font-size: 0.875rem;
}

.change-icon {
    font-size: 1rem;
    font-weight: bold;
}

.temporal-change-section .tooltip-row {
    margin-top: 0.375rem;
}

.temporal-change-section .tooltip-label {
    color: #78350f;
}

.temporal-change-section .tooltip-value {
    color: #451a03;
}

/* ✨ NEW: Confidence badges */
.confidence-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.confidence-badge.high {
    background: #d1fae5;
    color: #065f46;
}

.confidence-badge.medium {
    background: #fef3c7;
    color: #92400e;
}

.confidence-badge.low {
    background: #fee2e2;
    color: #991b1b;
}

/* ✨ NEW: Lists in tooltips */
.trigger-list, .cascade-list, .notable-years-list {
    margin: 0.5rem 0 0 1.25rem;
    padding: 0;
    font-size: 0.75rem;
    line-height: 1.5;
}

.trigger-list li, .cascade-list li, .notable-years-list li {
    margin-bottom: 0.25rem;
    color: #4b5563;
}

.footer {
    margin-top: 1.5rem;
    text-align: center;
}

#indicator-count {
    font-size: 0.875rem;
    color: #6b7280;
}

/* ✨ IMPROVED: Arc hover effect with smooth transitions */
.arc-segment {
    cursor: pointer;
    transition: all 0.3s ease;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.arc-segment:hover {
    opacity: 1 !important;
}

/* ✨ IMPROVED: Linking lines with better hover states */
.linking-line {
    transition: all 0.3s ease;
    pointer-events: none;
}

/* ✨ IMPROVED: Dot indicators styling */
.indicator-dot-group {
    cursor: pointer;
    transition: all 0.3s ease;
}

.indicator-dot {
    transition: all 0.3s ease;
}

.indicator-dot-group:hover .indicator-dot {
    filter: brightness(1.1);
}

/* ✨ NEW: Glow effect for temporal changes */
.has-temporal-change {
    animation: subtle-pulse 3s ease-in-out infinite;
}

@keyframes subtle-pulse {
    0%, 100% {
        filter: drop-shadow(0 0 2px rgba(139, 92, 246, 0.4));
    }
    50% {
        filter: drop-shadow(0 0 4px rgba(139, 92, 246, 0.6));
    }
}

/* Month labels */
.month-label {
    font-size: 0.875rem;
    font-weight: 500;
    fill: #374151;
}

/* ----------------------------------------- */
/*              Web View Styling             */
/* ----------------------------------------- */

.view-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: white;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.view-toggle:hover {
    background-color: #f3f4f6;
}

.view-toggle.active {
    background-color: #8b5cf6;
    color: white;
    border-color: #8b5cf6;
}

.web-view-container {
    background-color: white;
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    min-height: 800px;
}

#web-view-svg {
    display: block;
    margin: 0 auto;
}

.node-group,
.node-circle,
.link-line {
    transition: all 0.2s;
}

/* Web View Legend */
.web-view-legend {
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    margin-top: 1rem;
}

.web-view-legend h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 1rem;
}

.legend-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.legend-section h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: #4b5563;
}

.legend-item svg {
    flex-shrink: 0;
}

.legend-item span {
    line-height: 1.4;
}

/* Calendar Legend */
.calendar-legend {
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    margin-top: 1.5rem;
}

.calendar-legend h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.75rem;
}

.calendar-legend-content {
    font-size: 0.875rem;
    color: #4b5563;
    line-height: 1.6;
}

.calendar-legend-content p {
    margin-bottom: 0.5rem;
}

.calendar-legend-content p:first-of-type {
    background: linear-gradient(135deg, #f3e8ff 0%, #e9d5ff 100%);
    padding: 0.5rem;
    border-radius: 0.375rem;
    border-left: 3px solid #8b5cf6;
    font-weight: 500;
}

/* ✨ NEW: Highlight animation for focused indicators */
@keyframes highlight-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.9;
        transform: scale(1.05);
    }
}

.indicator-highlighted {
    animation: highlight-pulse 1.5s ease-in-out 3;
}

/* ----------------------------------------- */
/*      Indicator Data List Styling          */
/* ----------------------------------------- */

.indicator-data-list {
    margin-top: 3rem;
    padding: 2rem;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.indicator-list-header {
    margin-bottom: 2rem;
    text-align: center;
}

.indicator-list-header h2 {
    font-size: 1.75rem;
    font-weight: bold;
    color: #111827;
    margin-bottom: 0.5rem;
}

.indicator-list-subtitle {
    color: #6b7280;
    font-size: 0.875rem;
}

.indicator-cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.indicator-data-card {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.indicator-data-card:hover {
    border-color: #8b5cf6;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
    transform: translateY(-2px);
}

.indicator-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f3f4f6;
}

.indicator-card-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #111827;
    flex: 1;
    margin-right: 1rem;
}

.action-badge {
    font-size: 1rem;
    vertical-align: middle;
}

.indicator-type-badge {
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.indicator-card-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.data-section {
    padding: 0.75rem;
    background: #f9fafb;
    border-radius: 0.375rem;
    border-left: 3px solid #d1d5db;
}

.data-section.temporal-change {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-left-color: #f59e0b;
}

.data-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.data-content {
    font-size: 0.875rem;
    color: #4b5563;
    line-height: 1.6;
}

.data-content strong {
    color: #111827;
    font-weight: 600;
}

.data-content em {
    color: #6b7280;
    font-style: italic;
    display: block;
    margin-top: 0.25rem;
}

.data-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.data-list li {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: white;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    color: #4b5563;
    line-height: 1.5;
}

.data-list li:last-child {
    margin-bottom: 0;
}

.data-list li strong {
    color: #111827;
    font-weight: 600;
}

.data-list li small {
    color: #6b7280;
    font-size: 0.75rem;
    display: block;
    margin-top: 0.25rem;
}

/* Confidence badges in data list */
.data-content .confidence-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-content .confidence-badge.high {
    background: #d1fae5;
    color: #065f46;
}

.data-content .confidence-badge.medium {
    background: #fef3c7;
    color: #92400e;
}

.data-content .confidence-badge.low {
    background: #fee2e2;
    color: #991b1b;
}

/* ----------------------------------------- */
/*          Responsive Design                */
/* ----------------------------------------- */

@media (max-width: 768px) {
    body {
        padding: 1rem;
    }
    
    #region-title {
        font-size: 1.5rem;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .global-search {
        max-width: 100%;
    }
    
    .legend-grid {
        grid-template-columns: 1fr;
    }
    
    .tooltip {
        max-width: 90vw;
    }
    
    .calendar-container {
        padding: 1rem;
    }
    
    .calendar-container::after {
        font-size: 0.5rem;
        bottom: 0.5rem;
        right: 0.5rem;
        padding: 0.25rem 0.5rem;
    }
    
    .indicator-cards-grid {
        grid-template-columns: 1fr;
    }
    
    .indicator-data-list {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    #calendar-svg {
        width: 100%;
        height: auto;
    }
    
    .month-label {
        font-size: 0.625rem;
    }
    
    .calendar-container::after {
        display: none;
    }
    
    .indicator-card-header {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .indicator-type-badge {
        align-self: flex-start;
    }
}