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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}

#app {
    position: relative;
    width: 100%;
    height: 100vh;
}

/* Search container styles */
.search-container {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
}

.search-container.centered {
    transform: translateY(0);
}

.search-container.moved-up {
    transform: translateY(-40vh);
}

.search-wrapper {
    text-align: center;
    max-width: 600px;
    width: 90%;
}

.app-title {
    font-size: 3rem;
    font-weight: 300;
    color: white;
    margin-bottom: 2rem;
    opacity: 1;
    transition: opacity 0.4s ease;
}

.app-title.fade-out {
    opacity: 0;
}

/* Search input styles */
.search-input-wrapper {
    position: relative;
    margin-bottom: 0;
    z-index: 100;
}

.search-input-wrapper input {
    width: 100%;
    padding: 1rem 3rem 1rem 1.5rem;
    font-size: 1.1rem;
    border: none;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    outline: none;
    transition: all 0.3s ease;
}

.search-input-wrapper input:focus {
    background: white;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.search-input-wrapper button {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: #667eea;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-input-wrapper button:hover {
    background: #5a6fd8;
    transform: translateY(-50%) scale(1.05);
}

/* Top search bar styles */
.search-bar-top {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.search-bar-top.visible {
    opacity: 1;
}

.search-bar-top .search-input-wrapper {
    position: relative;
    width: 300px;
    height: 50px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: visible;
}

.search-bar-top .search-input-wrapper.collapsed {
    width: 50px;
    overflow: hidden;
}

.search-bar-top .search-input-wrapper.collapsed:hover,
.search-bar-top .search-input-wrapper.collapsed:focus-within {
    width: 300px;
    overflow: visible;
}

.search-bar-top .search-input-wrapper input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    font-size: 1rem;
    padding: 0 50px 0 15px;
    border: none;
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    outline: none;
    opacity: 1;
    transition: opacity 0.2s ease;
    pointer-events: all;
}

.search-bar-top .search-input-wrapper.collapsed input {
    opacity: 0;
    pointer-events: all;
}

.search-bar-top .search-input-wrapper.collapsed:hover input,
.search-bar-top .search-input-wrapper.collapsed:focus-within input {
    opacity: 1;
    pointer-events: all;
    transition: opacity 0.2s ease 0.1s;
}

.search-bar-top .search-input-wrapper button {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 35px;
    height: 35px;
    border: none;
    border-radius: 50%;
    background: #667eea;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.search-bar-top .search-input-wrapper button:hover {
    background: #5a6fd8;
    transform: translateY(-50%) scale(1.05);
}

/* Collapsed state - show only the icon */
.search-bar-top .search-input-wrapper.collapsed::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    transition: opacity 0.2s ease;
    z-index: 5;
}

.search-bar-top .search-input-wrapper.collapsed:hover::before,
.search-bar-top .search-input-wrapper.collapsed:focus-within::before {
    opacity: 0;
}

/* Suggestions styles */
.suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1001;
    display: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Top search bar suggestions - special positioning */
.search-bar-top .suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 300px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1002;
    display: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Show suggestions when search bar is expanded and has visible class */
.search-bar-top .suggestions.visible {
    display: block;
    animation: fadeInUp 0.2s ease-out;
}

.suggestions.visible {
    display: block;
    animation: fadeInUp 0.2s ease-out;
}

/* Override animation for top search bar suggestions */
.search-bar-top .suggestions.visible {
    display: block;
    animation: none; /* Use the transform-based animation instead */
}

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

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.suggestion-item:hover {
    background-color: #f8f9fa;
    border-radius: 8px;
    margin: 2px 4px;
    border-bottom: 1px solid #f0f0f0;
}

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

.suggestion-item:first-child {
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.suggestion-item:last-child {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.suggestion-title {
    font-weight: 500;
    color: #333;
    font-size: 0.95rem;
}

.suggestion-description {
    font-size: 0.85rem;
    color: #666;
    margin-top: 2px;
    line-height: 1.3;
    max-height: 2.6em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Graph container styles */
.graph-container {
    position: absolute;
    width: 100%;
    height: 100%;
    background: #1a1a2e;
    transition: opacity 0.6s ease;
    display: flex;
    flex-direction: column;
}

.graph-container.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Split layout container */
.content-container {
    display: flex;
    flex: 1;
    height: calc(100% - 80px); /* Account for search bar height */
}

/* Left panel: Graph */
.graph-panel {
    flex: 0 0 60%;
    position: relative;
    border-right: 2px solid rgba(255, 255, 255, 0.1);
}

.graph {
    width: 100%;
    height: 100%;
    position: relative;
}

/* Right panel: Article preview */
.article-panel {
    flex: 1;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    overflow-y: auto;
}

.article-content {
    padding: 2rem;
    height: 100%;
    color: #333;
}

.article-placeholder {
    text-align: center;
    color: #666;
    margin-top: 2rem;
}

.article-placeholder h3 {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.article-title {
    font-size: 2rem;
    font-weight: bold;
    color: #1a1a2e;
    margin-bottom: 1rem;
    border-bottom: 2px solid #667eea;
    padding-bottom: 0.5rem;
}

.article-extract {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #444;
    margin-bottom: 1.5rem;
}

.article-link {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.3s ease;
}

.article-link:hover {
    background: #5a6fd8;
}

.article-image {
    margin: 16px 0;
    text-align: center;
}

.article-image img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    object-fit: cover;
    transition: transform 0.3s ease;
}

.article-image img:hover {
    transform: scale(1.02);
}

/* Loading styles */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    z-index: 100;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Graph node styles */
.node {
    cursor: pointer;
}

.node-circle {
    fill: #667eea;
    stroke: #fff;
    stroke-width: 2px;
    transition: fill 0.2s ease, stroke-width 0.2s ease, r 0.2s ease;
}

.node-circle.central {
    fill: #ff6b6b;
    stroke-width: 3px;
}

.node-circle:hover {
    fill: #5a6fd8;
    stroke-width: 3px;
}

.node-text {
    fill: white;
    text-anchor: middle;
    dominant-baseline: middle;
    font-size: 12px;
    font-weight: 500;
    pointer-events: none;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.node-text.central {
    font-size: 14px;
    font-weight: 600;
}

/* Graph link styles */
.link {
    stroke: rgba(255, 255, 255, 0.3);
    stroke-width: 2px;
    transition: all 0.3s ease;
}

.link:hover {
    stroke: rgba(255, 255, 255, 0.6);
    stroke-width: 3px;
}

/* Responsive design */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
        height: 100vh;
    }
    
    .graph-container {
        width: 100% !important;
        height: 100vh !important;
        order: 2;
    }
    
    .content-container {
        flex-direction: column !important;
        height: calc(100vh - 80px) !important;
    }
    
    .graph-panel {
        flex: 0 0 50% !important;
        order: 2;
        border-right: none;
        border-bottom: 2px solid rgba(255, 255, 255, 0.1);
        min-height: 0;
    }
    
    .article-panel {
        flex: 0 0 50% !important;
        order: 1;
        position: relative;
        right: auto;
        top: auto;
        min-height: 0;
        display: flex !important;
        flex-direction: column;
    }
    
    .article-content {
        flex: 1;
        overflow-y: auto;
        padding: 1rem;
    }
    
    .app-title {
        font-size: 2rem;
    }
    
    .search-input-wrapper input {
        font-size: 1rem;
        padding: 0.8rem 2.5rem 0.8rem 1.2rem;
    }
    
    .search-input-wrapper button {
        width: 35px;
        height: 35px;
        right: 6px;
    }
    
    .node-text {
        font-size: 10px;
    }
    
    .node-text.central {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .app-title {
        font-size: 1.5rem;
    }
    
    .search-wrapper {
        width: 95%;
    }
}

/* Theme Switcher Styles */
.theme-switcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.theme-button {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    color: #667eea;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.theme-button:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.05);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.theme-dropdown {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    min-width: 150px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-dropdown.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.theme-dropdown-header {
    padding: 12px 16px 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.theme-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.theme-option:hover {
    background: rgba(102, 126, 234, 0.1);
}

.theme-option:last-child {
    border-radius: 0 0 12px 12px;
}

.theme-name {
    font-size: 0.9rem;
    color: #333;
    font-weight: 500;
}

.theme-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Dark Theme Styles */
body.dark-theme {
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
}

.dark-theme .main-container {
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
}

.dark-theme .app-title {
    color: #e2e8f0;
}

.dark-theme .app-subtitle {
    color: #a0aec0;
}

.dark-theme .search-input-wrapper {
    background: rgba(45, 55, 72, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.dark-theme .search-input-wrapper input {
    background: rgba(45, 55, 72, 0.95);
    color: #e2e8f0;
}

.dark-theme .search-input-wrapper input::placeholder {
    color: #a0aec0;
}

.dark-theme .search-input-wrapper button {
    background: #4a5568;
    color: #e2e8f0;
}

.dark-theme .search-input-wrapper button:hover {
    background: #2d3748;
}

.dark-theme .suggestions {
    background: rgba(45, 55, 72, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.dark-theme .suggestion-item {
    color: #e2e8f0;
}

.dark-theme .suggestion-item:hover {
    background: rgba(74, 85, 104, 0.5);
}

.dark-theme .suggestion-title {
    color: #e2e8f0;
}

.dark-theme .suggestion-description {
    color: #a0aec0;
}

.dark-theme .graph-container {
    background: #1a202c;
}

.dark-theme .article-panel {
    background: rgba(45, 55, 72, 0.95);
}

.dark-theme .article-content {
    color: #e2e8f0;
}

.dark-theme .article-placeholder {
    color: #a0aec0;
}

.dark-theme .article-placeholder h3 {
    color: #e2e8f0;
}

.dark-theme .article-title {
    color: #e2e8f0;
    border-bottom-color: #4a5568;
}

.dark-theme .article-extract {
    color: #cbd5e0;
}

.dark-theme .article-link {
    background: #4a5568;
    color: #e2e8f0;
}

.dark-theme .article-link:hover {
    background: #2d3748;
}

.dark-theme .theme-button {
    background: rgba(45, 55, 72, 0.95);
    color: #e2e8f0;
}

.dark-theme .theme-button:hover {
    background: rgba(45, 55, 72, 1);
}

.dark-theme .theme-dropdown {
    background: rgba(45, 55, 72, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.dark-theme .theme-dropdown-header {
    color: #e2e8f0;
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.dark-theme .theme-name {
    color: #e2e8f0;
}

.dark-theme .theme-option:hover {
    background: rgba(74, 85, 104, 0.3);
}

/* Dark theme graph node styles */
.dark-theme .node-circle {
    fill: #4a5568;
    stroke: #e2e8f0;
}

.dark-theme .node-circle.central {
    fill: #e53e3e;
    stroke: #e2e8f0;
}

.dark-theme .node-text {
    fill: #e2e8f0;
}

.dark-theme .link {
    stroke: #a0aec0 !important;
}

/* Dark theme article image styles */
.dark-theme .article-image img {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
