/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --bg-dark: #1a1a2e;
    --bg-medium: #16213e;
    --bg-light: #0f3460;
    --text-primary: #eee;
    --text-secondary: #aaa;
    --border-color: #333;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --error-color: #f44336;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-medium) 100%);
    color: var(--text-primary);
    overflow: hidden;
}

/* App Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.app-header {
    background: var(--bg-medium);
    border-bottom: 2px solid var(--border-color);
    box-shadow: var(--shadow);
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    max-width: 100%;
}

.app-header h1 {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* Connection Status */
.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-light);
    border-radius: 20px;
    font-size: 0.875rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--error-color);
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: var(--success-color);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--bg-medium);
    border-right: 2px solid var(--border-color);
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-section {
    background: var(--bg-light);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.sidebar-section h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

/* Search Box */
.search-box {
    display: flex;
    gap: 0.5rem;
}

.search-input {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-dark);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Filters */
.filter-group {
    margin-bottom: 1rem;
}

.filter-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.filter-group input[type="range"] {
    width: 100%;
    margin-right: 0.5rem;
}

.filter-group input[type="number"] {
    width: 100%;
    padding: 0.5rem;
    background: var(--bg-dark);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
}

#similarity-value {
    font-weight: bold;
    color: var(--accent-color);
}

/* Statistics */
.stats {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg-dark);
    border-radius: 8px;
}

.stat-label {
    color: var(--text-secondary);
}

.stat-value {
    font-weight: bold;
    color: var(--accent-color);
}

/* Metadata Panel */
#metadata-content {
    margin-bottom: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

.metadata-item {
    padding: 0.75rem;
    background: var(--bg-dark);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.metadata-item strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 0.25rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    background: var(--bg-medium);
}

.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--bg-light);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--primary-color);
    transform: scale(1.1);
}

/* Graph Container */
.graph-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#graph-canvas {
    width: 100%;
    height: 100%;
}

.graph-controls {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 26, 46, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 5rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    background: var(--bg-medium);
    border-left: 4px solid var(--primary-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease-out;
    min-width: 250px;
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.error {
    border-left-color: var(--error-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Graph Styles */
.node {
    cursor: pointer;
    stroke: var(--bg-dark);
    stroke-width: 2px;
    transition: all 0.3s;
}

.node:hover {
    stroke: var(--accent-color);
    stroke-width: 3px;
}

.node.selected {
    stroke: var(--primary-color);
    stroke-width: 4px;
}

.node.highlighted {
    stroke: var(--success-color);
    stroke-width: 3px;
}

.link {
    stroke: var(--border-color);
    stroke-opacity: 0.6;
    stroke-width: 1.5px;
}

.link.highlighted {
    stroke: var(--primary-color);
    stroke-opacity: 1;
    stroke-width: 2.5px;
}

.node-label {
    font-size: 11px;
    fill: var(--text-primary);
    text-anchor: middle;
    pointer-events: none;
    user-select: none;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }

    .header-content {
        padding: 1rem;
    }

    .app-header h1 {
        font-size: 1.2rem;
    }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 2px solid var(--border-color);
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .header-controls {
        width: 100%;
        justify-content: space-between;
    }

    .graph-controls {
        bottom: 1rem;
        right: 1rem;
    }

    #toast-container {
        right: 1rem;
        left: 1rem;
    }

    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .sidebar {
        padding: 1rem;
    }

    .sidebar-section {
        padding: 1rem;
    }

    .app-header h1 {
        font-size: 1rem;
    }

    .btn-icon {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}
