/* Modern Dark Theme for AtlasAI - Matching React Version Colors */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap");

/* CSS Variables - Matching React Version */
:root {
  --bg-primary: #030712;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-card: rgba(31, 41, 55, 0.5);
  --border-primary: rgba(75, 85, 99, 0.5);
  --border-secondary: rgba(75, 85, 99, 0.3);
  --text-primary: #f3f4f6;
  --text-secondary: #d1d5db;
  --text-tertiary: #9ca3af;
  --text-muted: #6b7280;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-orange: #f59e0b;
}
.locked-status {
  color: var(--accent-orange);
  font-weight: 500;
}

.locked-status i {
  color: var(--accent-orange);
}
/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box; /* Ensure consistent box model everywhere */
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Remove this specific override unless absolutely necessary after other changes */
/* .ql-snow .ql-picker.ql-expanded .ql-picker-label {
  z-index: 101 !important;
} */

/* Navigation */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50; /* Keep this */
  background: rgba(17, 24, 39, 1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-primary);
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-center {
  flex: 1;
  max-width: 400px;
  margin: 0 2rem;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-btn {
  padding: 0.5rem;
  background: none;
  border: none;
  color: var(--text-tertiary);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background: rgba(75, 85, 99, 0.3);
  color: var(--text-primary);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 2rem;
  height: 2rem;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.875rem;
}

.brand-text {
  font-size: 1.25rem;
  font-weight: 600;
  background: white;
  -webkit-background-clip: text;
  background-clip: text;
}

/* Global Search */
.global-search-container {
  position: relative;
  width: 100%;
  display: flex; /* Ensure flex for alignment */
  align-items: center; /* Vertically align items */
}

.global-search {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  background: rgba(31, 41, 55, 0.5);
  border: 1px solid var(--border-secondary);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: all 0.2s ease;
  vertical-align: middle; /* Align input with icon */
}

.global-search::placeholder {
  color: var(--text-muted);
}

.global-search:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.global-search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.875rem;
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  margin-top: 0.5rem;
}

.search-results.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.search-result-item {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px solid var(--border-secondary);
  transition: all 0.2s ease;
}

.search-result-item:hover {
  background: rgba(75, 85, 99, 0.3);
  color: var(--text-primary);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item.no-results {
  color: var(--text-muted);
  cursor: default;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-result-item.no-results:hover {
  background: none;
  color: var(--text-muted);
}

.result-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.result-title {
  font-weight: 500;
  color: var(--text-primary);
}

.result-snippet {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  line-height: 1.4;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent-blue);
  color: white;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-primary.edit {
  background: var(--accent-orange);
}

.btn-primary.edit:hover {
  background: #d97706;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-primary);
}

.btn-secondary:hover {
  background: #374151;
  color: var(--text-primary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fecaca;
}

.btn-large {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* Flash Messages */
.flash-container {
  position: fixed;
  top: 5rem;
  right: 1.5rem;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flash-message {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-primary);
  border-radius: 0.5rem;
  padding: 1rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  animation: slideInRight 0.3s ease-out;
}

.flash-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.flash-success i {
  color: var(--accent-green);
}

.flash-error i {
  color: var(--accent-red);
}

.flash-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  margin-left: auto;
  padding: 0.25rem;
}

.flash-close:hover {
  background: rgba(75, 85, 99, 0.3);
  color: var(--text-primary);
}

/* Main Layout */
.main-wrapper {
  padding-top: 5rem;
}

.app-layout {
  display: flex;
  height: calc(100vh);
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 4.5rem;
  height: calc(100vh - 4.5rem);
  width: 20rem;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-primary);
  transform: translateX(0);
  transition: transform 0.3s ease;
  z-index: 30;
}

.sidebar.collapsed {
  transform: translateX(-100%);
}

.sidebar-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: visible; /* Changed from hidden/auto */
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center; /* Vertically center items */
  justify-content: space-between; /* Distribute items with space between them */
}

.create-page-btn {
  width: 2rem;
  height: 2rem;
  background: var(--accent-blue);
  border: none;
  border-radius: 0.5rem;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 1rem;
}

/* Add this to static/css/style.css */
mark {
  background-color: #443e91; /* Light blue */
  color: var(--text-primary); /* Ensure text remains readable */
  padding: 0.2em; /* Optional: adds a little padding around the highlight */
}

.create-page-btn:hover {
  background: #2563eb;
  transform: scale(1.05);
}

.search-container {
  position: relative;
  flex-grow: 1; /* Allow search input to grow in flex container */
  display: flex; /* Make search container a flex container */
  align-items: center; /* Vertically align input and icon */
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.875rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.75rem 0.75rem 0.75rem 2.5rem;
  background: rgba(31, 41, 55, 0.5);
  border: 1px solid var(--border-secondary);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  vertical-align: middle; /* Ensure vertical alignment */
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: visible; /* Allow horizontal overflow for menus */
  padding: 1rem;
}

.page-tree {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow: visible; /* Allow menus to overflow */
}

/* Page item and link positioning */
.page-item {
  pointer-events: auto;
}

.page-item * {
  pointer-events: auto;
}

.sidebar-body.menu-open .page-item:not(.menu-active-item) {
  pointer-events: none;
}

.sidebar-body.menu-open .page-item.menu-active-item {
  pointer-events: auto;
} 
/* Animated page children with smooth transitions */
.page-children {
  margin-top: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow: visible; /* Allow child menus to overflow */
  /* transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1); */
}


.page-children.collapsed {
  opacity: 0;
  max-height: 0;
  margin-top: 0;
  transform: translateY(-10px);
}

/* Page toggle buttons with smooth animation */
.page-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  /* Removed margin-left: auto; as it's now first child of page-link-content */
  flex-shrink: 0; /* Prevent it from shrinking */
}

.page-toggle:hover {
  background: rgba(75, 85, 99, 0.3);
  color: var(--text-primary);
  transform: scale(1.1);
}

.page-toggle i {
  font-size: 0.75rem;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Smooth chevron rotation */
.page-toggle[aria-expanded="false"] i {
  transform: rotate(-90deg);
}

.page-toggle[aria-expanded="true"] i {
  transform: rotate(0deg);
}


/* Page menu button */
.page-menu-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  opacity: 0;
  margin-left: auto; /* Push to the right */
  flex-shrink: 0;
}

.page-item:hover .page-menu-btn {
  opacity: 1;
}

.page-menu-btn:hover {
  background: rgba(75, 85, 99, 0.3);
  color: var(--text-primary);
}

.page-menu-btn i {
  font-size: 0.75rem;
}

/* Page menu dropdown */
.page-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  z-index: 1001; /* Keep this high */
  min-width: 180px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: visible;
  
  /* Critical: Ensure menu captures pointer events */
  pointer-events: auto;
}

.page-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto; /* Ensure it can receive clicks */
}

.page-menu:not(.show) {
  pointer-events: none;
}

/* Ensure menu items are clickable */
.menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-secondary);
  
  /* Ensure menu items capture clicks */
  pointer-events: auto;
  position: relative;
  z-index: 1002; /* Higher than menu container */
}

.menu-item:hover {
  background: rgba(75, 85, 99, 0.3);
  color: var(--text-primary);
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item.delete {
  color: #fca5a5;
}

.menu-item.delete:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fecaca;
}

.menu-item i {
  font-size: 0.75rem;
  width: 1rem;
}

.page-link {
  display: flex;
  align-items: center;
  padding: 0.625rem 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 2.5rem;
  justify-content: space-between;
  overflow: visible; /* Allow menu to overflow */
}

.page-link-content { /* New class to wrap icon and text */
    display: flex; /* <<<<<<<<<<<<<<<< ADDED: Ensure it's a flex container for horizontal alignment */
    align-items: center;
    gap: 0.75rem; /* Gap for toggle, icon, and text */
    flex-grow: 1; /* Allow content to grow and push menu button */
    /* REMOVED overflow: hidden; from here */
    white-space: nowrap; /* Keep text on one line */
    text-overflow: ellipsis; /* Add ellipsis for overflowed text */
    min-width: 0; /* Allow content to shrink */
}

/* Add text overflow clipping specifically to the span if it overflows */
.page-link-content span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}


.page-link:hover {
  background: rgba(75, 85, 99, 0.3);
  color: var(--text-primary);
}

.page-link.active {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border-right: 2px solid var(--accent-blue);
}

.page-link.menu-active {
  z-index: 1000;
  /* Create a stronger stacking context */
  isolation: isolate;
}

/* Prevent underlying elements from interfering when menu is open */
.page-item:has(.page-menu.show) ~ .page-item {
  pointer-events: none; /* Disable clicks on siblings below */
}

.page-item:has(.page-menu.show) ~ .page-item * {
  pointer-events: none; /* Disable clicks on all child elements */
}

.page-link .page-link-content i { /* Target icon inside new wrapper */
  color: var(--text-muted);
  font-size: 0.875rem;
  /* Add explicit alignment if needed, e.g., vertical-align: middle; */
}

.page-link.active .page-link-content i { /* Target icon inside new wrapper */
  color: #60a5fa;
}

.page-link.child { /* This class is now redundant as indentation is handled by child-level-X */
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

/* Styles for nested page items in sidebar */
/* These indents are for the page-link itself, to push it right */
.page-item.child-level-1 > .page-link {
    padding-left: 1.5rem; /* Base padding of 0.75rem + 0.75rem indent */
}

.page-item.child-level-2 > .page-link {
    padding-left: 2.25rem; /* 0.75 + 2 * 0.75 */
}

.page-item.child-level-3 > .page-link {
    padding-left: 3rem; /* 0.75 + 3 * 0.75 */
}

.page-item.child-level-4 > .page-link {
    padding-left: 3.75rem; /* 0.75 + 4 * 0.75 */
}
/* You can add more .child-level-X as needed */


/* Main Content */
.main-content {
  flex: 1;
  margin-left: 20rem; /* Space for the sidebar */
  margin-right: 0; /* Add a base margin-right */
  transition: margin-left 0.3s ease, margin-right 0.3s ease; /* Add transition for smooth resizing */
  overflow-y: auto;
  position: relative;
}

.main-content.chat-open {
  margin-right: 24rem; /* Space for the chat panel */
}

.main-content.expanded {
  margin-left: 0;
}

/* Add a responsive rule for when both are closed on mobile */
@media (max-width: 768px) {
  .main-content.chat-open {
    margin-right: 0; /* Chat panel takes up full width on mobile, so no margin is needed */
  }
}

.content-container {
  max-width: 64rem;
  margin: 0 auto;
  padding: 2rem;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-primary);
}

.page-info {
  flex: 1;
}

.page-title {
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 0.5rem;
  padding: 0.25rem 0.5rem;
  margin: -0.25rem -0.5rem;
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  /* Add invisible border to prevent jumping */
  border: 2px solid transparent;
}

.page-title:hover {
  background: rgba(59, 130, 246, 0.05);
}

.page-title[contenteditable="true"] {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--accent-blue);
  outline: none;
  cursor: text;
}

.page-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.page-actions {
  display: flex;
  gap: 0.75rem;
}

.page-content {
  line-height: 1.8;
}

/* Base styles for the content area, applied when not in edit mode (Quill inactive) */
.content {
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 0.75rem;
  padding: 1rem;
  margin: -1rem;
  min-height: 200px;
  color: var(--text-secondary);
  /* Add invisible border to prevent jumping */
  border: 2px solid transparent;
  /* z-index: -1; */ /* REMOVED THIS LINE */
}

.content:hover {
  background: rgba(59, 130, 246, 0.02);
}

/* This style is no longer needed with Quill, as Quill creates its own editor div */
/* .content[contenteditable="true"] {
  background: rgba(59, 130, 246, 0.05);
  border-color: var(--accent-blue);
  outline: none;
  cursor: text;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
} */

/* Rich Editor Toolbar (now for Quill's toolbar) */
.rich-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: 0.5rem;
  margin-bottom: 2rem; /* Increased space between toolbar and content */
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10; /* Increased Z-index to be reliably above content */
  position: relative; /* Ensure it forms a stacking context */
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.toolbar-separator {
  width: 1px;
  height: 1.5rem;
  background: var(--border-primary);
  margin: 0 0.5rem;
}

/* Styles for custom toolbar buttons (no longer directly used by Quill's default, but good for reference) */
.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
  background: none;
  border: none;
  color: var(--text-tertiary);
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  min-width: 2rem;
  height: 2rem;
  justify-content: center;
}

.toolbar-btn:hover {
  background: rgba(75, 85, 99, 0.3);
  color: var(--text-primary);
}

.toolbar-btn.active {
  background: var(--accent-blue);
  color: white;
}

.toolbar-btn-success {
  background: var(--accent-green);
  color: white;
  padding: 0.5rem 0.75rem;
}

.toolbar-btn-success:hover {
  background: #059669;
}

.toolbar-btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-primary);
  padding: 0.5rem 0.75rem;
}

.toolbar-btn-secondary:hover {
  background: #374151;
  color: var(--text-primary);
}

.heading-level {
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 0.125rem;
}

/* Enhanced markdown styling for rendered content */
.content h1,
.content h2,
.content h3,
.content h4,
.content h5,
.content h6 {
  color: var(--text-primary);
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 1rem;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.content h1 {
  font-size: 2.25rem;
  border-bottom: 2px solid rgba(59, 130, 246, 0.3);
  padding-bottom: 0.5rem;
}

.content h2 {
  font-size: 1.875rem;
}

.content h3 {
  font-size: 1.5rem;
}

.content p {
  margin-bottom: 1rem;
}

.content ul,
.content ol {
  margin-bottom: 1rem;
  padding-left: 2rem;
}

.content li {
  margin-bottom: 0.5rem;
}

.content blockquote {
  border-left: 4px solid var(--accent-blue);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--text-tertiary);
  font-style: italic;
  background: rgba(59, 130, 246, 0.05);
  padding: 1rem;
  border-radius: 0 0.5rem 0.5rem 0;
}

.content code {
  background: rgba(31, 41, 55, 0.8);
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
  color: var(--accent-orange);
  font-family: "JetBrains Mono", monospace;
}

.content pre {
  background: rgba(17, 17, 17, 0.9);
  padding: 1.5rem;
  border-radius: 0.75rem;
  overflow-x: auto;
  border: 1px solid var(--border-primary);
  margin: 1rem 0;
}

.content pre code {
  background: none;
  padding: 0;
  color: var(--text-secondary);
}

.content a {
  color: var(--accent-blue);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
}

.content a:hover {
  border-bottom-color: var(--accent-blue);
}

.content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.content em {
  color: var(--text-secondary);
  font-style: italic;
}

/* Section toggle buttons */
.section-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.section-toggle:hover {
  background: rgba(75, 85, 99, 0.3);
  color: var(--text-primary);
  transform: scale(1.1);
}

.section-toggle i {
  font-size: 0.75rem;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.section-toggle[aria-expanded="false"] i {
  transform: rotate(-90deg);
}

.section-toggle[aria-expanded="true"] i {
  transform: rotate(0deg);
}

/* Collapsible section content */
.section-content {
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.section-content.expanded {
  opacity: 1;
  max-height: 5000px;
  transform: translateY(0);
}

.section-content.collapsed {
  opacity: 0;
  max-height: 0;
  transform: translateY(-10px);
  margin-bottom: 0;
}

.page-link.public-page {
  border-left: 2px solid #0c64e8;
}

.page-link.private-page {
  border-left: 2px solid #f6bd4c;
}

/* Welcome Screen */
.welcome-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.email-input-container {
    display: flex;
    gap: 0.5rem; /* Adds space between the input and the button */
    align-items: center;
}

.welcome-content {
  align-items: center;
  max-width: 28rem;
}

.welcome-icon {
  width: 6rem;
  height: 6rem;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(139, 92, 246, 0.2));
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #60a5fa;
}

.welcome-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.welcome-text {
  color: var(--text-tertiary);
  margin-bottom: 2rem;
  line-height: 1.5;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 100; /* Keep high, but allow editor popups to be higher */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 1rem;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
  max-width: 32rem;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 1.5rem 0;
  margin-bottom: 1rem;
}

.modal-icon {
  width: 2.5rem;
  height: 2.5rem;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1rem;
}

.modal-icon.delete {
  background: linear-gradient(135deg, var(--accent-red), var(--accent-orange));
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-subtitle {
  color: var(--text-tertiary);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.5rem;
  margin-left: auto;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: rgba(75, 85, 99, 0.3);
  color: var(--text-primary);
}

.modal-body {
  padding: 0 1.5rem 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.modal-actions .btn {
  flex: 1;
  justify-content: center;
}

/* Form Styles */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(31, 41, 55, 0.5);
  border: 1px solid var(--border-secondary);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.form-group textarea {
  resize: vertical;
  font-family: "JetBrains Mono", monospace;
}

.form-group select {
  cursor: pointer;
}

/* User Menu and Avatar */
.user-menu-container {
  position: relative;
}

.user-avatar-btn {
  background: none;
  border: none;
  padding: .5rem;
  cursor: pointer;
  margin-top: 3px;
}

.user-avatar {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 60%;
  border: 0px solid var(--accent-blue);
  transition: all 0.2s ease;
}

.user-avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  min-width: 150px;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
}

.user-menu-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s ease;
}

.user-menu-item:hover {
  background: rgba(75, 85, 99, 0.3);
  color: var(--text-primary);
}

.user-menu-item i {
  width: 1.25rem;
  text-align: center;
}

/* Chat Panel */
.chat-panel {
  position: fixed;
  right: 0;
  top: 4.5rem;
  height: calc(100vh - 4.5rem);
  width: 24rem;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border-primary);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 30; /* Keep this */
}

.chat-panel.open {
  transform: translateX(0);
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem;
  border-bottom: 1px solid var(--border-primary);
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chat-icon {
  width: 2rem;
  height: 2rem;
  background: linear-gradient(135deg, var(--accent-green), var(--accent-blue));
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.875rem;
}

.chat-title h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
  margin-left: auto;
}

.chat-close:hover {
  background: rgba(75, 85, 99, 0.3);
  color: var(--text-primary);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.welcome-message {
  text-align: center;
  padding: 1rem 0;
}

.bot-avatar {
  width: 4rem;
  height: 4rem;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(59, 130, 246, 0.2));
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-green);
}

.welcome-message h4 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.welcome-message p {
  color: var(--text-tertiary);
  font-size: 0.875rem;
  line-height: 1.5;
}

.chat-input-container {
  padding: 1.5rem;
  border-top: 1px solid var(--border-primary);
}

.chat-input-wrapper {
  position: relative;
}

.chat-input {
  width: 100%;
  padding: 0.75rem 3rem 0.75rem 1rem;
  background: rgba(31, 41, 55, 0.5);
  border: 1px solid var(--border-secondary);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.chat-send {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.5rem;
  background: var(--accent-blue);
  border: none;
  border-radius: 0.375rem;
  color: white;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.chat-send:hover {
  background: #2563eb;
}

/* Chat Messages */
.bot-message,
.user-message {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
  animation: fadeIn 0.3s ease-out;
}

.user-message {
  justify-content: flex-end;
}

.message-content {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  word-wrap: break-word;
}

.bot-message .message-content {
  background: rgba(31, 41, 55, 0.8);
  border: 1px solid var(--border-secondary);
  color: var(--text-secondary);
}

.user-message .message-content {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: white;
}

.bot-message i {
  color: var(--accent-green);
  margin-top: 0.25rem;
  font-size: 1rem;
}

.user-message i {
  color: var(--text-secondary);
  margin-top: 0.25rem;
  font-size: 1rem;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Animations */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading Animation */
.loading::after {
  content: "";
  width: 1rem;
  height: 1rem;
  margin-left: 0.5rem;
  border: 2px solid #374151;
  border-top: 2px solid var(--accent-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: inline-block;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Feedback Buttons */
.feedback-buttons {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
}

.feedback-buttons button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
}

.feedback-buttons button:hover {
  color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.1);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #374151;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}

/* Responsive Design */
@media (max-width: 768px) {
  .nav-center {
    display: none;
  }

  .sidebar {
    width: 100%;
    transform: translateX(-100%);
  }

  .main-content {
    margin-left: 0;
  }

  .chat-panel {
    width: 100%;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .chat-panel.open {
    transform: translateX(0);
  }

  .page-header {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .page-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .modal-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-actions .btn {
    justify-content: center;
  }

  .rich-editor-toolbar {
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .toolbar-separator {
    display: none;
  }
}

/* Edit mode visual feedback with smooth transitions */
.edit-mode::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
  z-index: 100;
  animation: editPulse 3s infinite;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.edit-mode-exiting::before {
  opacity: 0;
}

@keyframes editPulse {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 0.8;
  }
}

/* Save status */
.save-status {
  position: fixed;
  top: 6rem;
  right: 1.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  z-index: 40;
  transform: translateY(-100px);
  opacity: 0;
  transition: all 0.3s ease;
}

.save-status.show {
  transform: translateY(0);
  opacity: 1;
}

.save-status.saving {
  color: var(--accent-orange);
}

.save-status.saved {
  color: var(--accent-green);
}

.save-status.error {
  color: var(--accent-red);
}

/* Styles for color picker modal */
.color-picker-modal .modal-content {
    max-width: 250px; /* Smaller size for color picker */
    padding: 1rem;
}

.color-picker-modal label {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.color-picker-modal input[type="color"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    height: 40px;
    border: 1px solid var(--border-secondary);
    border-radius: 0.5rem;
    background: var(--bg-tertiary);
    cursor: pointer;
    padding: 0; /* Remove default padding */
    overflow: hidden; /* Hide default color swatch border */
}

.color-picker-modal input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-modal input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 0.5rem;
}

.color-picker-modal input[type="color"]::-moz-color-sample {
    border: none;
    border-radius: 0.5rem;
}


/* --- Quill.js Custom Styling Overrides --- */

/* Quill Editor Container (where the editor content lives) */
.ql-container {
  font-family: "Inter", sans-serif;
  font-size: 1rem;
  border-radius: 0.75rem;
  min-height: 200px;
  border: 1px solid var(--border-primary) !important; /* Important to override Quill's default */
  background: var(--bg-secondary) !important;
  color: var(--text-secondary) !important;
  transition: all 0.2s ease;
  position: relative; /* Important: Create a stacking context here */
  z-index: 2; /* Make it higher than main-content's base of 1, but lower than toolbar */
}

/* Editor content area */
.ql-editor {
  line-height: 1.8;
  padding: 1rem;
  color: var(--text-secondary);
  z-index: 3; /* Ensure content is above container background if needed */
}

/* Focus state for editor */
.ql-container.ql-snow.ql-editor.ql-blank::before {
    color: var(--text-muted); /* Placeholder color */
    font-style: italic;
    left: 1rem; /* Adjust placeholder position */
    right: 1rem;
}

/* Remove default Quill focus outline */
.ql-container.ql-snow:focus-within {
  border-color: var(--accent-blue) !important; /* Keep a subtle border color */
  box-shadow: none !important; /* Remove blue shadow */
  outline: none !important; /* Remove default outline */
}

/* Toolbar styling */
.ql-toolbar {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-primary) !important;
  border-radius: 0.5rem !important; /* Inherit from rich-editor-toolbar */
  margin-bottom: 1.5rem; /* Space between toolbar and editor */
  padding: 0.75rem 1rem !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Toolbar buttons and controls */
.ql-toolbar .ql-picker-label,
.ql-toolbar .ql-picker-item,
.ql-toolbar .ql-stroke,
.ql-toolbar .ql-fill,
.ql-toolbar .ql-even,
.ql-toolbar .ql-format-group .ql-stroke {
  color: var(--text-tertiary) !important; /* Default icon/text color */
  fill: var(--text-tertiary) !important; /* Fill for icons */
}

/* Hover state for toolbar buttons */
.ql-toolbar button:hover .ql-stroke,
.ql-toolbar button:hover .ql-fill,
.ql-toolbar button:hover .ql-picker-label .ql-stroke,
.ql-toolbar .ql-picker-label:hover .ql-stroke,
.ql-toolbar .ql-picker-label:hover {
  color: var(--text-primary) !important;
  fill: var(--text-primary) !important;
}

.ql-toolbar button.ql-active .ql-stroke,
.ql-toolbar button.ql-active .ql-fill,
.ql-toolbar .ql-picker-label.ql-active .ql-stroke,
.ql-toolbar .ql-picker-label.ql-active {
  color: var(--accent-blue) !important;
  fill: var(--accent-blue) !important;
}

.ql-toolbar button.ql-active {
  background: rgba(59, 130, 246, 0.2) !important; /* Active background */
  border-color: transparent !important;
}

/* Dropdowns (e.g., header, font size) */
.ql-picker {
  color: var(--text-tertiary) !important;
  background: var(--bg-tertiary) !important;
  border: 1px solid var(--border-secondary) !important;
  border-radius: 0.375rem !important;
  /* z-index: 100 !important; */ /* Remove or keep lower if label handles stacking */
}

/* Dropdown menu options */
.ql-picker.ql-expanded .ql-picker-options {
  background: var(--bg-secondary) !important;
  border: 1px solid var(--border-primary) !important;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3) !important;
  border-radius: 0.5rem !important;
  padding: 0.5rem 0;
  color: var(--text-secondary);
  z-index: 100 !important; /* Keep this high */
}

.ql-picker-item {
  color: var(--text-secondary) !important;
  padding: 0.5rem 1rem !important;
  /* z-index: 100 !important; */ /* This is often redundant if options panel has it */
}

.ql-picker-item:hover {
  background: rgba(75, 85, 99, 0.3) !important;
  color: var(--text-primary) !important;
  /* z-index: 100 !important; */
}

.ql-picker-item.ql-selected {
  background: rgba(59, 130, 246, 0.2) !important;
  color: var(--accent-blue) !important;
  /* z-index: 100 !important; */
}

/* Tooltips (e.g., link editor) */
.ql-tooltip {
  background: var(--bg-secondary) !important;
  border: 1px solid var(--border-primary) !important;
  border-radius: 0.5rem !important;
  color: var(--text-secondary) !important;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3) !important;
  z-index: 100 !important; /* Keep this high */
}

.ql-tooltip a.ql-action,
.ql-tooltip a.ql-remove {
  color: var(--accent-blue) !important;
}

.ql-tooltip .ql-action:hover {
  color: var(--text-primary) !important;
}

.ql-tooltip input[type=text] {
  background: var(--bg-tertiary) !important;
  border: 1px solid var(--border-secondary) !important;
  color: var(--text-primary) !important;
  border-radius: 0.375rem !important;
  padding: 0.5rem !important;
}

/* Specific button overrides for toolbar-btn success/secondary (if Quill generates these, unlikely) */
/* Quill generates its own button elements, so these custom styles might need to be re-applied to Quill's selectors */
.ql-toolbar button.ql-link::after,
.ql-toolbar button.ql-color::after {
    /* Adjustments for custom icon-only buttons if needed */
}

/* Match header font sizes and margins generated by Quill */
.ql-editor h1 {
  font-size: 2.25rem;
  border-bottom: 2px solid rgba(59, 130, 246, 0.3);
  padding-bottom: 0.5rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
  font-weight: 600;
}
.ql-editor h2 {
  font-size: 1.875rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
  font-weight: 600;
}
.ql-editor h3 {
  font-size: 1.5rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
  font-weight: 600;
}
/* Ensure code blocks and blockquotes generated by Quill match our theme */
.ql-editor pre.ql-syntax { /* For Quill's code blocks */
  background: rgba(17, 17, 17, 0.9);
  padding: 1.5rem;
  border-radius: 0.75rem;
  overflow-x: auto;
  border: 1px solid var(--border-primary);
  margin: 1rem 0;
  color: var(--text-secondary); /* Code text color */
  font-family: "JetBrains Mono", monospace;
}

.ql-editor blockquote {
  border-left: 4px solid var(--accent-blue);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--text-tertiary);
  font-style: italic;
  background: rgba(59, 130, 246, 0.05);
  padding: 1rem;
  border-radius: 0 0.5rem 0.5rem 0;
}

.ql-editor p {
    margin-bottom: 1rem;
}

.ql-editor ul, .ql-editor ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.ql-editor li {
    margin-bottom: 0.5rem;
}