@import url("./reset.css");

@import url("https://esm.sh/prosemirror-view/style/prosemirror.css");
@import url("https://esm.sh/prosemirror-menu/style/menu.css");
@import url("https://esm.sh/prosemirror-example-setup/style/style.css");
@import url("https://esm.sh/prosemirror-gapcursor/style/gapcursor.css");

html {
  --font:
    system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
    "Open Sans", "Helvetica Neue", sans-serif;
  font-family: var(--font);
}

input,
select,
textarea {
  flex: 1;
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.875rem;
  background: #fff;
  transition: border-color 0.15s;

  &:focus {
    outline-offset: 1px;
    outline: 2px solid rgba(from blue r g b / 0.5);
  }
}

actor-typeahead {
  flex: 1;
}

button,
.ProseMirror-menuitem .share-menu-button {
  padding: 0.4rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  font-size: 0.875rem;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;

  &:hover {
    background: #f5f5f5;
  }

  &:active {
    background: #eee;
  }
}

label {
  display: block;
  flex: 1;
  width: 100%;
  font-size: 0.75rem;
}

html,
body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.login {
  margin: auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.login-blurb {
  font-size: 0.75rem;
}

.loading {
  display: flex;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  opacity: 0;
  animation: 1s fade-in 1s forwards;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

#editor {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0;
  font-family: ui-serif, Georgia, serif;
  font-size: 1rem;
  line-height: 1.6;
}

.ProseMirror {
  min-height: 100%;
  outline: none;
  padding: 1rem;
  margin-trim: block;

  > :first-child,
  > :first-child p {
    margin-top: 0;
  }

  > :last-child,
  > :last-child p {
    margin-bottom: 0;
  }
}

.ProseMirror-menubar-wrapper {
  height: 100%;
}

.ProseMirror-menubar {
  display: flex;
  padding-right: 0;
}

.ProseMirror-menuitem {
  align-self: center;
}

.ProseMirror-menuitem:has(.toolbar-right) {
  margin-left: auto;
  padding: 4px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

dialog {
  overflow: visible;
  place-self: center;
  width: 100%;
  max-width: 720px;
  border: none;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);

  &::backdrop {
    background: rgba(0, 0, 0, 0.25);
  }

  header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #dddddd;
  }

  > * {
    padding: 12px;
  }
}

.icon-button {
  all: unset;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  border-radius: 4px;
  color: #888;

  &:hover {
    color: #333;
    background: #f0f0f0;
  }
}

#editors {
  ul {
    list-style: none;
  }

  &:empty {
    display: none;
  }

  > li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;

    .avatar {
      width: 32px;
      height: 32px;
      border-radius: 50%;
    }

    .member-info {
      flex: 1;
      display: flex;
      flex-direction: column;
      min-width: 0;
      overflow: hidden;

      strong {
        font-size: 0.875rem;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
      }

      small {
        font-size: 0.75rem;
        color: #888;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
      }
    }
  }
}

.copy-link {
  display: flex;
  align-items: center;
  background: #f5f5f5;
  border-radius: 4px;

  input {
    all: unset;
    flex: 1;
    color: #666;
    padding: 0.4rem 0.5rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
  }

  .icon-button {
    flex-shrink: 0;
  }
}

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

#add-member {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.readonly-banner {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: #f8f8f8;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: #666;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  z-index: 10;
  white-space: nowrap;
  animation: 0.3s fade-in;
}

.collab-cursor {
  position: relative;
  border-left: 2px solid var(--color);
  margin-left: -1px;
  pointer-events: none;
}

.collab-cursor::after {
  content: attr(data-name);
  position: absolute;
  top: -1.4em;
  left: -2px;
  background: var(--color);
  color: white;
  font-size: 0.7rem;
  font-family: sans-serif;
  padding: 0 4px;
  border-radius: 3px 3px 3px 0;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Devtools panel ── */

.devtools-resize-handle {
  height: 6px;
  margin-top: -3px;
  margin-bottom: -3px;
  position: relative;
  z-index: 10;
  cursor: ns-resize;
  flex-shrink: 0;
}

.devtools-panel {
  display: flex;
  flex-direction: column;
  border-top: 1px solid #ddd;
  background: #fff;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas,
    "DejaVu Sans Mono", monospace;
  font-size: 12px;
}

.devtools-header {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
  height: 32px;
  padding: 0 6px;
  flex-shrink: 0;
}

.devtools-tabs {
  display: flex;
  height: 100%;
  margin-right: 4px;

  button {
    all: unset;
    padding: 0 10px;
    font-size: 11px;
    font-family: var(--font);
    cursor: pointer;
    color: #666;
    border-bottom: 2px solid transparent;
    height: 100%;

    &:hover {
      color: #333;
      background: rgba(0, 0, 0, 0.05);
    }

    &.active {
      color: #1a73e8;
      border-bottom-color: #1a73e8;
    }
  }
}

.devtools-pause {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-family: var(--font);
  padding: 3px 6px !important;
}

.devtools-pause,
.devtools-close {
  padding: 4px !important;
  color: #888;
}

.devtools-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.devtools-tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.devtools-subtabs {
  display: flex;
  flex-shrink: 0;
  border-bottom: 1px solid #e8e8e8;
  padding: 0 4px;
  overflow-x: auto;

  button {
    all: unset;
    padding: 3px 10px;
    font-size: 11px;
    font-family: var(--font);
    cursor: pointer;
    color: #888;
    border-bottom: 2px solid transparent;
    white-space: nowrap;

    &:hover { color: #333; }
    &.active { color: #1a73e8; border-bottom-color: #1a73e8; }
  }
}

.devtools-body-inner {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-width: 0;
  min-height: 0;

  &:not(.has-detail) {
    overflow-y: auto;
  }

  &.has-detail > .devtools-timeline {
    width: 340px;
    flex-shrink: 0;
    border-right: 1px solid #e8e8e8;
  }
}

.devtools-empty {
  color: #999;
  text-align: center;
  padding: 24px;
  font-family: var(--font);
}

/* Timeline tab */

.devtools-timeline {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.devtools-entry {
  border: 1px solid #eee;
  border-radius: 5px;
  padding: 7px 9px;
  background: #fafafa;
  cursor: pointer;

  &:hover {
    background: #f0f4ff;
    border-color: #c8d8ff;
  }

  &.active {
    background: #e8f0fe;
    border-color: #4285f4;
  }
}

.devtools-entry-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}

.devtools-entry-index {
  font-size: 10px;
  font-weight: 700;
  color: #bbb;
  min-width: 14px;
}

.devtools-entry-author {
  font-weight: 600;
  font-size: 11px;
  font-family: var(--font);
}

.devtools-entry-time {
  font-size: 10px;
  color: #aaa;
  margin-left: auto;
}

.devtools-entry-uri {
  font-size: 10px;
  color: #1a73e8;
  margin-bottom: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.devtools-entry-json {
  font-size: 10px;
  color: #555;
  margin: 0;
  white-space: pre;
  line-height: 1.5;
  overflow: hidden;
  max-height: 60px;
}

/* Detail panel */

.devtools-detail {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  min-width: 0;
}

.devtools-detail-meta {
  font-size: 11px;
  color: #888;
  margin-bottom: 10px;
  font-family: var(--font);
}

.devtools-detail-label {
  font-size: 10px;
  font-weight: 600;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 10px 0 4px;
}

.devtools-ops {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;

  th {
    text-align: left;
    color: #aaa;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px 4px 0;
    border-bottom: 1px solid #eee;
  }

  td {
    padding: 3px 8px 3px 0;
    vertical-align: top;
    border-bottom: 1px solid #f5f5f5;
  }
}

.devtools-op-num {
  color: #888;
  white-space: nowrap;
}

.devtools-op-desc {
  color: #333;
  word-break: break-word;
}

/* Doc Record tab */

.devtools-doc {
  padding: 10px;
  overflow-y: auto;
  flex: 1;
}

.devtools-doc-uri {
  font-size: 11px;
  color: #1a73e8;
  margin-bottom: 8px;
  word-break: break-all;
}

.devtools-doc-json {
  font-size: 12px;
  color: #333;
  margin: 0;
  white-space: pre;
  line-height: 1.5;
}
