/* ============================================================
   Notion Clone — Stylesheet
   Matches Notion's clean aesthetic: Inter font, #37352f ink,
   warm-gray sidebar (#f7f7f5), generous whitespace.
   ============================================================ */

:root {
  --ink: #37352f;
  --ink-soft: #6b6a64;
  --ink-faint: #9b9a93;
  --bg: #ffffff;
  --bg-sidebar: #fbfbfa;
  --bg-hover: rgba(55, 53, 47, 0.06);
  --bg-hover-strong: rgba(55, 53, 47, 0.10);
  --bg-active: rgba(55, 53, 47, 0.09);
  --border: rgba(55, 53, 47, 0.10);
  --border-strong: rgba(55, 53, 47, 0.18);
  --blue: #2383e2;
  --blue-soft: rgba(35, 131, 226, 0.1);
  --red: #e03e3e;
  --green: #0f7b6c;
  --orange: #d9730d;
  --yellow-bg: #fdecc8;
  --code-bg: #f7f6f3;
  --radius: 4px;
  --radius-lg: 8px;
  --sidebar-w: 260px;
  --shadow-sm: 0 1px 2px rgba(15, 15, 15, 0.1);
  --shadow-md: rgba(15, 15, 15, 0.05) 0px 0px 0px 1px, rgba(15, 15, 15, 0.1) 0px 3px 6px, rgba(15, 15, 15, 0.2) 0px 9px 24px;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[hidden] { display: none !important; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(55,53,47,0.16); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(55,53,47,0.28); background-clip: content-box; border: 2px solid transparent; }

/* ============================================================
   AUTH VIEW
   ============================================================ */
.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f7f7f5;
  padding: 24px;
}
.auth-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}
.auth-logo { margin-bottom: 20px; display: flex; justify-content: center; }
.auth-card h1 { font-size: 28px; font-weight: 700; text-align: center; letter-spacing: -0.01em; }
.auth-subtitle { text-align: center; color: var(--ink-soft); margin-top: 6px; font-size: 14px; }

.auth-form { margin-top: 28px; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.field input {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }

.btn { border-radius: var(--radius); padding: 9px 16px; font-size: 14px; font-weight: 500; transition: background .12s; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; }
.btn-block { width: 100%; }

.auth-error {
  background: rgba(224,62,62,0.08); color: var(--red);
  padding: 8px 12px; border-radius: var(--radius); font-size: 13px;
}
.auth-switch { text-align: center; margin-top: 24px; font-size: 14px; color: var(--ink-soft); }
.auth-switch a { color: var(--blue); text-decoration: none; font-weight: 500; }
.auth-switch a:hover { text-decoration: underline; }
.auth-demo-hint { text-align: center; margin-top: 16px; font-size: 12px; color: var(--ink-faint); }

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app-view { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width .15s, margin .15s;
}
.sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; user-select: none;
}
.workspace { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: var(--radius); cursor: pointer; }
.workspace:hover { background: var(--bg-hover); }
.workspace-avatar {
  width: 22px; height: 22px; border-radius: 4px;
  background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.workspace-name { font-size: 14px; font-weight: 600; }

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius);
  color: var(--ink-soft); flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--ink); }

.sidebar-nav { padding: 4px 8px; }
.sidebar-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 5px 8px; border-radius: var(--radius);
  font-size: 14px; color: var(--ink-soft);
}
.sidebar-item:hover { background: var(--bg-hover); color: var(--ink); }

.sidebar-tree { flex: 1; overflow-y: auto; padding: 4px 8px; }

/* Tree items */
.tree-item { user-select: none; }
.tree-row {
  display: flex; align-items: center; gap: 2px;
  padding: 3px 6px 3px 4px; border-radius: var(--radius);
  font-size: 14px; cursor: pointer; position: relative;
  color: var(--ink);
}
.tree-row:hover { background: var(--bg-hover); }
.tree-row.active { background: var(--bg-active); font-weight: 500; }
.tree-toggle {
  width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
  border-radius: 3px; color: var(--ink-faint); flex-shrink: 0; transition: transform .12s;
}
.tree-toggle:hover { background: var(--bg-hover-strong); color: var(--ink); }
.tree-toggle.expanded { transform: rotate(90deg); }
.tree-toggle.empty { visibility: hidden; }
.tree-icon { width: 20px; text-align: center; flex-shrink: 0; font-size: 14px; opacity: .8; }
.tree-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-actions { display: none; gap: 0; }
.tree-row:hover .tree-actions { display: flex; }
.tree-action-btn {
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  border-radius: 3px; color: var(--ink-faint);
}
.tree-action-btn:hover { background: var(--bg-hover-strong); color: var(--ink); }
.tree-children { overflow: hidden; }

.tree-row.drag-over-top { box-shadow: inset 0 2px 0 0 var(--blue); }
.tree-row.drag-over-bottom { box-shadow: inset 0 -2px 0 0 var(--blue); }
.tree-row.drag-over-inside { box-shadow: inset 0 0 0 1.5px var(--blue); }

.sidebar-footer { padding: 8px 10px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-radius: var(--radius); }
.user-chip:hover { background: var(--bg-hover); }
.user-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.user-name { flex: 1; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   MAIN / EDITOR
   ============================================================ */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg); min-height: 45px;
}
.breadcrumb { font-size: 14px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.breadcrumb-sep { color: var(--ink-faint); }
.breadcrumb a { color: var(--ink-soft); text-decoration: none; cursor: pointer; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .current { color: var(--ink); }

.editor-container {
  flex: 1; overflow-y: auto; padding: 0 24px 240px;
  max-width: 900px; width: 100%; margin: 0 auto;
}

/* Page header */
.page-header { padding: 80px 0 8px; max-width: 720px; margin: 0 auto; }
.page-icon { font-size: 60px; line-height: 1; margin-left: -6px; margin-bottom: 4px; padding: 4px; border-radius: var(--radius); width: fit-content; cursor: pointer; }
.page-icon:hover { background: var(--bg-hover); }
.page-icon:focus { outline: none; background: var(--bg-hover); }
.page-icon:empty::before { content: attr(data-placeholder); opacity: .35; }

.page-title {
  font-size: 40px; font-weight: 700; line-height: 1.2;
  padding: 4px 0; letter-spacing: -0.02em;
}
.page-title:focus { outline: none; }
.page-title:empty::before { content: attr(data-placeholder); color: var(--ink-faint); }

/* Blocks container */
.blocks { max-width: 720px; margin: 0 auto; padding-top: 8px; }

/* Block wrapper */
.block {
  position: relative; display: flex; align-items: flex-start;
  margin: 2px 0; min-height: 30px;
}
.block-body { flex: 1; min-width: 0; padding: 3px 2px; }
.block-body:focus { outline: none; }

/* The gutter where hover controls live */
.block-gutter {
  position: absolute; left: -38px; top: 2px; height: 30px;
  display: flex; align-items: center; gap: 1px;
  opacity: 0; transition: opacity .1s;
}
.block:hover .block-gutter { opacity: 1; }
.gutter-btn {
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  border-radius: 3px; color: var(--ink-faint);
}
.gutter-btn:hover { background: var(--bg-hover-strong); color: var(--ink); }

/* Placeholder for empty blocks */
[contenteditable].block-body:empty::before {
  content: attr(data-placeholder); color: var(--ink-faint);
}

/* Block type styles */
.block-h1 .block-body { font-size: 30px; font-weight: 700; margin-top: 1.4em; line-height: 1.3; }
.block-h2 .block-body { font-size: 24px; font-weight: 600; margin-top: 1.2em; line-height: 1.3; }
.block-h3 .block-body { font-size: 20px; font-weight: 600; margin-top: 1em; line-height: 1.3; }

.block-bullet, .block-numbered { display: flex; align-items: flex-start; }
.block-bullet::before { content: "•"; margin: 3px 8px 0 0; font-size: 18px; line-height: 1; color: var(--ink); flex-shrink: 0; }
.block-numbered { counter-increment: numbered; }
.block-numbered::before { content: counter(numbered) "."; margin: 0 8px 0 2px; font-size: 16px; color: var(--ink); flex-shrink: 0; min-width: 18px; }
.blocks { counter-reset: numbered; }

.block-todo { display: flex; align-items: flex-start; gap: 8px; }
.block-todo .todo-check {
  margin-top: 5px; width: 16px; height: 16px; border-radius: 3px;
  border: 1.5px solid var(--border-strong); flex-shrink: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background .12s;
}
.block-todo .todo-check.checked { background: var(--blue); border-color: var(--blue); }
.block-todo .todo-check.checked svg { display: block; }
.block-todo .todo-check svg { display: none; }
.block-todo.checked .block-body { color: var(--ink-faint); text-decoration: line-through; }

.block-toggle { display: flex; align-items: flex-start; }
.block-toggle .toggle-arrow {
  margin: 4px 4px 0 2px; width: 18px; height: 18px; flex-shrink: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; border-radius: 3px;
  transition: transform .12s; color: var(--ink-soft);
}
.block-toggle .toggle-arrow:hover { background: var(--bg-hover); }
.block-toggle .toggle-arrow.expanded { transform: rotate(90deg); }
.block-toggle .toggle-children { margin-left: 24px; }

.block-quote { border-left: 3px solid var(--ink); padding-left: 14px; }
.block-callout { background: var(--yellow-bg); border-radius: var(--radius); padding: 4px 12px; display: flex; gap: 10px; align-items: flex-start; }
.block-callout .callout-icon { font-size: 18px; margin-top: 2px; flex-shrink: 0; }
.block-code { background: var(--code-bg); border-radius: var(--radius); padding: 0; font-family: 'SF Mono', 'Fira Code', Menlo, Consolas, monospace; font-size: 14px; }
.block-code .block-body { padding: 12px 16px; white-space: pre-wrap; font-family: inherit; }
.block-divider { display: flex; align-items: center; height: 30px; }
.block-divider .divider-line { flex: 1; border-top: 1px solid var(--border-strong); }

/* Inline formatting */
.block-body strong, .block-body b { font-weight: 700; }
.block-body em, .block-body i { font-style: italic; }
.block-body code { background: var(--code-bg); padding: 1px 5px; border-radius: 3px; font-family: 'SF Mono', Menlo, monospace; font-size: 0.88em; }
.block-body s { text-decoration: line-through; }
.block-body a { color: inherit; border-bottom: 1px solid var(--ink); text-decoration: none; }

/* Add block hint */
.add-block-hint {
  display: flex; align-items: center; gap: 8px;
  max-width: 720px; margin: 8px auto 0; padding: 8px 2px;
  color: var(--ink-faint); font-size: 14px;
}
.add-block-btn {
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  border-radius: 3px; color: var(--ink-faint);
}
.add-block-btn:hover { background: var(--bg-hover-strong); color: var(--ink); }
kbd {
  font-family: inherit; font-size: 12px;
  background: var(--bg-hover-strong); padding: 1px 6px; border-radius: 3px;
}

/* Drag-over indicator for blocks */
.block.drag-over-top { box-shadow: inset 0 2px 0 0 var(--blue); }
.block.drag-over-bottom { box-shadow: inset 0 -2px 0 0 var(--blue); }
.block.dragging { opacity: 0.4; }

/* ============================================================
   SLASH MENU
   ============================================================ */
.slash-menu {
  position: absolute; z-index: 100;
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); width: 280px; max-height: 340px;
  display: flex; flex-direction: column; overflow: hidden;
}
.slash-menu-search { padding: 8px; border-bottom: 1px solid var(--border); }
.slash-menu-search input {
  width: 100%; border: none; outline: none; font-size: 14px; padding: 4px 8px;
  background: transparent; color: var(--ink);
}
.slash-menu-list { overflow-y: auto; padding: 4px; }
.slash-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: var(--radius); cursor: pointer; font-size: 14px;
}
.slash-item:hover, .slash-item.selected { background: var(--bg-hover); }
.slash-item-icon {
  width: 36px; height: 36px; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; background: #fff;
}
.slash-item-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.slash-item-title { font-weight: 500; }
.slash-item-desc { font-size: 12px; color: var(--ink-faint); }
.slash-menu-empty { padding: 16px; text-align: center; color: var(--ink-faint); font-size: 13px; }

/* Empty page state */
.empty-page { text-align: center; padding: 60px 20px; color: var(--ink-faint); }
.empty-page svg { opacity: 0.4; margin-bottom: 12px; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { position: fixed; top: 0; bottom: 0; z-index: 50; box-shadow: var(--shadow-md); }
  .sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }
  .editor-container { padding: 0 16px 200px; }
  .page-header { padding: 40px 0 8px; }
  .page-title { font-size: 30px; }
}
