/* ===== White Theme - Matching Website ===== */
:root {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f0f0;
    --bg-hover: #e5e5e5;
    --text-primary: #1a1a1a;
    --text-secondary: #525252;
    --text-muted: #737373;
    --accent: #7ee787;
    --accent-hover: #6bd476;
    --border: #e5e5e5;
    --link: #2563eb;
    --tag-bg: #dbeafe;
    --tag-text: #1e40af;
    --danger: #dc2626;
    --warning: #ca8a04;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
}

#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* ===== Login Screen ===== */
#login-screen {
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.login-container {
    text-align: center;
    padding: 3rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    max-width: 400px;
    width: 90%;
}

.login-container h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 600;
}

.login-container p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* ===== Buttons ===== */
.btn-primary, .btn-secondary, .btn-danger {
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    width: 100%;
    margin-bottom: 0.75rem;
}

.btn-primary {
    background: #1a1a1a;
    color: white;
}

.btn-primary:hover {
    background: #333;
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ===== Header ===== */
.header {
    height: 64px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.vault-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.search-box {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.search-box input {
    width: 100%;
    padding: 0.625rem 1rem 0.625rem 2.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
}

.search-box input:focus {
    outline: none;
    border-color: #1a1a1a;
}

.search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

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

/* ===== Sidebar ===== */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar.collapsed {
    width: 0;
    padding: 0;
    overflow: hidden;
}

.sidebar-section {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.875rem;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* File Tree */
.file-tree {
    font-size: 0.9rem;
}

.file-tree ul {
    list-style: none;
}

.file-tree li {
    margin: 0;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    cursor: pointer;
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.tree-item:hover {
    background: var(--bg-hover);
}

.tree-item.active {
    background: var(--tag-bg);
    color: var(--tag-text);
}

.tree-toggle {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.tree-children {
    padding-left: 1.25rem;
}

.tree-children.collapsed {
    display: none;
}

/* Tags */
.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    padding: 0.25rem 0.75rem;
    background: var(--tag-bg);
    color: var(--tag-text);
    border-radius: 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.tag:hover {
    opacity: 0.8;
}

/* Backlinks */
.backlinks-list {
    font-size: 0.85rem;
}

.backlink-item {
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 6px;
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
}

.backlink-item:hover {
    background: var(--bg-hover);
}

/* ===== Editor Container ===== */
.editor-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.empty-state-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.empty-state-content {
    text-align: center;
}

.empty-state-content svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-content h2 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

/* ===== Note Editor ===== */
.note-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
}

.breadcrumbs {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.breadcrumbs span:not(:last-child)::after {
    content: ' / ';
    margin: 0 0.25rem;
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
}

.editor-actions button {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* View Mode */
.view-mode {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.markdown-content {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-secondary);
    padding: 2.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

/* Markdown Styles */
.markdown-content h1, 
.markdown-content h2, 
.markdown-content h3, 
.markdown-content h4, 
.markdown-content h5, 
.markdown-content h6 {
    color: var(--text-primary);
    margin: 1.5rem 0 1rem;
    font-weight: 600;
}

.markdown-content h1 { 
    font-size: 2rem; 
    border-bottom: 1px solid var(--border); 
    padding-bottom: 0.5rem; 
}
.markdown-content h2 { font-size: 1.5rem; }
.markdown-content h3 { font-size: 1.25rem; }

.markdown-content p {
    margin: 1rem 0;
    color: var(--text-secondary);
}

.markdown-content a {
    color: var(--link);
    text-decoration: none;
}

.markdown-content a:hover {
    text-decoration: underline;
}

.markdown-content code {
    background: var(--bg-tertiary);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.9em;
    color: var(--text-primary);
}

.markdown-content pre {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
    border: 1px solid var(--border);
}

.markdown-content pre code {
    background: none;
    padding: 0;
}

.markdown-content blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-muted);
    font-style: italic;
}

.markdown-content ul, .markdown-content ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.markdown-content li {
    margin: 0.25rem 0;
}

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.markdown-content th, .markdown-content td {
    padding: 0.75rem;
    border: 1px solid var(--border);
    text-align: left;
}

.markdown-content th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.markdown-content img {
    max-width: 100%;
    border-radius: 8px;
    margin: 1rem 0;
}

.markdown-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

/* Wiki Links */
.wiki-link {
    color: var(--link);
    background: var(--tag-bg);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.wiki-link:hover {
    background: #bfdbfe;
}

.wiki-link.unresolved {
    color: var(--danger);
    background: #fee2e2;
}

/* Tags in content */
.tag-link {
    color: var(--tag-text);
    background: var(--tag-bg);
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-size: 0.85em;
    cursor: pointer;
}

/* Edit Mode */
.edit-mode {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1.5rem;
}

.metadata-editor {
    background: var(--bg-secondary);
    padding: 1.25rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

.metadata-editor input,
.metadata-editor textarea {
    width: 100%;
    padding: 0.625rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.metadata-editor textarea {
    min-height: 80px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    resize: vertical;
}

#note-body {
    flex: 1;
    padding: 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.6;
    resize: none;
    outline: none;
}

#note-body:focus {
    border-color: #1a1a1a;
}

/* ===== Modals ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 1.5rem;
    min-width: 400px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal-content h2 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.modal-content input {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.modal-content input:focus {
    outline: none;
    border-color: #1a1a1a;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.modal-actions button {
    width: auto;
    padding: 0.625rem 1.25rem;
}

/* Search Modal */
.search-modal-content {
    width: 600px;
    max-height: 70vh;
}

.search-header {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-header input {
    flex: 1;
    margin-bottom: 0;
    font-size: 1.1rem;
}

.search-results {
    overflow-y: auto;
    max-height: 50vh;
}

.search-result {
    padding: 0.875rem;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 0.5rem;
    border: 1px solid transparent;
}

.search-result:hover {
    background: var(--bg-tertiary);
    border-color: var(--border);
}

.search-result-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.search-result-context {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 1rem;
    background: var(--bg-tertiary);
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: #1a1a1a;
    color: var(--text-primary);
    background: var(--bg-hover);
}

.drop-zone input {
    display: none;
}

/* Sync Status */
.sync-status {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 100;
    font-size: 0.875rem;
}

.sync-status.success {
    border-color: var(--accent);
    background: #f0fdf4;
}

.sync-status.error {
    border-color: var(--danger);
    background: #fef2f2;
}

/* Status Messages */
.status {
    margin-top: 1rem;
    font-size: 0.9rem;
}

.status.success {
    color: #166534;
}

.status.error {
    color: var(--danger);
}

/* Empty States */
.empty-state {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

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

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

::-webkit-scrollbar-thumb {
    background: #d4d4d4;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a3a3a3;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 64px;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .header-center {
        display: none;
    }
    
    .view-mode {
        padding: 1rem;
    }
    
    .markdown-content {
        padding: 1.5rem;
    }
}
