/* Modern Chat-Centric Design */
:root {
    --bg-dark: #0f0f1e;
    --bg-sidebar: #16162a;
    --bg-chat: #0f0f1e;
    --bg-panel: #16162a;

    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --surface: rgba(255, 255, 255, 0.05);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.1);

    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);

    --success: #10b981;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* --- Sidebar --- */
.sidebar {
    width: 320px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 2rem;
    flex-shrink: 0;
}

.sidebar-header {
    text-align: center;
    margin-bottom: 2rem;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
    overflow: hidden;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-name {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.profile-title {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: var(--surface);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
}

.profile-bio {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    text-align: center;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.social-link {
    width: 40px;
    height: 40px;
    background: var(--surface);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s;
    border: 1px solid var(--border);
}

.social-link:hover {
    background: var(--surface-hover);
    color: white;
    transform: translateY(-2px);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
}

/* --- Mode Selector --- */
.mode-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--surface);
    padding: 0.25rem;
    border-radius: var(--radius-md);
}

.mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn.active {
    background: var(--primary-gradient);
    color: white;
    font-weight: 600;
}

/* --- Main Chat Area --- */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-chat);
    position: relative;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.message {
    display: flex;
    gap: 1rem;
    animation: fadeIn 0.3s ease;
}

.message-avatar {
    width: 36px;
    height: 36px;
    background: var(--surface);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-content {
    flex: 1;
    max-width: 80%;
}

.message-content p {
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.bot-message .message-content {
    color: var(--text-secondary);
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-avatar {
    background: var(--primary-gradient);
}

.user-message .message-content {
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--radius-md);
    border-bottom-right-radius: 2px;
}

/* Suggestion Chips */
.suggestion-chips {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.chip {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chip:hover {
    background: var(--surface);
    border-color: rgba(102, 126, 234, 0.5);
    color: white;
}

/* Chat Input */
.chat-input-container {
    padding: 2rem;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.chat-input-form {
    position: relative;
}

.chat-input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 1rem 3.5rem 1rem 3.5rem;
    border-radius: var(--radius-lg);
    color: white;
    font-size: 1rem;
    transition: all 0.2s;
}

.chat-input:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.5);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.chat-attach-btn {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}

.chat-attach-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.chat-send-btn {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary-gradient);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-send-btn:hover {
    opacity: 0.9;
    transform: translateY(-50%) scale(1.05);
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.link-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.empty-icon {
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Animations */
@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-4px);
    }
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
    align-items: center;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

/* --- Reference Panel --- */
.reference-panel {
    width: 300px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

/* --- Node Details Panel (Graph Mode) --- */
.details-panel {
    width: 300px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100%;
    overflow: hidden;
    transition: transform 0.3s ease;
}

/* Hamburger Menu Button (Default/Desktop) */
.menu-btn {
    display: none;
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    z-index: 100;
}

/* Mobile Overlay (Default/Desktop) */
.mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Responsive */
@media (max-width: 1024px) {
    .reference-panel {
        display: none;
        /* Hide right panel on smaller screens */
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 280px;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    }

    .sidebar.active {
        display: flex;
        /* Ensure it's visible when active */
        transform: translateX(0);
    }

    .chat-area {
        padding-top: 60px;
        /* Space for menu button */
    }

    .menu-btn {
        display: flex;
        /* Show on mobile */
    }

    .mobile-overlay.active {
        opacity: 1;
        pointer-events: all;
    }

    /* Mobile Chat Input */
    .chat-input-container {
        padding: 1rem;
    }

    .chat-input {
        padding: 0.8rem 3rem 0.8rem 3.5rem;
        font-size: 16px;
    }

    .chat-attach-btn {
        left: 0.5rem;
        padding: 0.25rem;
    }

    .chat-send-btn {
        right: 0.5rem;
        width: 32px;
        height: 32px;
    }

    /* Mobile Graph Controls */
    .graph-controls {
        top: 1rem;
        left: 1rem;
        right: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .graph-legend {
        max-width: 100%;
        overflow-x: auto;
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    /* Mobile Node Details (Bottom Sheet) */
    .details-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        height: 50vh;
        /* Half screen */
        border-left: none;
        border-top: 1px solid var(--border);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        z-index: 50;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    }

    .details-panel.active {
        display: flex !important;
        transform: translateY(0);
    }
}