/* ===== PetrarcaNotes — App Layout CSS ===== */

/* ===== Layout ===== */
.main-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin-left: 300px;
  transition: margin-left 0.3s ease;
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 300px;
  background: var(--bg-dark);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.25rem 0;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}
.brand-logo {
  width: 30px; height: 30px;
  border-radius: 8px;
  object-fit: contain;
}
.brand-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--crimson-soft);
  letter-spacing: 0.01em;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.sidebar-close svg { width: 18px; height: 18px; }
.sidebar-close:hover { color: var(--text-primary); }

/* Search */
.sidebar-search {
  padding: 1rem 1rem 0.5rem;
  flex-shrink: 0;
}
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 0.75rem;
  width: 15px; height: 15px;
  color: var(--text-faint);
  pointer-events: none;
  flex-shrink: 0;
}
.sidebar-search input {
  padding-left: 2.25rem;
  padding-right: 2rem;
  font-size: 0.875rem;
  background: var(--bg-void);
}
.search-clear {
  position: absolute;
  right: 0.6rem;
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
  display: none;
  transition: color var(--transition);
}
.search-clear.visible { display: block; }
.search-clear:hover { color: var(--crimson-soft); }

/* Notes list header */
.notes-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem 0.5rem;
  flex-shrink: 0;
}
.notes-list-header span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  font-weight: 500;
}
.btn-new-sm {
  background: var(--crimson);
  border: none;
  color: #fff;
  width: 26px; height: 26px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), transform var(--transition);
  flex-shrink: 0;
}
.btn-new-sm svg { width: 14px; height: 14px; }
.btn-new-sm:hover { background: var(--crimson-glow); transform: scale(1.1); }

/* Notes list */
.notes-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 0 0.5rem 1rem;
}

.note-item {
  padding: 0.875rem 0.875rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  margin-bottom: 0.25rem;
  position: relative;
}
.note-item:hover { background: var(--bg-surface); }
.note-item.active {
  background: rgba(192,57,43,0.08);
  border-color: rgba(192,57,43,0.3);
}
.note-item-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}
.note-item.active .note-item-title { color: var(--crimson-soft); }
.note-item-preview {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.note-item-date {
  font-size: 0.7rem;
  color: var(--text-faint);
  margin-top: 0.35rem;
}

.notes-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
  color: var(--text-faint);
  text-align: center;
  gap: 0.75rem;
}
.notes-empty svg { width: 36px; height: 36px; }
.notes-empty p { font-size: 0.85rem; }

/* Sidebar footer */
.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
}
.user-info { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--crimson-deep);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-details { min-width: 0; }
.user-email {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.user-plan {
  display: block;
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}
.btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.btn-logout svg { width: 16px; height: 16px; }
.btn-logout:hover { border-color: var(--crimson); color: var(--crimson-soft); }

/* Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ===== Topbar (mobile) ===== */
.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}
.menu-toggle, .btn-new-top {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem;
  display: flex;
  transition: color var(--transition);
}
.menu-toggle svg, .btn-new-top svg { width: 20px; height: 20px; }
.menu-toggle:hover, .btn-new-top:hover { color: var(--crimson-soft); }
.btn-new-top {
  background: var(--crimson);
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 0.4rem;
  transition: background var(--transition);
}
.btn-new-top:hover { background: var(--crimson-glow); color: #fff; }
.topbar-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--crimson-soft);
}

/* ===== Editor area ===== */
.editor-area {
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
}

/* Empty state */
.editor-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  gap: 1rem;
  animation: fadeUp 0.4s ease both;
}
.empty-icon {
  width: 72px; height: 72px;
  background: rgba(192,57,43,0.08);
  border: 1px solid rgba(192,57,43,0.2);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}
.empty-icon svg { width: 32px; height: 32px; color: var(--crimson); }
.editor-empty h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--text-primary);
}
.editor-empty p { color: var(--text-muted); font-size: 0.9rem; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* Editor pane */
.editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fadeUp 0.25s ease both;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-dark);
  flex-shrink: 0;
}
.editor-toolbar-left, .editor-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.back-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: none;
  align-items: center;
  transition: color var(--transition);
}
.back-btn svg { width: 20px; height: 20px; }
.back-btn:hover { color: var(--crimson-soft); }
.save-indicator {
  font-size: 0.75rem;
  color: var(--text-faint);
  letter-spacing: 0.03em;
}
.save-indicator.saving { color: var(--crimson); }
.save-indicator.saved  { color: #2ecc71; }

.btn-sm {
  padding: 0.45rem 0.875rem;
  font-size: 0.8rem;
}
.btn-danger {
  background: rgba(192,57,43,0.15);
  color: var(--crimson-soft);
  border: 1px solid rgba(192,57,43,0.3);
}
.btn-danger:hover {
  background: var(--crimson);
  color: #fff;
  border-color: var(--crimson);
}

/* Editor content */
.editor-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

.field-block { display: flex; flex-direction: column; gap: 0.5rem; }
.field-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  font-weight: 500;
}

.note-title-input {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 0.5rem 0;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.note-title-input:focus {
  border-bottom-color: var(--crimson);
  box-shadow: none;
}
.note-title-input::placeholder { color: var(--text-faint); font-style: italic; }

.note-body-input {
  font-size: 0.95rem;
  line-height: 1.8;
  min-height: 300px;
  resize: vertical;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0.75rem 0;
  font-style: italic;
  color: var(--text-primary);
}
.note-body-input:focus { box-shadow: none; border-bottom: 1px solid var(--border); }
.note-body-input::placeholder { color: var(--text-faint); }

.editor-meta {
  font-size: 0.75rem;
  color: var(--text-faint);
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ===== Confirm dialog ===== */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.dialog-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-card);
  animation: cardIn 0.3s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes cardIn {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1);    }
}
.dialog-box h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}
.dialog-box p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}
.dialog-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    box-shadow: var(--shadow-card);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }

  .main-layout { margin-left: 0; }
  .topbar { display: flex; }

  .editor-toolbar { padding: 0.75rem 1rem; }
  .back-btn { display: flex; }

  .editor-content { padding: 1.25rem 1rem; }
  .note-title-input { font-size: 1.3rem; }

  /* On mobile, show list OR editor, not both */
  .editor-pane .back-btn { display: flex; }
}

@media (min-width: 769px) {
  .back-btn { display: none !important; }
}

@media (max-width: 420px) {
  .editor-content { padding: 1rem 0.875rem; }
  .note-title-input { font-size: 1.2rem; }
}
