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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left h1 {
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
}

.header-left p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Session Controls in Left Panel */
.session-controls-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.session-toggle-left {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
}

.session-toggle-left input[type="checkbox"] {
    display: none;
}

.toggle-slider-left {
    width: 36px;
    height: 18px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 9px;
    position: relative;
    transition: background-color 0.3s;
}

.toggle-slider-left::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

.session-toggle-left input:checked + .toggle-slider-left {
    background: #667eea;
}

.session-toggle-left input:checked + .toggle-slider-left::after {
    transform: translateX(18px);
}

.toggle-label-left {
    color: #374151;
    font-size: 0.8rem;
    font-weight: 500;
}

.session-info-left {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(102, 126, 234, 0.1);
    padding: 0.3rem 0.6rem;
    border-radius: 12px;
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.session-info-left.hidden {
    display: none;
}

.session-name-left {
    color: #374151;
    font-size: 0.8rem;
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-dropdown-btn-left {
    background: none;
    border: none;
    color: #374151;
    cursor: pointer;
    font-size: 0.7rem;
    padding: 0;
}

/* Session Dropdown */
.session-dropdown {
    position: fixed;
    top: 70px;
    right: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 300px;
    max-height: 400px;
    overflow: hidden;
    z-index: 1000;
}

.session-dropdown.hidden {
    display: none;
}

.session-dropdown-header {
    padding: 1rem;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.session-dropdown-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #374151;
}

.session-new-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
}

.session-new-btn:hover {
    background: #5a67d8;
}

.session-list {
    max-height: 320px;
    overflow-y: auto;
}

.session-item {
    padding: 1rem;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background-color 0.2s;
}

.session-item:hover {
    background: #f9fafb;
}

.session-item.active {
    background: #f0f2ff;
}

.session-item-name {
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.25rem;
}

.session-item-meta {
    font-size: 0.85rem;
    color: #6b7280;
}

.no-sessions {
    padding: 2rem;
    text-align: center;
    color: #9ca3af;
    font-size: 0.9rem;
}

.user-info {
    color: white;
    font-size: 0.9rem;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.main-container {
    flex: 1;
    display: flex;
    padding: 1rem;
    gap: 1rem;
    width: 100%;
}

.chat-section {
    width: 38%;
    min-width: 320px;
    max-width: 680px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-input-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.input-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    background: #f0f2f5;
    padding: 0.25rem;
    border-radius: 10px;
}

.tab-button {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab-button.active {
    background: white;
    color: #667eea;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.tab-button:hover:not(.active):not(.disabled) {
    background: rgba(255, 255, 255, 0.5);
}

.tab-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(0, 0, 0, 0.1);
    color: #999;
}



.chat-input-form {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.chat-input {
    flex: 1;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    resize: none;
    min-height: 50px;
    max-height: 150px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.chat-input:focus {
    outline: none;
    border-color: #667eea;
}

.chat-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.chat-button:hover {
    transform: translateY(-1px);
}

.chat-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.chat-messages {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.25rem;
    flex: 1;
    overflow-y: auto;
    min-height: 400px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.message {
    padding: 1rem;
    border-radius: 10px;
}

.message.user {
    background: #f0f2ff;
    align-self: flex-start;
    max-width: 90%;
}

.message.assistant {
    background: #f8fafc;
    align-self: flex-start;
    max-width: 90%;
}

.message-header {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #374151;
}

.message-content {
    color: #4b5563;
    line-height: 1.5;
}

/* Formatting for structured chat messages */
.message-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #374151;
    margin: 1rem 0 0.5rem 0;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.25rem;
}

.message-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
    counter-reset: item;
}

.message-content ol li {
    display: block;
    margin-bottom: 0.5rem;
    position: relative;
    counter-increment: item;
}

.message-content ol li:before {
    content: counter(item) ". ";
    font-weight: 600;
    color: #6366f1;
}

.message-content p {
    margin: 0.5rem 0;
}

.message-content strong {
    font-weight: 600;
    color: #374151;
}

.map-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.thought-map {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    flex: 1;
    min-height: 500px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    position: relative;
    display: flex;
    flex-direction: column;
}

.map-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #374151;
    flex-shrink: 0;
}

#thoughtMap {
    flex: 1;
    position: relative;
}

.insights-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.insights-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #374151;
}

.insight-item {
    background: #f8fafc;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-left: 3px solid #667eea;
}

.loading {
    text-align: center;
    color: #6b7280;
    font-style: italic;
}

.empty-state {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: #9ca3af;
    font-style: italic;
    text-align: center;
}

/* Authentication Modal Styles */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.auth-modal {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 1.5rem;
    color: #374151;
}

.auth-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.auth-tab {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    background: white;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-input {
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.auth-input:focus {
    outline: none;
    border-color: #667eea;
}

.auth-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.auth-button:hover {
    transform: translateY(-1px);
}

.auth-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.auth-error {
    background: #fee2e2;
    color: #dc2626;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.hidden {
    display: none;
}

/* D3 Graph Styles */
#thoughtMap svg {
    width: 100%;
    height: 100%;
}

.graph-node {
    cursor: pointer;
    stroke-width: 2px;
    stroke: #fff;
}

.graph-node:hover {
    stroke-width: 3px;
    stroke: #333;
}

.graph-link {
    stroke: #999;
    stroke-opacity: 0.6;
    stroke-width: 2px;
}

.graph-link:hover {
    stroke: #333;
    stroke-opacity: 0.8;
    stroke-width: 3px;
}

.graph-label {
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    fill: #333;
    text-anchor: middle;
    pointer-events: none;
    user-select: none;
}

.graph-link-label {
    font-family: inherit;
    font-size: 9px;
    fill: #666;
    text-anchor: middle;
    pointer-events: none;
    user-select: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.graph-link:hover + .graph-link-label,
.graph-link-label:hover {
    opacity: 1;
}

/* Thoughts list styles */
.thoughts-list {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.thoughts-list.active {
    display: flex;
}

#thoughtsContainer {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-right: 0.5rem;
}

/* Custom scrollbar for thoughts container */
#thoughtsContainer::-webkit-scrollbar {
    width: 6px;
}

#thoughtsContainer::-webkit-scrollbar-track {
    background: transparent;
}

#thoughtsContainer::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

#thoughtsContainer::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.thought-item {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 12px;
    padding: 1.25rem;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.thought-item:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-1px);
}

.thought-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.thought-date {
    font-size: 0.85rem;
    color: #666;
}

.thought-meta {
    font-size: 0.85rem;
    color: #999;
}

.thought-content {
    color: #333;
    line-height: 1.6;
    word-wrap: break-word;
    max-height: 120px;
    overflow-y: auto;
    margin-top: 0.75rem;
    font-size: 0.95rem;
}

.thought-content.expanded {
    max-height: none;
}

/* Session formatting styles */
.session-header {
    font-weight: bold;
    color: #2c3e50;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
    margin-bottom: 15px;
}

.session-messages {
    padding-left: 10px;
}

.session-message {
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: 5px;
    line-height: 1.5;
}

.session-message.user-message {
    background: #e8f4f8;
    border-left: 3px solid #3498db;
}

.session-message.assistant-message {
    background: #f0f8f0;
    border-left: 3px solid #27ae60;
}

.message-role {
    font-weight: bold;
    color: #2c3e50;
}

.message-text {
    color: #34495e;
}

.expand-button {
    background: none;
    border: none;
    color: #667eea;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0;
    margin-top: 0.5rem;
}

.expand-button:hover {
    text-decoration: underline;
}

.thoughts-search {
    margin-bottom: 1rem;
}

.thoughts-search input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #e1e5e9;
    border-radius: 10px;
    font-size: 0.95rem;
    transition: all 0.2s;
    background: #f8fafc;
}

.thoughts-search input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.thoughts-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e1e5e9;
}

.pagination-button {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-button:hover:not(:disabled) {
    border-color: #667eea;
    background: #f8fafc;
}

.pagination-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 0.9rem;
    color: #666;
}

.no-thoughts {
    text-align: center;
    padding: 3rem 2rem;
    color: #999;
    font-size: 0.95rem;
}

.loading-thoughts {
    text-align: center;
    padding: 2rem;
    color: #667eea;
    font-size: 0.95rem;
}

/* Authentication notification */
.auth-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    animation: slideDown 0.3s ease-out, slideUp 0.3s ease-out 3.5s;
    animation-fill-mode: forwards;
}

.notification-content {
    background: #fee2e2;
    color: #dc2626;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.notification-icon {
    font-size: 1.2rem;
}

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

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
    to {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
}

/* Toast notifications */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.toast.toast-success {
    background: rgba(34, 197, 94, 0.9);
}

.toast.toast-error {
    background: rgba(239, 68, 68, 0.9);
}

.toast.toast-info {
    background: rgba(59, 130, 246, 0.9);
}

.toast.toast-warning {
    background: rgba(245, 158, 11, 0.9);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Graph node tooltip styles */
.graph-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.4;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateY(-10px);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    max-width: 250px;
}

.graph-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.graph-tooltip-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
    color: #ffffff;
}

.graph-tooltip-type {
    font-size: 0.75rem;
    color: #cbd5e1;
    margin-bottom: 8px;
    text-transform: capitalize;
}

.graph-tooltip-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.graph-tooltip-tag {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.graph-tooltip-no-tags {
    color: #9ca3af;
    font-style: italic;
    font-size: 0.75rem;
}

/* Zoom controls */
.zoom-controls {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 10;
}

.zoom-btn {
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
    cursor: pointer;
}

.zoom-btn:hover {
    background: rgba(0,0,0,0.8);
}

@media (max-width: 1024px) {
    .main-container {
        flex-direction: column;
        padding: 1rem;
    }
    
    .chat-section, .map-section {
        flex: none;
    }
    
    .graph-tooltip {
        font-size: 0.8rem;
        padding: 10px 12px;
        max-width: 200px;
    }
} 