/* ===== Note Page Specific Styles ===== */

html, body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
}

/* Obsidian Theme Variables - AnuPpuccin Rose Pine Light + Custom Overrides */
.obsidian-theme {
  --ob-bg: #faf4ed;         /* Base */
  --ob-surface: #fffaf3;    /* Mantle */
  --ob-border: #dfdad9;     /* Surface0 */
  --ob-text: #575279;       /* Text */
  --ob-text-muted: #0C9FCE; /* Subtext0 (Custom Override) */
  --ob-brand: #1A7DA4;      /* Teal (Custom Override) */
  --ob-brand-light: #e4dfde;/* Surface1 */
  --ob-brand-dark: #525252; /* Overlay2 (Custom Override) */
  --ob-hover: #dfdad9;      /* Surface0 */
  --ob-active: #e4dfde;     /* Surface1 */
  --ob-danger: #b4637a;     /* Red */
  --ob-danger-bg: #f2e9e1;  /* Crust */
  --radius-sm: 8px;         /* AnuPpuccin style radius */
  --radius-md: 16px;
  
  /* Markdown Preview specifics */
  --h1-color: #b4637a;      /* Red */
  --h2-color: #DD7F67;      /* Peach custom */
  --h3-color: #286983;      /* Green */
  --h4-color: #1A7DA4;      /* Teal custom */
  --h5-color: #907aa9;      /* Lavender */
  --h6-color: #ea9d34;      /* Mauve */
  
  --link-color: #1A7DA4;
  --blockquote-border: #1A7DA4;
  --code-bg: #f2e9e1;       /* Crust */
}

/* Login Overlay */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--ob-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-card {
  background: var(--ob-surface);
  padding: 3rem;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  border: 1px solid var(--ob-border);
  width: 100%;
  max-width: 400px;
  text-align: center;
  color: var(--ob-text);
}

.login-error {
  color: var(--ob-danger);
  margin-top: 0.5rem;
  font-size: 14px;
}

/* App Container */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  background: var(--ob-bg);
  color: var(--ob-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Buttons */
.action-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.action-btn.primary {
  background: var(--ob-brand);
  color: #fff;
}

.action-btn.primary:hover:not(:disabled) {
  background: var(--ob-brand-dark);
}

.action-btn.secondary {
  background: transparent;
  color: var(--ob-text);
  border-color: var(--ob-border);
}

.action-btn.secondary:hover:not(:disabled) {
  background: var(--ob-hover);
}

.action-btn.secondary.active {
  background: var(--ob-brand-light);
  border-color: var(--ob-brand);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--ob-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

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

.icon-btn.danger-icon:hover:not(:disabled) {
  background: var(--ob-danger-bg);
  color: var(--ob-danger);
}

.icon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

/* Sidebars */
.app-sidebar, .app-properties {
  background: var(--ob-surface);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.15s ease-out;
  overflow: hidden;
}

.app-sidebar {
  width: 260px;
  border-right: 1px solid var(--ob-border);
}

.app-sidebar.collapsed {
  width: 0 !important;
  border-right: none;
}

.app-properties {
  width: 260px;
  border-left: 1px solid var(--ob-border);
}

.app-properties.collapsed {
  width: 0 !important;
  border-left: none;
  padding: 0 !important;
}

.sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--ob-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 48px;
}

.sidebar-actions {
  padding: 12px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--ob-border);
}

.sidebar-actions .action-btn {
  flex: 1;
}

/* Inputs */
.ob-input {
  width: 100%;
  background: var(--ob-bg);
  border: 1px solid var(--ob-border);
  color: var(--ob-text);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.ob-input:focus {
  outline: none;
  border-color: var(--ob-brand);
}

.search-container {
  padding: 12px;
  border-bottom: 1px solid var(--ob-border);
}

.folders-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.folder-list {
  font-size: 14px;
}

/* Folder and File Tree */
.folder-group {
  margin-bottom: 2px;
}

.folder-header {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-weight: 500;
  color: var(--ob-text);
  user-select: none;
  position: relative;
}

.folder-header:hover {
  background: var(--ob-hover);
}

.folder-icon {
  margin-right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ob-text-muted);
  transition: transform 0.15s ease;
}

.folder-group.collapsed > .folder-icon {
  transform: rotate(-90deg);
}

.folder-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.add-subfolder-btn {
  background: transparent;
  border: none;
  color: var(--ob-text-muted);
  cursor: pointer;
  opacity: 0;
  padding: 2px 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.folder-header:hover .add-subfolder-btn {
  opacity: 1;
}

.add-subfolder-btn:hover {
  background: var(--ob-active);
  color: var(--ob-text);
}

.folder-items {
  display: flex;
  flex-direction: column;
}

.folder-group.collapsed > .folder-items {
  display: none;
}

.note-item {
  padding: 4px 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--ob-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
}

.note-item::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="%23FB35D8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>');
  background-repeat: no-repeat;
  background-position: center;
  flex-shrink: 0;
}

.note-item:hover {
  background: var(--ob-hover);
  color: var(--ob-text);
}

.note-item.active {
  background: var(--ob-active);
  color: var(--ob-text);
  font-weight: 500;
}

.note-item.selected {
  background: var(--ob-brand-light);
  border: 1px solid var(--ob-brand);
  color: #fff;
}

/* Main Area */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--ob-bg);
  min-width: 0;
}

.editor-header {
  padding: 0 16px;
  height: 48px;
  background: var(--ob-surface);
  border-bottom: 1px solid var(--ob-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.note-title-input {
  font-size: 18px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--ob-text);
  width: 100%;
}

.note-title-input:focus {
  outline: none;
}

.editor-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.note-folder-input {
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ob-text-muted);
  width: 120px;
  transition: all 0.15s ease;
}

.note-folder-input:hover, .note-folder-input:focus {
  border-color: var(--ob-border);
  background: var(--ob-bg);
  color: var(--ob-text);
  outline: none;
}

.editor-body {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

.note-editor,
.note-preview {
  width: 100%;
  height: 100%;
  padding: 32px 48px;
  overflow-y: auto;
  border: none;
  background: var(--ob-bg);
  color: var(--ob-text);
  resize: none;
}

.note-editor {
  font-family: "Iosevka Comfy Duo", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  line-height: 1.6;
}

.note-editor:focus {
  outline: none;
}

/* Markdown Preview Styling (AnuPpuccin) */
.note-preview {
  font-family: "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  font-size: 16px;
}
.note-preview h1 { 
  color: var(--h1-color); 
  border-bottom: 2px solid var(--h1-color); 
  padding-bottom: 0.2em; 
  font-weight: 900; 
  font-family: "Noto Serif", serif;
  margin-top: 1.5em;
}
.note-preview h2 { 
  color: var(--h2-color); 
  border-bottom: 1px solid var(--h2-color); 
  padding-bottom: 0.2em; 
  font-weight: 600; 
  font-family: "Noto Serif", serif;
  margin-top: 1.2em;
}
.note-preview h3 { color: var(--h3-color); font-weight: 600; font-family: "Noto Serif", serif; margin-top: 1em; }
.note-preview h4 { color: var(--h4-color); font-weight: 600; font-family: "Noto Serif", serif; margin-top: 1em; }
.note-preview h5 { color: var(--h5-color); font-weight: 600; font-family: "Noto Serif", serif; margin-top: 1em; }
.note-preview h6 { color: var(--h6-color); font-weight: 600; font-family: "Noto Serif", serif; margin-top: 1em; }
.note-preview a { color: var(--link-color); text-decoration: none; }
.note-preview a:hover { text-decoration: underline; }
.note-preview blockquote {
  border-left: 4px solid var(--blockquote-border);
  margin: 1.5em 0;
  padding: 0.5em 1em;
  color: var(--ob-text-muted);
  background: var(--ob-surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.note-preview code {
  background: var(--code-bg);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-sm);
  font-family: "Iosevka Comfy Duo", ui-monospace, monospace;
  font-size: 0.9em;
  color: var(--h1-color); /* slightly tint inline code */
}
.note-preview pre {
  background: var(--code-bg);
  padding: 1em;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  border: 1px solid var(--ob-border);
}
.note-preview pre code {
  background: transparent;
  padding: 0;
  color: var(--ob-text);
}
.note-preview ul, .note-preview ol { padding-left: 2em; margin: 1em 0; }
.note-preview li { margin-bottom: 0.25em; }
.note-preview li::marker { color: var(--ob-brand); }
.note-preview table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1.5em;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.note-preview th, .note-preview td {
  border: 1px solid var(--ob-border);
  padding: 0.75em;
  text-align: left;
}
.note-preview th { background: var(--ob-surface); font-weight: 600; color: var(--ob-brand-dark); }
.note-preview tr:nth-child(even) { background: var(--ob-hover); }
.note-preview img { max-width: 100%; border-radius: var(--radius-sm); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.note-preview hr { border: none; border-top: 2px solid var(--ob-border); margin: 2.5em 0; }

/* Properties */
.app-properties {
  padding: 0;
}

.properties-container {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.property-row {
  display: flex;
  gap: 4px;
  align-items: center;
}

.property-key,
.property-value {
  padding: 4px 8px;
  border: 1px solid var(--ob-border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: var(--ob-bg);
  color: var(--ob-text);
}

.property-key {
  width: 35%;
  color: var(--ob-text-muted);
}

.property-value {
  flex: 1;
}

.property-key:focus, .property-value:focus {
  outline: none;
  border-color: var(--ob-brand);
}

.property-remove {
  background: none;
  border: none;
  color: var(--ob-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.property-remove:hover {
  background: var(--ob-danger-bg);
  color: var(--ob-danger);
}

/* Resizers */
.resizer {
  width: 4px;
  background: transparent;
  cursor: col-resize;
  flex-shrink: 0;
  transition: background 0.15s ease;
  z-index: 10;
}

.resizer.left-resizer {
  margin-left: -2px;
  margin-right: -2px;
}

.resizer.right-resizer {
  margin-left: -2px;
  margin-right: -2px;
}

.resizer:hover, .resizer.resizing {
  background: var(--ob-brand);
}

/* Internal Links */
.internal-link {
  color: var(--ob-brand);
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s;
  font-weight: 500;
}

.internal-link:hover {
  opacity: 0.8;
  text-decoration: underline;
}

/* Drag & Drop */
.note-item[draggable="true"] {
  user-select: none;
}

.note-item.dragging {
  opacity: 0.5;
  background: var(--ob-active);
}

.folder-header.drag-over {
  background: var(--ob-brand-light);
  color: #fff;
}

/* Inline Rename */
.folder-rename-input {
  background: var(--ob-bg);
  border: 1px solid var(--ob-brand);
  color: var(--ob-text);
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  width: 100%;
  padding: 0 4px;
  margin: 0;
  outline: none;
  border-radius: 2px;
}
