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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header {
    background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
    color: white;
    padding: 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.1); opacity: 0.1; }
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
}

.header .tagline {
    font-size: 1.1em;
    opacity: 0.9;
    position: relative;
    z-index: 1;
    font-style: italic;
}

.main-content {
    padding: 30px;
}

.intro-section {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    border-left: 4px solid #FF6B6B;
}

.intro-section h2 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.3em;
}

.intro-section p {
    color: #666;
    line-height: 1.6;
    max-width: 800px;
    margin: 0 auto;
}

.search-section {
    margin-bottom: 30px;
}

.dual-search {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 20px;
}

.search-container {
    position: relative;
}

.search-container h4 {
    margin-bottom: 10px;
    color: #333;
    text-align: center;
    font-size: 1.1em;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-input {
    flex: 1;
    padding: 15px 20px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 25px;
    outline: none;
    transition: all 0.3s ease;
    background: white;
}

.search-input:focus {
    border-color: #FF6B6B;
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
    transform: translateY(-1px);
}

.search-input.topic-a:focus {
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.search-input.topic-b:focus {
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.related-btn {
    padding: 12px 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    white-space: nowrap;
}

.related-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

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

.related-icon {
    font-size: 16px;
}

.related-text {
    font-size: 13px;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 10px 10px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    margin-top: 5px;
}

.autocomplete-item {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
}

.autocomplete-item:hover {
    background-color: #f5f5f5;
    transform: translateX(3px);
}

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

/* Related Topics Modal Styles */
.related-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.related-modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 0;
    border: 1px solid #888;
    width: 90%;
    max-width: 600px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: slideDown 0.3s ease;
}

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

.related-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.related-modal-header h3 {
    margin: 0;
    font-size: 1.4em;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 20px;
}

.close:hover,
.close:focus {
    transform: scale(1.2);
}

.related-modal-body {
    padding: 20px;
    max-height: 500px;
    overflow-y: auto;
}

.related-spinner {
    width: 40px;
    height: 40px;
    margin: 20px auto;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

.related-results {
    margin-top: 10px;
}

.related-topic-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.related-topic-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.related-topic-title {
    font-weight: bold;
    color: #333;
    font-size: 1.1em;
    margin-bottom: 5px;
}

.related-topic-mentions {
    color: #667eea;
    font-size: 0.9em;
    font-weight: bold;
    margin-bottom: 8px;
}

.related-topic-extract {
    color: #666;
    font-size: 0.9em;
    line-height: 1.4;
}

.no-results {
    text-align: center;
    color: #666;
    padding: 20px;
    font-style: italic;
}

/* Time range section styles */
.time-range-section {
    text-align: center;
    margin: 30px 0;
}

.time-range-section h3 {
    margin-bottom: 15px;
    color: #333;
}

.time-range-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 15px;
}

.time-range-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.time-range-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    transition: all 0.3s ease;
    transform: translate(-50%, -50%);
}

.time-range-btn:hover::before {
    width: 100%;
    height: 100%;
}

.time-range-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

.time-range-btn.active {
    background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.3);
}

.results-section {
    margin-top: 30px;
}

.loading-container {
    text-align: center;
    padding: 60px 40px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #FF6B6B;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: #666;
    font-style: italic;
    font-size: 1.1em;
}

.correlation-stats {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
    border: 1px solid rgba(239, 108, 0, 0.1);
    animation: fadeIn 0.5s ease-out;
}

.correlation-stats h3 {
    color: #ef6c00;
    margin-bottom: 15px;
    font-size: 1.4em;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.stat-item {
    background: rgba(255,255,255,0.8);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    transition: transform 0.3s ease;
    border: 1px solid rgba(239, 108, 0, 0.1);
}

.stat-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.stat-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #ef6c00;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9em;
    color: #666;
}

.topic-legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    padding: 8px 15px;
    background: rgba(255,255,255,0.7);
    border-radius: 20px;
    transition: transform 0.2s ease;
}

.legend-item:hover {
    transform: scale(1.05);
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.topic-a-color { background: #4CAF50; }
.topic-b-color { background: #2196F3; }
.overlap-color { background: linear-gradient(45deg, #4CAF50 50%, #2196F3 50%); }

.correlation-result {
    background: white;
    border: 1px solid #ddd;
    border-radius: 15px;
    margin-bottom: 25px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: slideInUp 0.5s ease-out forwards;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.correlation-result:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.correlation-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 25px;
    border-bottom: 1px solid #ddd;
}

.correlation-title {
    font-size: 1.4em;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.correlation-date-range {
    color: #666;
    font-size: 1.1em;
    margin-bottom: 15px;
}

.correlation-strength {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.9em;
    color: white;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.strength-high { 
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    box-shadow: 0 3px 10px rgba(229, 62, 62, 0.3);
}
.strength-medium { 
    background: linear-gradient(135deg, #fd9801 0%, #e68900 100%);
    box-shadow: 0 3px 10px rgba(253, 152, 1, 0.3);
}
.strength-low { 
    background: linear-gradient(135deg, #9ae6b4 0%, #68d391 100%);
    color: #333;
    box-shadow: 0 3px 10px rgba(154, 230, 180, 0.3);
}

.correlation-timeline {
    padding: 25px;
}

.dual-timeline {
    margin: 20px 0;
}

.timeline-row {
    margin-bottom: 15px;
}

.timeline-label {
    font-weight: bold;
    margin-bottom: 5px;
    padding-left: 5px;
}

.timeline-bar {
    height: 35px;
    border-radius: 20px;
    overflow: hidden;
    background: #f0f0f0;
    display: flex;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
    position: relative;
    transition: transform 0.2s ease;
}

.timeline-bar:hover {
    transform: scale(1.02);
}

.timeline-segment {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.75em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    border-right: 1px solid rgba(255,255,255,0.3);
    transition: all 0.2s ease;
}

.timeline-segment:hover {
    filter: brightness(1.1);
}

.timeline-segment:last-child {
    border-right: none;
}

.timeline-gap {
    background: #f0f0f0;
    color: #999;
}

.intensity-high { background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%); }
.intensity-medium-high { background: linear-gradient(135deg, #fd9801 0%, #e68900 100%); }
.intensity-medium { background: linear-gradient(135deg, #fbd38d 0%, #f6ad55 100%); }
.intensity-low { background: linear-gradient(135deg, #9ae6b4 0%, #68d391 100%); }
.intensity-lingering { background: linear-gradient(135deg, #bee3f8 0%, #90cdf4 100%); }

.topic-a-segment { border-top: 3px solid #4CAF50; }
.topic-b-segment { border-bottom: 3px solid #2196F3; }

.overlap-indicator {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid #FF6B6B;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #FF6B6B;
    font-size: 0.8em;
}

.search-links {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.search-link {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
    text-decoration: none;
    border-radius: 25px;
    font-weight: bold;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.search-link::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    transition: all 0.3s ease;
    transform: translate(-50%, -50%);
}

.search-link:hover::before {
    width: 200%;
    height: 200%;
}

.search-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.search-link.news {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
}

.search-link.combined {
    background: linear-gradient(135deg, #4CAF50 0%, #2196F3 100%);
}

.no-results {
    text-align: center;
    color: #666;
    padding: 60px 40px;
    font-size: 1.1em;
}

.no-results h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.5em;
}

.no-results p {
    line-height: 1.6;
    margin-bottom: 10px;
}

.footer {
    text-align: center;
    padding: 30px;
    color: #666;
    border-top: 1px solid #eee;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.footer p {
    margin-bottom: 10px;
}

.footer a {
    color: #FF6B6B;
    text-decoration: none;
    font-weight: bold;
}

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

@media (max-width: 768px) {
    .dual-search {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .search-input-wrapper {
        flex-direction: column;
        gap: 10px;
    }
    
    .related-btn {
        width: 100%;
        justify-content: center;
    }
    
    .time-range-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .search-links {
        flex-direction: column;
        align-items: center;
    }
    
    .topic-legend {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .header h1 {
        font-size: 2em;
    }
    
    .container {
        margin: 10px;
        border-radius: 10px;
    }
    
    .related-modal-content {
        width: 95%;
        margin: 10% auto;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .header {
        padding: 20px;
    }
    
    .related-text {
        display: none;
    }
    
    .related-btn {
        padding: 12px 15px;
    }
}