/* Notesweb application styles. Colors come from tokens.css via --nw-* variables. */

/* -------------------------------------------------------------------------- */
/* Reset                                                                      */
/* -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

html {
  font-size: var(--nw-font-size);
}

body {
  font-family: var(--nw-font);
  line-height: var(--nw-line-height);
  color: var(--nw-text);
  background: var(--nw-content-bg);
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--nw-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus {
  outline: none;
}

:focus-visible {
  box-shadow: var(--nw-focus-ring);
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: var(--nw-icon-size);
  height: var(--nw-icon-size);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.icon-fill {
  fill: currentColor;
  stroke: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* -------------------------------------------------------------------------- */
/* Shell: top bar                                                             */
/* -------------------------------------------------------------------------- */

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--nw-topbar-height);
  padding: 0 10px;
  background: var(--nw-topbar-bg);
  border-bottom: 1px solid var(--nw-border);
  flex-shrink: 0;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--nw-text);
  font-weight: 600;
  font-size: var(--nw-brand-size);
  padding: 0 4px;
  white-space: nowrap;
}

.topbar-brand:hover {
  text-decoration: none;
  color: var(--nw-text);
}

.topbar-brand-mark {
  width: var(--nw-icon-size);
  height: var(--nw-icon-size);
}

.topbar-spacer {
  flex: 1 1 auto;
}

.topbar-search {
  display: flex;
  align-items: center;
  width: 220px;
}

.topbar-search input {
  width: 100%;
  height: var(--nw-search-height);
  padding: 0 10px 0 28px;
  background: var(--nw-search-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a8886' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 8px 50%;
  border: 1px solid var(--nw-search-border);
  border-radius: var(--nw-radius-input);
  color: var(--nw-text);
}

.topbar-search input::placeholder {
  color: var(--nw-text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.topbar-link {
  color: var(--nw-text);
  padding: 4px 8px;
  border-radius: var(--nw-radius);
  font-size: var(--nw-muted-size);
}

.topbar-link:hover {
  background: var(--nw-nav-hover-bg);
  text-decoration: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--nw-icon-btn-size);
  height: var(--nw-icon-btn-size);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--nw-icon);
  border-radius: var(--nw-radius);
  cursor: pointer;
}

.icon-btn:hover,
.icon-btn[aria-expanded="true"] {
  background: var(--nw-nav-hover-bg);
  color: var(--nw-text);
  text-decoration: none;
}

.icon-btn.is-pressed,
.icon-btn.is-pressed:hover {
  background: var(--nw-row-selected-bg);
  color: var(--nw-accent);
}

.icon-btn.is-hidden-desktop,
.topbar-hamburger,
.topbar-kebab {
  display: none;
}

/* -------------------------------------------------------------------------- */
/* Shell: body + sidebar                                                      */
/* -------------------------------------------------------------------------- */

.app-body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  width: var(--nw-sidebar-width);
  background: var(--nw-sidebar-bg);
  border-right: 1px solid var(--nw-border);
  flex-shrink: 0;
  min-height: 0;
}

[data-sidebar="collapsed"] .sidebar {
  width: var(--nw-sidebar-rail);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--nw-row-height);
  padding: 0 14px;
  color: var(--nw-text);
  border: 0;
  background: transparent;
  text-decoration: none;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--nw-nav-hover-bg);
  text-decoration: none;
  color: var(--nw-text);
}

.nav-item.is-active {
  background: var(--nw-nav-active-bg);
  font-weight: 600;
}

.nav-item .icon {
  color: var(--nw-icon);
}

.nav-item.is-active .icon {
  color: var(--nw-text);
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-sidebar="collapsed"] .sidebar .nav-item {
  justify-content: center;
  padding: 0;
}

[data-sidebar="collapsed"] .sidebar .nav-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--nw-border);
}

.sidebar-collapse {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  height: var(--nw-row-height);
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: var(--nw-icon);
  cursor: pointer;
}

.sidebar-collapse:hover {
  background: var(--nw-nav-hover-bg);
  color: var(--nw-text);
}

[data-sidebar="collapsed"] .sidebar-collapse {
  justify-content: center;
  padding: 0;
}

.sidebar-collapse .icon-expand {
  display: none;
}

[data-sidebar="collapsed"] .sidebar-collapse .icon-collapse {
  display: none;
}

[data-sidebar="collapsed"] .sidebar-collapse .icon-expand {
  display: block;
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  overflow: auto;
  background: var(--nw-content-bg);
}

.public-main {
  flex: 1 1 auto;
  padding: 2rem 1rem 3rem;
  overflow: auto;
}

.public-card {
  width: 100%;
  max-width: 28rem;
  margin: 0 auto;
}

.public-card .content-title {
  margin: 0 0 1rem;
}

.icon-btn .theme-icon-moon {
  display: none;
}

[data-theme="light"] .icon-btn .theme-icon-sun {
  display: none;
}

[data-theme="light"] .icon-btn .theme-icon-moon {
  display: block;
}

.menu-label {
  cursor: default;
  font-weight: 600;
}

.card-heading {
  font-size: calc(var(--nw-font-size) + 2px);
  margin: 0 0 8px;
}

.card-narrow {
  max-width: 32rem;
}

.public-card-wide {
  max-width: 40rem;
}

/* -------------------------------------------------------------------------- */
/* Dropdowns (account, kebab, mobile nav)                                     */
/* -------------------------------------------------------------------------- */

.menu {
  position: relative;
}

.menu-panel,
.nav-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 200px;
  padding: 4px 0;
  background: var(--nw-surface);
  border: 1px solid var(--nw-border);
  box-shadow: var(--nw-shadow);
  z-index: 40;
}

.nav-dropdown {
  left: 0;
  right: auto;
  background: var(--nw-sidebar-bg);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: var(--nw-text);
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  font: inherit;
}

.menu-item:hover {
  background: var(--nw-nav-hover-bg);
  text-decoration: none;
  color: var(--nw-text);
}

.menu-item form {
  margin: 0;
  width: 100%;
}

.menu-divider {
  height: 1px;
  margin: 4px 0;
  background: var(--nw-border);
  border: 0;
}

.tooltip {
  position: fixed;
  z-index: 80;
  padding: 4px 8px;
  font-size: var(--nw-muted-size);
  line-height: 1.3;
  color: #fff;
  background: #323130;
  border-radius: var(--nw-radius);
  pointer-events: none;
  max-width: 220px;
}

[data-theme="light"] .tooltip {
  background: #323130;
}

/* -------------------------------------------------------------------------- */
/* Content header + note list                                                 */
/* -------------------------------------------------------------------------- */

.content-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 16px 20px 8px;
}

.content-title {
  margin: 0;
  font-size: var(--nw-title-size);
  font-weight: 600;
}

.content-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  width: 100%;
  padding: 4px 20px 12px;
  border-bottom: 1px solid var(--nw-border);
}

.content-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
}

.page-body {
  padding: 16px 20px 32px;
}

.note-list {
  display: flex;
  flex-direction: column;
}

.note-list-head,
.note-row {
  display: grid;
  grid-template-columns: 2.25rem 2.25rem minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 4px;
  min-height: var(--nw-row-height);
  padding: 0 20px;
}

.note-list-head {
  color: var(--nw-text-muted);
  font-size: var(--nw-muted-size);
  font-weight: 600;
  border-bottom: 1px solid var(--nw-border);
  min-height: 28px;
}

.note-list-head .note-col-updated {
  white-space: nowrap;
  padding-left: 16px;
}

.note-row {
  position: relative;
  border-bottom: 1px solid transparent;
  color: var(--nw-text);
  cursor: pointer;
}

.note-row:hover {
  background: var(--nw-row-hover-bg);
}

.note-row.is-selected {
  background: var(--nw-row-selected-bg);
  color: var(--nw-row-selected-fg);
}

.note-row-stretch {
  position: absolute;
  inset: 0;
  z-index: 0;
  grid-column: 1 / -1;
  grid-row: 1;
}

.note-star,
.note-lock,
.note-title,
.note-updated {
  position: relative;
  z-index: 1;
  grid-row: 1;
}

.note-star { grid-column: 1; }
.note-lock { grid-column: 2; }
.note-title { grid-column: 3; }
.note-updated { grid-column: 4; }

.note-list-head > span:nth-child(1) { grid-column: 1; }
.note-list-head > span:nth-child(2) { grid-column: 2; }
.note-list-head > span:nth-child(3) { grid-column: 3; }
.note-list-head > .note-col-updated { grid-column: 4; }

.note-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--nw-icon-btn-size);
  height: var(--nw-icon-btn-size);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--nw-text-muted);
  cursor: pointer;
  border-radius: var(--nw-radius);
}

.note-star:hover {
  color: var(--nw-text);
  background: var(--nw-nav-hover-bg);
}

.note-star.is-starred,
.note-star.is-starred:hover,
.icon-btn.is-starred,
.icon-btn.is-starred:hover {
  color: var(--nw-star);
}

.note-star.is-starred .icon,
.icon-btn.is-starred .icon {
  fill: currentColor;
  stroke: none;
}

.note-lock {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--nw-icon);
}

.note-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
  font-weight: 400;
  pointer-events: none;
}

.note-updated {
  color: var(--nw-text-muted);
  font-size: var(--nw-muted-size);
  white-space: nowrap;
  padding-left: 16px;
}

.empty-state {
  padding: 32px 20px;
  color: var(--nw-text-muted);
}

/* -------------------------------------------------------------------------- */
/* Buttons, forms, alerts                                                     */
/* -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--nw-control-height);
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--nw-radius);
  background: var(--nw-surface-alt);
  color: var(--nw-text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  text-decoration: none;
  filter: brightness(1.05);
}

.btn-primary {
  background: var(--nw-accent);
  border-color: var(--nw-accent);
  color: var(--nw-accent-fg);
}

.btn-primary:hover {
  background: var(--nw-accent-hover);
  border-color: var(--nw-accent-hover);
  color: var(--nw-accent-fg);
}

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

.btn-secondary:hover {
  background: var(--nw-nav-hover-bg);
}

.btn-danger {
  background: var(--nw-danger);
  border-color: var(--nw-danger);
  color: var(--nw-danger-fg);
}

.btn-danger:hover {
  background: var(--nw-danger-hover);
  border-color: var(--nw-danger-hover);
  color: var(--nw-danger-fg);
}

.btn-sm {
  height: var(--nw-control-height-sm);
  padding: 0 10px;
  font-size: var(--nw-muted-size);
}

.btn-block {
  width: 100%;
}

.btn-link {
  height: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--nw-accent);
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
}

.form-input {
  display: block;
  width: 100%;
  height: var(--nw-control-height);
  padding: 0 10px;
  background: var(--nw-search-bg);
  border: 1px solid var(--nw-search-border);
  border-radius: var(--nw-radius-input);
  color: var(--nw-text);
}

textarea.form-input {
  height: auto;
  padding: 8px 10px;
  resize: vertical;
  min-height: 12rem;
  font-family: var(--nw-font-mono);
  line-height: 1.5;
}

.form-input.is-invalid {
  border-color: var(--nw-danger);
}

.form-error {
  display: block;
  margin-top: 4px;
  color: var(--nw-danger);
  font-size: var(--nw-muted-size);
}

.form-hint {
  display: block;
  margin-top: 4px;
  color: var(--nw-text-muted);
  font-size: var(--nw-muted-size);
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.form-check input {
  accent-color: var(--nw-accent);
}

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

.form-actions + .form-check {
  margin-top: 14px;
}

.alert {
  position: relative;
  padding: 10px 36px 10px 14px;
  margin: 12px 20px 0;
  border: 1px solid;
  border-radius: var(--nw-radius);
}

.public-main .alert,
.page-body .alert {
  margin-left: 0;
  margin-right: 0;
}

.alert-success {
  background: var(--nw-success-bg);
  color: var(--nw-success-fg);
  border-color: var(--nw-success-border);
}

.alert-error {
  background: var(--nw-error-bg);
  color: var(--nw-error-fg);
  border-color: var(--nw-error-border);
}

.alert-warning {
  background: var(--nw-warning-bg);
  color: var(--nw-warning-fg);
  border-color: var(--nw-warning-border);
}

.alert-info {
  background: var(--nw-info-bg);
  color: var(--nw-info-fg);
  border-color: var(--nw-info-border);
}

.alert-dismiss {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  border-radius: var(--nw-radius);
}

.muted {
  color: var(--nw-text-muted);
}

.text-center {
  text-align: center;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--nw-surface);
  border: 1px solid var(--nw-border);
  border-radius: var(--nw-radius);
  padding: 16px;
}

.note-meta {
  color: var(--nw-text-muted);
  font-size: var(--nw-muted-size);
  margin: 0 0 16px;
}

.note-command {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--nw-border);
}

.note-command form {
  display: flex;
  margin: 0;
}

.note-command-sep {
  width: 1px;
  height: 16px;
  margin: 0 6px;
  background: var(--nw-search-border);
  flex-shrink: 0;
}

.note-command + .content-header {
  padding-top: 14px;
}

.icon-btn.note-command-delete:hover {
  color: var(--nw-danger);
}

.note-command-print {
  margin-left: auto;
}

.content-wrapper {
  max-width: 52rem;
  font-size: var(--nw-content-font-size);
  line-height: var(--nw-content-line-height);
}

.content-wrapper pre {
  background: var(--nw-code-bg);
  border-radius: 8px;
  padding: 1rem;
  overflow: auto;
}

.content-wrapper code {
  font-family: var(--nw-font-mono);
  font-size: 0.9em;
}

.content-wrapper h1,
.content-wrapper h2,
.content-wrapper h3 {
  margin-top: 1.4em;
}

.content-wrapper p {
  margin: 0.75em 0;
}

.sort-control {
  color: var(--nw-text-muted);
  font-size: var(--nw-muted-size);
}

.sort-control a {
  color: var(--nw-accent);
}

.sort-control strong {
  color: var(--nw-text);
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .nav-item,
  .btn {
    transition: none;
  }
}

/* -------------------------------------------------------------------------- */
/* Mobile                                                                     */
/* -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .topbar-search,
  .topbar-desktop-actions {
    display: none;
  }

  .topbar-hamburger,
  .topbar-kebab {
    display: inline-flex;
  }

  .content-header {
    padding: 12px 14px 4px;
  }

  .note-command {
    padding: 8px 14px;
  }

  .content-toolbar {
    padding: 4px 14px 10px;
  }

  .page-body {
    padding: 12px 14px 24px;
  }

  .content-toolbar-extra {
    display: none;
  }
}

/*
  Stacked note rows on phones/tablets (including iPad Pro).
  Matches the comfort token query in tokens.css so type and layout
  grow together. Hamburger layout stays at 768px above.
*/
@media (max-width: 1024px), (pointer: coarse) {
  .note-list-head {
    display: none;
  }

  .note-row {
    grid-template-columns: var(--nw-icon-btn-size) var(--nw-icon-btn-size) minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: start;
    column-gap: 4px;
    row-gap: 2px;
    padding: 10px 16px;
  }

  .note-star,
  .note-lock {
    grid-row: 1 / span 2;
    align-self: center;
    width: var(--nw-icon-btn-size);
    height: var(--nw-icon-btn-size);
  }

  .note-title {
    grid-column: 3;
    grid-row: 1;
    white-space: normal;
    text-overflow: unset;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .note-updated {
    grid-column: 3;
    grid-row: 2;
    padding-left: 0;
  }

  .note-row-stretch {
    grid-row: 1 / span 2;
  }

  .menu-item {
    min-height: 44px;
  }
}

/* -------------------------------------------------------------------------- */
/* Print                                                                      */
/* -------------------------------------------------------------------------- */

@media print {
  html,
  body,
  .app-body,
  .app-main {
    height: auto;
    overflow: visible;
    background: var(--nw-content-bg);
  }

  body {
    display: block;
    color: var(--nw-text);
  }

  .app-body,
  .app-main {
    display: block;
  }

  .topbar,
  .sidebar,
  .note-command,
  .alert,
  .tooltip {
    display: none;
  }

  .content-header,
  .page-body {
    padding: 0;
  }

  .content-header {
    padding-bottom: 8px;
  }
}
