/**
 * timeline-v2.css
 * Organized styles matching original timeline appearance
 * Structure:
 * 1. Base & Body
 * 2. Navigation Header
 * 3. Timeline Container & Sections
 * 4. Timeline Events (Green/Red Dots)
 * 5. Caseline Elements
 * 6. Year Markers
 * 7. Controls & Filters
 * 8. Tooltips & Interactions
 * 9. Legend & Stats
 */

/* ========== 1. BASE & BODY ========== */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: white;
    margin: 0;
    padding: 0;
    overflow: auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-top: 190px; /* Space for header with border */
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 20px; /* Space for scrollbar */
}

.container {
    width: fit-content;
    background: transparent;
    padding: 40px 20px;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

/* ========== 2. NAVIGATION HEADER ========== */
.sticky-nav {
    position: fixed;
    top: 15px;
    left: 15px;
    right: 15px;
    background: #2c3e50;
    padding: 8px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 1000;
    flex-shrink: 0;
    border: 15px solid white;
}

.nav-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.nav-bottom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 40px;
}

.nav-filter-row {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 6px 0;
    border-top: 1px solid #34495e;
}

.nav-link {
    color: white;
    text-decoration: none;
    font-size: 16px;
    padding: 8px 16px;
    border-radius: 4px;
    background: #3498db;
    transition: background 0.3s ease;
}

.nav-link:hover {
    background: #455a71;
}

.nav-title {
    color: white;
    font-size: 18px;
    font-weight: bold;
}

/* ========== 3. TIMELINE CONTAINER & SECTIONS ========== */
.timeline-container {
    position: relative;
    margin: 10px 0;
    height: calc(100vh - 210px); /* Full height minus header */
    width: 100%;
    min-width: 1200px;
    display: flex;
    flex-direction: column;
}

/* Timeline sections */
.timeline-section {
    position: relative;
    width: 100%;
}

/* Caseline takes 60% of vertical space */
.caseline-section {
    height: 60%;
    position: relative;
    z-index: 10;
}

/* Timeline takes 40% of vertical space */
.timeline-events-section {
    height: 40%;
    position: relative;
    z-index: 10;
}

.section-content {
    position: absolute;
    top: 0;
    left: 0; /* Don't offset - nodes handle their own X positioning */
    right: 0;
    height: 100%;
}

/* The main timeline line (between public and private) */
.timeline-line {
    position: absolute;
    top: 50%; /* Center line divides public/private */
    left: 155px;
    right: 0;
    height: 1px; /* Single pixel width */
    background: rgba(52, 73, 94, 0.25); /* 25% opacity */
    z-index: 4; /* Timeline center line */
    transform: translateY(-50%);
}

/* Center line for caseline section - exactly between upper and lower nodes */
.caseline-center-line {
    position: absolute;
    top: calc(50% + 45px); /* Adjusted center line position */
    left: 155px;
    right: 0;
    height: 1px; /* Single pixel width */
    background: rgba(52, 73, 94, 0.25); /* 25% opacity */
    z-index: 4; /* Caseline center line */
    transform: translateY(-50%);
}

/* Background sections */
.timeline-section-background {
    position: absolute;
    left: 155px;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 1; /* Background at very bottom */
}

.public-section-bg {
    background: rgba(46, 125, 50, 0.08);
}

.private-section-bg {
    background: rgba(198, 40, 40, 0.08);
}

/* Section labels */
.section-label {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    font-weight: bold;
    z-index: 10; /* Section labels above year lines */
}

.caseline-label {
    color: #0066cc;
    font-size: 16px;
    top: calc(50% + 35px); /* Align with actual caseline vertical center */
    transform: translateY(-50%);
}

.public-label {
    color: #2e7d32;
}

.private-label {
    color: #c62828;
}

/* Overlays that span all sections */
.year-markers-overlay,
.connections-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.year-markers-overlay {
    z-index: 2; /* Year markers at bottom */
}

.connections-overlay {
    z-index: 5; /* Connections below sections but above backgrounds */
}

/* ========== 4. TIMELINE EVENTS (GREEN/RED DOTS) ========== */
.event,
.timeline-node {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 1px;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 30; /* Nodes above connections */
    transform: translateX(-50%);
}

/* Public events - green (absolute positioning) */
.tracked-event,
.event-above {
    background: #4caf50;
    border-color: #388e3c;
    top: 35%; /* Well above center in timeline section */
}

/* Private events - red (absolute positioning) */
.tracked-event-priv,
.event-below {
    background: #f44336;
    border-color: #d32f2f;
    top: 65%; /* Well below center in timeline section */
}

.event:hover,
.timeline-node:hover {
    transform: translateX(-50%) scale(1.2, 1.1);
    z-index: 35; /* Hovered nodes slightly above */
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Date labels */
.event-date-label {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    color: #666;
    white-space: nowrap;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.9);
    padding: 1px 3px;
    border-radius: 2px;
    z-index: 40; /* Date labels above nodes */
}

.event-above .event-date-label {
    bottom: calc(100% + 8px);
    margin-bottom: 2px;
}

.event-below .event-date-label {
    top: calc(100% + 8px);
    margin-top: 2px;
}

/* Missing indicator */
.missing-indicator {
    position: absolute;
    font-size: 7px;
    z-index: 41; /* Missing indicators above date labels */
    left: 50%;
    transform: translateX(-50%);
}

.event-above .missing-indicator {
    top: -10px;
}

.event-below .missing-indicator {
    bottom: -10px;
}

/* ========== 5. CASELINE ELEMENTS ========== */
.case-procedural,
.caseline-node {
    position: absolute;
    font-size: 16px;
    transform: translateX(-50%);
    cursor: pointer;
    z-index: 50; /* Caseline nodes well above labels (40) to ensure tooltips show properly */
}

/* When hovering caseline nodes, bring them to front */
.caseline-node:hover,
.case-procedural:hover {
    z-index: 100; /* Bring hovered node and its tooltip above everything */
}

/* Caseline public events - above the center (with offset for title space) */
.caseline-node.public,
.case-procedural-above {
    top: calc(50% - 20px + 35px); /* 20px above center + 35px down for title space */
}

/* Caseline private events - below the center (with offset for title space) */  
.caseline-node.private,
.case-procedural-below {
    top: calc(50% + 20px + 35px); /* 20px below center + 35px down for title space */
}

/* Caseline labels */
.node-label {
    position: absolute;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    background: transparent;
    border: none;
    white-space: nowrap;
    text-align: center;
    z-index: 40; /* Labels above nodes */
    cursor: pointer;
}

.node-label-above {
    /* Will be positioned dynamically by JS based on label height */
}

.node-label-below {
    /* Will be positioned dynamically by JS - top edge 30px below node */
}

/* Status colors for labels - text only, no backgrounds */
.status-approved {
    color: #4caf50;
}

.status-denied {
    color: #f44336;
}

.status-pending {
    color: #ffd700;
}

/* Continuance hiding - only hide nodes, not connection lines */
.hide-continuances .caseline-node.continuance {
    display: none !important;
}

/* ========== 6. YEAR MARKERS ========== */
.year-tick {
    position: absolute;
    width: 1px;
    height: 10px;
    background: #34495e;
    z-index: 2; /* Year markers at bottom */
}

.year-label {
    position: absolute;
    transform: translateX(-50%) translateY(-50%);
    font-weight: bold;
    color: #34495e;
    background: rgba(255,255,255,0.9);
    padding: 0 6px;
    font-size: 12px;
    z-index: 3; /* Year labels just above lines */
}

/* ========== 7. CONTROLS & FILTERS ========== */
.date-filter-group {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(52, 73, 94, 0.2);
    padding: 8px 15px;
    border-radius: 6px;
    border: 1px solid rgba(52, 73, 94, 0.6);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.filter-label {
    color: #ccc;
    font-size: 13px;
}

.filter-input {
    padding: 4px 8px;
    border: 1px solid #34495e;
    border-radius: 4px;
    background: #1a252f;
    color: white;
    font-size: 13px;
    transition: background-color 0.2s;
}

.filter-input.active-filter {
    background: #5c1616; /* Dark red background when filter is active */
    border-color: #8b2020;
}

.filter-button {
    padding: 4px 12px;
    border: 1px solid #34495e;
    border-radius: 4px;
    background: #34495e;
    color: white;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.filter-button:hover {
    background: #455a71;
}

#reset-filters.active-filters {
    background: #8b2020; /* Dark red when filters are active */
    border-color: #a52a2a;
}

#reset-filters.active-filters:hover {
    background: #a52a2a;
}

/* Case filter dropdown */
.case-filter-container {
    position: relative;
    display: inline-block;
}

.case-filter-button {
    padding: 4px 12px;
    border: 1px solid #34495e;
    border-radius: 4px;
    background: #1a252f;
    color: white;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 150px;
    justify-content: space-between;
    transition: background-color 0.2s, border-color 0.2s;
}

.case-filter-button:hover {
    background: #2c3e50;
}

.case-filter-button.active-filter {
    background: #5c1616; /* Dark red when not showing all cases */
    border-color: #8b2020;
}

.case-filter-button.active-filter:hover {
    background: #6c2020;
}

.dropdown-arrow {
    font-size: 10px;
}

.case-filter-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: #1a252f;
    border: 1px solid #34495e;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
}

.case-filter-controls {
    display: flex;
    gap: 8px;
    padding: 8px;
    border-bottom: 1px solid #34495e;
}

.select-all-btn,
.clear-all-btn {
    flex: 1;
    padding: 4px 8px;
    font-size: 11px;
    border: 1px solid #34495e;
    background: #2c3e50;
    color: white;
    cursor: pointer;
    border-radius: 3px;
}

.select-all-btn:hover,
.clear-all-btn:hover {
    background: #34495e;
}

.case-checkbox-list {
    padding: 8px;
}

.case-checkbox-label {
    display: flex;
    align-items: center;
    color: white;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 0;
    white-space: nowrap;
}

.case-checkbox {
    margin-right: 8px;
    cursor: pointer;
}

.case-checkbox-label:hover {
    color: #ffd700;
}

/* ========== 8. TOOLTIPS & INTERACTIONS ========== */
.event-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 500; /* High z-index to ensure tooltips appear above all other elements */
    white-space: nowrap;
    max-width: 400px;
}

/* Show tooltip on hover */
.event:hover .event-tooltip,
.timeline-node:hover .event-tooltip,
.caseline-node:hover .event-tooltip {
    opacity: 1;
}

/* Position tooltips above for top events, below for bottom events */
.event-above .event-tooltip {
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
}

.event-below .event-tooltip {
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
}

.event-date {
    font-weight: 600;
    color: #4fc3f7;
    margin-bottom: 4px;
}

.event-title {
    font-size: 14px;
    margin-bottom: 6px;
}

.event-detail {
    font-size: 12px;
    color: #ccc;
    white-space: normal;
}

/* ========== 9. LEGEND & STATS ========== */
.legend {
    display: flex;
    gap: 40px;
    color: white;
    font-size: 12px;
}

.legend table {
    border-collapse: collapse;
}

.legend td {
    padding: 2px 8px;
    white-space: nowrap;
}

.stats-container {
    display: flex;
    gap: 20px;
    color: white;
}

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

.stat-number {
    font-size: 18px;
    font-weight: bold;
    color: #ffd700;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    color: #ccc;
    opacity: 0.9;
}

/* Clickable stat styling */
.clickable-stat {
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.clickable-stat:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

/* Popup overlay and container */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.popup-container {
    background: #1a252f;
    border: 1px solid #34495e;
    border-radius: 8px;
    max-width: 600px;
    max-height: 80vh;
    width: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #34495e;
    background: #2c3e50;
    border-radius: 8px 8px 0 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.popup-header h3 {
    margin: 0;
    color: white;
    font-size: 18px;
}

.popup-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.popup-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.popup-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.popup-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.missing-docs-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.missing-doc-item {
    display: flex;
    gap: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #e0e0e0;
}

.missing-doc-date {
    color: #76d7c4;
    min-width: 100px;
}

.missing-doc-case {
    color: #f39c12;
    min-width: 80px;
}

.missing-doc-title {
    color: #e0e0e0;
    flex: 1;
}

.copy-button {
    padding: 6px 16px;
    background: #34495e;
    color: white;
    border: 1px solid #455a71;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.copy-button:hover {
    background: #455a71;
}

/* Loading state */
.loading {
    padding: 40px;
    text-align: center;
    color: #666;
    font-size: 16px;
}

/* Hide content initially */
#timeline-content {
    display: none;
}

/* Scrollbar styling */
.main-content::-webkit-scrollbar {
    height: 12px;
}

.main-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.main-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 6px;
}

.main-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}