:root {
  --sidebar-width: 280px;
  --header-height: 60px;
  --font-sans: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --border-color: rgba(0, 0, 0, 0.08);
  --sidebar-bg: #fbfbfb;
  --sidebar-bg-hover: rgba(0, 0, 0, 0.04);
  --sidebar-active-bg: rgba(0, 0, 0, 0.06);
  --sidebar-active-color: #000;
  --accent-color: #0d6efd;
}

[data-bs-theme="dark"] {
  --border-color: rgba(255, 255, 255, 0.1);
  --sidebar-bg: #1e1e1e;
  --sidebar-bg-hover: rgba(255, 255, 255, 0.05);
  --sidebar-active-bg: rgba(255, 255, 255, 0.1);
  --sidebar-active-color: #fff;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bs-body-bg);
  height: 100vh;
  overflow: hidden;
}

/* App Layout */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--bs-body-bg);
}

.top-bar {
  height: var(--header-height);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bs-body-bg);
  z-index: 1000;
}

.editor-container {
  flex: 1;
  overflow-y: auto;
  position: relative;
  padding: 0 2rem 2rem;
}

.editor-wrapper {
  max-width: 900px;
  margin: 0 auto;
  padding-top: 2rem;
  padding-bottom: 4rem;
}

/* Editor Styling */
#richTextEditor {
  min-height: 60vh;
  outline: none;
  font-size: 1.1rem;
  line-height: 1.7;
}

#richTextEditor h1 { font-weight: 700; margin-top: 2rem; margin-bottom: 1rem; }
#richTextEditor h2 { font-weight: 600; margin-top: 1.5rem; margin-bottom: 0.75rem; }
#richTextEditor p { margin-bottom: 1rem; }
#richTextEditor ul, #richTextEditor ol { margin-bottom: 1rem; padding-left: 1.5rem; }
#richTextEditor blockquote {
  border-left: 3px solid var(--border-color);
  padding-left: 1rem;
  color: var(--bs-secondary-color);
  font-style: italic;
}
#richTextEditor img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1rem 0;
}

/* Floating Toolbar */
.floating-toolbar {
  position: sticky;
  top: 1rem;
  z-index: 100;
  background-color: var(--bs-body-bg);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  padding: 0.25rem 0.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  margin-bottom: 1.5rem;
  display: inline-flex;
  gap: 0.25rem;
  align-self: center;
}

[data-bs-theme="dark"] .floating-toolbar {
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.toolbar-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--bs-body-color);
  border: none;
  background: transparent;
  transition: background-color 0.2s;
}

.toolbar-btn:hover {
  background-color: var(--bs-tertiary-bg);
}

.toolbar-btn.active {
  background-color: var(--accent-color);
  color: white;
}

/* Tree Nodes */
.tree-node-content {
  display: flex;
  align-items: center;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--bs-body-color);
  transition: background-color 0.15s;
  user-select: none;
  font-size: 0.95rem;
}

.tree-node-content:hover {
  background-color: var(--sidebar-bg-hover);
}

.tree-node-content.active {
  background-color: var(--sidebar-active-bg);
  color: var(--sidebar-active-color);
  font-weight: 500;
}

.tree-toggle {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  border-radius: 4px;
  color: var(--bs-secondary-color);
  transition: transform 0.2s;
}

.tree-toggle:hover {
  background-color: rgba(0,0,0,0.1);
}

.tree-toggle.expanded {
  transform: rotate(90deg);
}

.tree-icon {
  margin-right: 8px;
  opacity: 0.7;
}

.tree-children {
  padding-left: 24px;
  display: none;
}

.tree-children.show {
  display: block;
}

/* Search Input */
.search-wrapper {
  position: relative;
  max-width: 400px;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--bs-secondary-color);
  pointer-events: none;
}

.search-input {
  padding-left: 36px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--bs-tertiary-bg);
}

.search-input:focus {
  background-color: var(--bs-body-bg);
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
}

/* Login Page */
#loginSection {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

[data-bs-theme="dark"] #loginSection {
  background: linear-gradient(135deg, #121212 0%, #2d3436 100%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  border: none;
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.05);
  background-color: var(--bs-body-bg);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    z-index: 1050;
    height: 100%;
    box-shadow: 4px 0 15px rgba(0,0,0,0.1);
  }
  
  .sidebar.show {
    transform: translateX(100%);
    left: 0; /* Fix for transform */
  }
  
  .top-bar {
    padding: 0 1rem;
  }
  
  .editor-container {
    padding: 0 1rem 1rem;
  }
}

/* Utilities */
.text-xs { font-size: 0.75rem; }
.fw-500 { font-weight: 500; }
.rounded-xl { border-radius: 12px; }
.cursor-pointer { cursor: pointer; }

/* Context Menu */
.context-menu {
  position: fixed;
  z-index: 1080;
  display: none;
  min-width: 180px;
  background-color: var(--bs-body-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 0.5rem 0;
}

.context-menu button {
  width: 100%;
  padding: 0.5rem 1rem;
  background: transparent;
  border: 0;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--bs-body-color);
  font-size: 0.9rem;
}

.context-menu button:hover {
  background-color: var(--bs-tertiary-bg);
}

/* Attachments Badge */
.attachment-badge {
  font-size: 0.75rem;
  padding: 0.15em 0.5em;
  background-color: rgba(13, 110, 253, 0.1);
  color: var(--accent-color);
  border-radius: 12px;
  margin-left: auto;
}

/* Save Status */
#changeStatus {
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.3s;
}
#changeStatus.visible {
  opacity: 1;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}
