/* DittoRoo — stylesheet (dark theme, adapted from the Webroo design language) */

:root {
  --bg:        #0f0f0f;
  --surface:   #1a1a1a;
  --surface2:  #252525;
  --border:    #333;
  --text:      #e8e8e8;
  --text-dim:  #888;
  --accent:    #3ba776;   /* DittoRoo green */
  --accent-2:  #4fc78e;
  --danger:    #c0392b;
  --success:   #27ae60;
  --link:      #5aa9e6;
  --radius:    8px;
  --radius-sm: 4px;
}

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

/* Ensure [hidden] wins over component display rules (e.g. display:flex panes). */
[hidden] { display: none !important; }

html { font-size: 16px; }
body { background: var(--bg); color: var(--text); font-family: system-ui, sans-serif; min-height: 100vh; }

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .5rem 1.25rem; border-radius: var(--radius-sm); border: none;
  font-size: .9rem; font-weight: 600; cursor: pointer; transition: opacity .15s;
  color: var(--text); background: var(--surface2);
}
.btn:hover:not(:disabled) { opacity: .85; }
.btn:disabled { opacity: .5; cursor: default; }
.btn--primary { background: var(--accent); color: #06120c; }
.btn--ghost   { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn--danger  { background: var(--danger); color: #fff; }
.btn--sm      { padding: .35rem .75rem; font-size: .8rem; }
.btn--full    { width: 100%; }

/* ── Flash messages ──────────────────────────────────────────────────────── */

.flash-container { position: fixed; top: 1rem; right: 1rem; z-index: 999; display: flex; flex-direction: column; gap: .5rem; }
.flash { padding: .75rem 1rem; border-radius: var(--radius-sm); font-size: .9rem; max-width: 320px; }
.flash--error   { background: var(--danger);  color: #fff; }
.flash--success { background: var(--success); color: #fff; }
.flash--info    { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }

/* ── Landing / auth ──────────────────────────────────────────────────────── */

body.landing { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.landing__wrap { width: 100%; padding: 1rem; }
.landing__card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 400px; margin: 0 auto;
}
.landing__logo { display: flex; align-items: center; gap: .5rem; justify-content: center; margin-bottom: 1.5rem; }
.landing__logo-mark { font-size: 2rem; }
.landing__logo-name { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }
.landing__tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.landing__tab { flex: 1; text-align: center; padding: .6rem; font-size: .9rem; color: var(--text-dim); }
.landing__tab--active { color: var(--accent); border-bottom: 2px solid var(--accent); margin-bottom: -1px; }
.landing__divider { display: flex; align-items: center; text-align: center; color: var(--text-dim); font-size: .8rem; margin: 1.25rem 0; gap: .75rem; }
.landing__divider::before, .landing__divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ── Form fields ─────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.field label { font-size: .85rem; color: var(--text-dim); }
.field__input {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .6rem .75rem; color: var(--text);
  font-size: 1rem; width: 100%;
}
.field__input:focus { outline: none; border-color: var(--accent); }
.field__error { font-size: .8rem; color: var(--danger); }
.field--inline { flex-direction: row; align-items: center; gap: .5rem; }

/* ── Account page ────────────────────────────────────────────────────────── */

.account-page { max-width: 560px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.account-page__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.account-page__back { color: var(--text-dim); font-size: .9rem; }
.account-page__back:hover { color: var(--text); }
.account-page__logo { display: flex; align-items: center; gap: .4rem; font-weight: 700; }
.account-page__title { font-size: 1.5rem; margin-bottom: 1.5rem; }
.account-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.account-section__title { font-size: 1.05rem; margin-bottom: .35rem; }
.account-section__desc { font-size: .85rem; color: var(--text-dim); margin-bottom: 1rem; }
.account-section__empty { font-size: .9rem; color: var(--text-dim); margin-bottom: 1rem; }
.account-section__status { margin-top: .75rem; font-size: .85rem; }
.account-section__status--ok { color: var(--success); }
.account-section__status--error { color: var(--danger); }
.passkey-list { list-style: none; margin-bottom: 1rem; }
.passkey-item { display: flex; align-items: center; justify-content: space-between; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.passkey-item:last-child { border-bottom: none; }
.passkey-item__info { display: flex; flex-direction: column; }
.passkey-item__name { font-weight: 600; }
.passkey-item__meta { font-size: .75rem; color: var(--text-dim); }

/* ── Notes app layout ────────────────────────────────────────────────────── */

body.notes { overflow: hidden; }

/* Scope the grid to the container div (id=app), NOT body.notes which also
   carries no .app class now. */
.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100dvh;
}

/* Sidebar */
.sidebar {
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-height: 0;                    /* allow inner scroll */
}
.sidebar__head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1rem .75rem; }
.sidebar__brand { display: flex; align-items: center; gap: .4rem; font-weight: 700; font-size: 1.1rem; }
.sidebar__account { color: var(--text-dim); font-size: 1.2rem; line-height: 1; padding: .2rem; }
.sidebar__account:hover { color: var(--text); }
.sidebar__search { padding: 0 1rem .5rem; }
.sidebar__search-input {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .5rem .7rem; color: var(--text); font-size: .9rem;
}
.sidebar__search-input:focus { outline: none; border-color: var(--accent); }
.sidebar__new { margin: 0 1rem .75rem; width: calc(100% - 2rem); }

.note-list { list-style: none; overflow-y: auto; flex: 1; min-height: 0; padding-bottom: 1rem; }
.note-list__empty { color: var(--text-dim); font-size: .85rem; text-align: center; padding: 1rem; }

.note-item { padding: .7rem 1rem; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.note-item:hover { background: var(--surface2); }
.note-item--active { background: var(--surface2); border-left: 3px solid var(--accent); padding-left: calc(1rem - 3px); }
.note-item__title { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item__meta { font-size: .72rem; color: var(--text-dim); margin-top: .15rem; }
.note-item__snippet { font-size: .78rem; color: var(--text-dim); margin-top: .2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item__owner { display: inline-block; font-size: .68rem; color: var(--accent-2); margin-top: .2rem; }

.note-list__section { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); padding: .9rem 1rem .3rem; }

/* Editor */
.editor { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.editor__empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-dim); }
.editor__pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.editor__bar { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); }
.editor__title {
  flex: 1; background: transparent; border: none; color: var(--text);
  font-size: 1.3rem; font-weight: 700; min-width: 0;
}
.editor__title:focus { outline: none; }
.editor__bar-right { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }
.editor__status { font-size: .75rem; color: var(--text-dim); white-space: nowrap; }
.editor__owner { font-size: .75rem; color: var(--accent-2); white-space: nowrap; }

/* ── Modal (share dialog) ────────────────────────────────────────────────── */

.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.modal__panel {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; width: 100%; max-width: 380px; margin: 1rem;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.modal__title { font-size: 1.1rem; }
.modal__close { background: none; border: none; color: var(--text-dim); font-size: 1.1rem; cursor: pointer; line-height: 1; }
.modal__close:hover { color: var(--text); }
.modal__desc { font-size: .82rem; color: var(--text-dim); margin-bottom: 1rem; }

.share-form { display: flex; gap: .5rem; margin-bottom: .5rem; }
.share-form .field__input { flex: 1; }
.share-error { font-size: .8rem; color: var(--danger); margin-bottom: .5rem; }
.share-empty { font-size: .82rem; color: var(--text-dim); margin-top: .5rem; }
.share-list { list-style: none; margin-top: .5rem; }
.share-item { display: flex; align-items: center; justify-content: space-between; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.share-item:last-child { border-bottom: none; }
.share-item__name { font-size: .9rem; }
.share-item__remove { background: none; border: none; color: var(--danger); cursor: pointer; font-size: .85rem; }
.share-item__remove:hover { text-decoration: underline; }

/* The rendered (clickable-links) view and the textarea occupy the same space. */
.editor__rendered, .editor__content {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 1.5rem; font-size: 1rem; line-height: 1.6;
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
  font-family: inherit;
}
.editor__rendered { cursor: text; }
.editor__rendered:empty::before { content: "Start typing…"; color: var(--text-dim); }
.editor__rendered a { color: var(--link); text-decoration: underline; }
.editor__rendered a:hover { opacity: .8; }

.editor__content {
  background: var(--bg); border: none; color: var(--text); resize: none; width: 100%;
}
.editor__content:focus { outline: none; }

/* Lock banner + read-only affordance while someone else edits */
.editor__lock {
  padding: .55rem 1.5rem; font-size: .82rem; color: #f0c674;
  background: rgba(240,198,116,.08); border-bottom: 1px solid var(--border);
}
.editor--locked .editor__rendered { cursor: default; opacity: .75; }

.note-item__lock { color: #f0c674; font-size: .72rem; margin-top: .2rem; }

/* Mobile sidebar toggle (hidden on desktop) */
.sidebar-toggle {
  display: none; position: fixed; top: .75rem; left: .75rem; z-index: 20;
  width: 2.4rem; height: 2.4rem; border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  font-size: 1.1rem; cursor: pointer;
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 30% 0 0; z-index: 30;
    width: 84%; max-width: 340px;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 2px 0 16px rgba(0,0,0,.5);
  }
  .app--sidebar-open .sidebar { transform: translateX(0); }
  .app--sidebar-open .sidebar-backdrop { display: block; }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.5); }
  .sidebar-toggle { display: block; }
  .editor__bar { padding-left: 3.6rem; }   /* clear the toggle button */
}
