/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #1a1a2e;
    color: #eaeaea;
    line-height: 1.6;
    font-size: 16px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    text-align: center;
    padding: 40px 0 20px;
    border-bottom: 2px solid #0f3460;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    color: #eaeaea;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    color: #a0a0a0;
    font-weight: 300;
}

/* Stats bar */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 40px;
    padding: 30px 0;
    flex-wrap: wrap;
}

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

.stat-label {
    font-size: 0.85rem;
    color: #a0a0a0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #e94560;
}

/* View tabs */
.view-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #0f3460;
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab-button {
    padding: 12px 28px;
    background: none;
    border: none;
    color: #a0a0a0;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.tab-button:hover {
    color: #eaeaea;
}

.tab-button.active {
    color: #e94560;
    border-bottom-color: #e94560;
}

/* Filters (cards controls) */
.filters,
.view-control-bar {
    display: flex;
    gap: 20px;
    padding: 20px;
    background-color: #16213e;
    border-radius: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 150px;
}

.checkbox-group {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.filter-group label {
    font-size: 0.85rem;
    color: #a0a0a0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group input[type="text"],
.filter-group select {
    padding: 10px 14px;
    background-color: #0f3460;
    border: 1px solid #1a4d7a;
    border-radius: 6px;
    color: #eaeaea;
    font-size: 0.95rem;
    transition: border-color 0.2s, background-color 0.2s;
}

.filter-group input[type="text"]:focus,
.filter-group select:focus {
    outline: none;
    border-color: #e94560;
    background-color: #153a5e;
}

.filter-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #e94560;
}

.checkbox-group label {
    cursor: pointer;
    margin-bottom: 0;
}

/* Date input dark theme */
.filter-group input[type="date"] {
    padding: 10px 14px;
    background-color: #0f3460;
    border: 1px solid #1a4d7a;
    border-radius: 6px;
    color: #eaeaea;
    font-size: 0.95rem;
    color-scheme: dark;
    transition: border-color 0.2s, background-color 0.2s;
}

.filter-group input[type="date"]:focus {
    outline: none;
    border-color: #e94560;
    background-color: #153a5e;
}

/* Range slider dark theme */
.filter-group input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: #0f3460;
    border-radius: 3px;
    outline: none;
}

.filter-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e94560;
    cursor: pointer;
}

.filter-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e94560;
    cursor: pointer;
    border: none;
}

.slider-group label {
    display: flex;
    gap: 4px;
}

/* Cards grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 24px;
    padding: 20px 0 40px;
}

.card {
    background-color: #16213e;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    position: relative;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
}

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

.card-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #eaeaea;
    margin-bottom: 8px;
    line-height: 1.4;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: #a0a0a0;
    margin-bottom: 12px;
}

.card-source {
    font-weight: 500;
    color: #0f8dd6;
}

.card-date {
    white-space: nowrap;
}

.card-summary {
    color: #c0c0c0;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 16px;
}

.card-entities {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.entity-tag {
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

.entity-tag.person {
    background-color: #e94560;
    color: #fff;
}

.entity-tag.organization {
    background-color: #0f3460;
    color: #fff;
}

.entity-tag.location {
    background-color: #53a653;
    color: #fff;
}

.entity-tag.topic {
    background-color: #e9a645;
    color: #1a1a2e;
}

.entity-tag.event {
    background-color: #a645e9;
    color: #fff;
}

.card-connections {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #0f3460;
}

.connection-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background-color: #0f3460;
    border-radius: 12px;
    font-size: 0.8rem;
    color: #e94560;
}

.connection-icon {
    font-size: 1rem;
}

/* Graph container */
.graph-container {
    width: 100%;
    height: calc(100vh - 300px);
    min-height: 500px;
    background-color: #16213e;
    border-radius: 12px;
    position: relative;
    margin-bottom: 20px;
}

/* Graph tooltip */
.graph-tooltip {
    position: absolute;
    padding: 10px 14px;
    background-color: #0f3460;
    border: 1px solid #1a4d7a;
    border-radius: 8px;
    color: #eaeaea;
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 100;
    display: none;
    max-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.graph-tooltip .tooltip-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.graph-tooltip .tooltip-meta {
    color: #a0a0a0;
    font-size: 0.8rem;
}

/* Timeline container */
.timeline-container {
    width: 100%;
    min-height: 400px;
    background-color: #16213e;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

/* vis-timeline dark theme overrides */
.timeline-container .vis-timeline {
    border: none;
    background-color: transparent;
}

.timeline-container .vis-panel.vis-bottom,
.timeline-container .vis-panel.vis-center,
.timeline-container .vis-panel.vis-left,
.timeline-container .vis-panel.vis-right,
.timeline-container .vis-panel.vis-top {
    border-color: #0f3460;
}

.timeline-container .vis-time-axis .vis-text {
    color: #a0a0a0;
    font-size: 0.8rem;
}

.timeline-container .vis-time-axis .vis-grid.vis-minor {
    border-color: rgba(15, 52, 96, 0.5);
}

.timeline-container .vis-time-axis .vis-grid.vis-major {
    border-color: #0f3460;
}

.timeline-container .vis-labelset .vis-label {
    color: #eaeaea;
    background-color: #1a1a2e;
    border-bottom: 1px solid #0f3460;
    font-size: 0.85rem;
    font-weight: 500;
}

.timeline-container .vis-foreground .vis-group {
    border-bottom: 1px solid #0f3460;
}

.timeline-container .vis-item {
    background-color: #0f3460;
    border-color: #1a4d7a;
    color: #eaeaea;
    border-radius: 4px;
    font-size: 0.8rem;
    padding: 2px 8px;
    cursor: pointer;
}

.timeline-container .vis-item.vis-selected {
    background-color: #e94560;
    border-color: #e94560;
}

.timeline-container .vis-item.entity-person {
    border-left: 3px solid #e94560;
}

.timeline-container .vis-item.entity-organization {
    border-left: 3px solid #4a90d9;
}

.timeline-container .vis-item.entity-location {
    border-left: 3px solid #53a653;
}

.timeline-container .vis-item.entity-topic {
    border-left: 3px solid #e9a645;
}

.timeline-container .vis-item.entity-event {
    border-left: 3px solid #a645e9;
}

.timeline-container .vis-current-time {
    background-color: #e94560;
}

/* Loading state */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #a0a0a0;
    gap: 16px;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #0f3460;
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Article detail panel */
.article-detail {
    position: fixed;
    top: 0;
    right: 0;
    width: 600px;
    max-width: 90vw;
    height: 100vh;
    background-color: #16213e;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.5);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
}

.article-detail.visible {
    transform: translateX(0);
}

.article-detail.hidden {
    display: block;
}

.close-button {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: #eaeaea;
    font-size: 2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.close-button:hover {
    background-color: #0f3460;
}

.detail-content {
    padding: 40px;
}

#detail-title {
    font-size: 2rem;
    font-weight: 700;
    color: #eaeaea;
    margin-bottom: 16px;
    line-height: 1.3;
    padding-right: 40px;
}

.detail-meta {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #0f3460;
}

.detail-source {
    font-weight: 600;
    color: #0f8dd6;
    font-size: 0.95rem;
}

.detail-date {
    color: #a0a0a0;
    font-size: 0.9rem;
}

.detail-summary {
    color: #c0c0c0;
    font-size: 1.05rem;
    line-height: 1.8;
    margin-bottom: 32px;
}

.detail-entities,
.detail-connections {
    margin-bottom: 32px;
}

.detail-entities h3,
.detail-connections h3 {
    font-size: 1.2rem;
    color: #eaeaea;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.entities-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.connections-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.connection-item {
    background-color: #0f3460;
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 3px solid #e94560;
}

.connection-strength {
    font-size: 0.85rem;
    color: #a0a0a0;
    margin-bottom: 4px;
}

.connection-description {
    color: #c0c0c0;
    font-size: 0.95rem;
}

.source-link {
    display: inline-block;
    margin-top: 24px;
    padding: 12px 24px;
    background-color: #e94560;
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.source-link:hover {
    background-color: #ff5570;
}

/* Footer */
footer {
    text-align: center;
    padding: 40px 0;
    color: #a0a0a0;
    font-size: 0.9rem;
    border-top: 1px solid #0f3460;
}

#last-updated {
    color: #eaeaea;
    font-weight: 500;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: #a0a0a0;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 12px;
    color: #eaeaea;
}

/* Responsive design */
@media (max-width: 1024px) {
    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }

    .filters,
    .view-control-bar {
        gap: 15px;
    }

    .filter-group {
        min-width: 120px;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2.5rem;
    }

    .stats-bar {
        gap: 24px;
    }

    .stat-value {
        font-size: 1.6rem;
    }

    .cards-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .filters,
    .view-control-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        min-width: auto;
    }

    .article-detail {
        width: 100vw;
    }

    .detail-content {
        padding: 30px 20px;
    }

    .graph-container {
        height: 400px;
        min-height: 300px;
    }

    .timeline-container {
        min-height: 300px;
    }

    .view-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .card {
        padding: 20px;
    }

    .card-title {
        font-size: 1.15rem;
    }

    #detail-title {
        font-size: 1.5rem;
    }
}
