/* Hide main content while keeping SweetAlert2 dialogs visible */
.hidden-content #main-content,
.hidden-content #main-title,
.hidden-content .task-control,
.hidden-content .row.mt-3 {
  visibility: hidden;
}

body:not(.hidden-content) #main-content,
body:not(.hidden-content) #main-title,
body:not(.hidden-content) .task-control,
body:not(.hidden-content) .row.mt-3 {
  visibility: visible;
}

/* List styles */
.container li {
  cursor: grab;
}

/* Default desktop height */
.todo-container,
.in-progress-container {
  min-height: 300px;
  max-height: 640px;
  overflow-y: auto;
}

/* Dragging background */
.blue-background-class {
  background-color: #f0f0f0 !important;
}

.custom-mt {
  margin-top: 2rem;
}

/* Spinner loading */
.spinner {
  display: inline-block;
  width: 17px;
  height: 17px;
  border: 2px solid white;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Notebook fullscreen mode */
body.notebook-active {
  height: 100dvh;
  overflow: hidden;
}

body.notebook-active > .row.mt-3,
body.notebook-active #restore-backup {
  display: none;
}

body.notebook-active .swal2-container {
  z-index: 10050;
}

#note-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 9998;
  background-color: #1e1e1e;
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0;
  border: none;
}

.note-workspace {
  display: grid;
  grid-template-columns: minmax(220px, 18vw) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  flex: 1;
  min-height: 0;
}

.note-sidebar {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  color: #c8c8c8;
  background: #181818;
  border-right: 1px solid #333;
}

.note-sidebar-title,
.note-outline-title {
  padding: 10px 12px 6px;
  color: #8d8d8d;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.note-sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.note-block-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  letter-spacing: 0;
}

.note-block-actions button {
  min-width: 22px;
  padding: 2px 5px;
  color: #bdbdbd;
  background: #222;
  border: 1px solid #3b3b3b;
  border-radius: 3px;
  font-size: 0.65rem;
  line-height: 1.2;
}

.note-block-actions button:hover,
.note-block-actions button:focus-visible {
  color: #fff;
  background: #303030;
  outline: none;
}

.note-file-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  color: #f0f0f0;
  background: #262626;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.86rem;
}

.note-block-count {
  margin-left: auto;
  color: #868686;
  font-size: 0.68rem;
}

.note-file-icon {
  color: #b8b8b8;
}

.note-outline {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 2px 0 12px;
  overflow-y: auto;
  list-style: none;
}

.note-block-list {
  max-height: 34%;
  min-height: 72px;
  margin: 0;
  padding: 3px 0 8px;
  overflow-y: auto;
  border-bottom: 1px solid #292929;
  list-style: none;
}

.note-block-item {
  width: 100%;
  overflow: hidden;
  padding: 6px 10px 6px 24px;
  color: #c8c8c8;
  background: transparent;
  border: 0;
  font-size: 0.82rem;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-block-item::before {
  margin-right: 7px;
  color: #8f8f8f;
  content: "▸";
}

.note-block-item:hover,
.note-block-item:focus,
.note-block-item:focus-visible {
  color: #fff;
  background: #2a2d2e;
  outline: none;
}

.note-block-item.is-active {
  color: #f0f0f0;
  background: #242424;
}

.note-block-item.is-active:focus,
.note-block-item.is-active:focus-visible {
  background: #3a3a3a;
}

.note-outline-item {
  width: 100%;
  overflow: hidden;
  padding: 5px 10px 5px
    calc(14px + (var(--outline-depth, 0) * 14px));
  color: #c8c8c8;
  background: transparent;
  border: 0;
  font-size: 0.82rem;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-outline-item::before {
  margin-right: 7px;
  color: #9a9a9a;
  content: "#";
}

.note-outline-item:hover,
.note-outline-item:focus,
.note-outline-item:focus-visible {
  color: #fff;
  background: #2a2d2e;
  outline: none;
}

.note-outline-item.is-active {
  color: #f0f0f0;
  background: #242424;
}

.note-outline-item.is-active:focus,
.note-outline-item.is-active:focus-visible {
  background: #3a3a3a;
}

.note-outline-empty {
  padding: 8px 14px;
  color: #777;
  font-size: 0.78rem;
  line-height: 1.4;
}

.note-sidebar-help {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 9px 12px;
  color: #777;
  border-top: 1px solid #2b2b2b;
  font-size: 0.72rem;
}

.note-sidebar-help kbd {
  min-width: 19px;
  padding: 1px 5px;
  color: #bbb;
  background: #2b2b2b;
  border: 1px solid #444;
  border-radius: 3px;
  box-shadow: none;
  font-size: 0.68rem;
  text-align: center;
}

.note-editor-pane {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}

.note-editor-header {
  display: flex;
  gap: 12px;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  color: #aaa;
  background: #202020;
  border-bottom: 1px solid #333;
  font-size: 0.78rem;
}

.note-editor-file {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  color: #ddd;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: nowrap;
}

.note-editor-file span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-editor-file img {
  width: 16px;
  height: 16px;
  filter: grayscale(1);
}

.note-editor-hint {
  flex: 0 0 auto;
  color: #a8a8a8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.note-control-bar {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  min-height: 32px;
  grid-column: 1 / -1;
  grid-row: 2;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 8px;
  color: #d0d0d0;
  background: #181818;
  border-top: 1px solid #383838;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
}

.note-control-left,
.note-control-right {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
}

.note-control-left {
  flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.note-control-left::-webkit-scrollbar {
  display: none;
}

.note-control-right {
  flex: 0 0 auto;
}

.note-control-bar button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  color: #d0d0d0;
  background: transparent;
  border: 0;
  border-radius: 3px;
  font: inherit;
  white-space: nowrap;
}

.note-control-bar button:hover,
.note-control-bar button:focus-visible {
  background: #303030;
  outline: none;
}

.note-control-bar kbd {
  padding: 1px 4px;
  color: #c8c8c8;
  background: #252525;
  border: 1px solid #484848;
  border-radius: 3px;
  box-shadow: none;
  font-size: 0.66rem;
  white-space: nowrap;
}

.note-status-file {
  color: #c0c0c0;
}

.note-status-mode {
  flex: 0 0 auto;
  min-width: 58px;
  padding: 3px 7px;
  color: #161616;
  background: #bdbdbd;
  border-radius: 3px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.note-status-cursor {
  color: #b8b8b8;
  white-space: nowrap;
}

#note-container.sidebar-hidden .note-workspace {
  grid-template-columns: 0 minmax(0, 1fr);
}

#note-container.sidebar-hidden .note-sidebar {
  display: none;
}

#note-container.outline-collapsed .note-outline-item[data-level]:not([data-level="1"]) {
  display: none;
}

.note-command-palette {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  background: rgb(0 0 0 / 45%);
}

.note-palette-panel {
  width: min(620px, calc(100vw - 32px));
  overflow: hidden;
  color: #d0d0d0;
  background: #202020;
  border: 1px solid #505050;
  border-radius: 7px;
  box-shadow: 0 18px 60px rgb(0 0 0 / 55%);
}

.note-palette-label {
  padding: 8px 12px 4px;
  color: #888;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.note-palette-input {
  width: calc(100% - 20px);
  margin: 4px 10px 8px;
  padding: 9px 10px;
  color: #eee;
  background: #151515;
  border: 1px solid #555;
  border-radius: 4px;
  outline: none;
}

.note-palette-input:focus {
  border-color: #999;
}

.note-palette-results {
  max-height: 46vh;
  padding: 3px 6px;
  overflow-y: auto;
}

.note-palette-result {
  display: block;
  width: 100%;
  padding: 7px 9px;
  overflow: hidden;
  color: #d0d0d0;
  background: transparent;
  border: 0;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-palette-result:hover,
.note-palette-result:focus-visible {
  background: #333;
  outline: none;
}

.note-palette-empty,
.note-palette-footer {
  padding: 8px 12px;
  color: #888;
  font-size: 0.72rem;
}

.note-palette-footer {
  border-top: 1px solid #3a3a3a;
}

/* CodeMirror fill */
#note-container #editor {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

#note-container .CodeMirror {
  height: 100% !important;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Fixed bottom buttons */
.row.mt-3 {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 10px 15px;
  background-color: #1e1e1e;
  z-index: 9999;
}

#restore-backup {
  position: fixed;
  right: 14px;
  bottom: 72px;
  z-index: 10000;
  min-width: 48px;
  padding: 4px 8px;
  font-size: 0.8rem;
}

/* ========================= */
/* Mobile */
/* ========================= */
@media (max-width: 767.98px) {
  #main-title {
    font-size: 1.5rem;
    margin-top: 1rem;
    text-align: center;
  }

  /* Reduced list height */
  .todo-container {
    min-height: 120px;
    max-height: 12vh;
  }

  .in-progress-container {
    min-height: 120px;
    max-height: 60vh;
  }

  .list-group-item button {
    font-size: 0.75rem;
    padding: 2px 6px;
  }

  #note-container .CodeMirror {
    font-size: 0.86rem;
  }

  #note-container .CodeMirror-linenumber {
    padding: 0 3px 0 2px;
    font-size: 0.68rem;
  }

  #note-container .CodeMirror-gutters {
    display: none;
  }

  #note-container .CodeMirror-sizer {
    margin-left: 0 !important;
  }

  .note-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }

  #note-container.sidebar-hidden .note-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .note-sidebar {
    display: none;
  }

  #note-container.sidebar-focused::before {
    position: absolute;
    inset: 0;
    z-index: 11;
    background: rgb(0 0 0 / 48%);
    content: "";
  }

  #note-container.sidebar-focused .note-sidebar {
    position: absolute;
    inset: auto 10px 48px;
    z-index: 12;
    display: flex;
    width: auto;
    max-height: min(72dvh, 520px);
    border: 1px solid #424242;
    border-radius: 12px;
    box-shadow: 0 18px 54px rgb(0 0 0 / 62%);
  }

  #note-container.sidebar-focused .note-block-list {
    max-height: 38dvh;
  }

  .note-editor-pane {
    grid-column: 1 / -1;
    grid-row: 1;
    height: 100%;
  }

  .note-editor-header {
    min-height: 34px;
    padding: 0 10px;
    gap: 8px;
  }

  .note-editor-file {
    font-size: 0.74rem;
  }

  .note-editor-hint {
    font-size: 0.56rem;
  }

  .note-control-bar {
    grid-column: 1;
    grid-row: 2;
    gap: 4px 8px;
    padding: 5px 6px;
    font-size: 0.6rem;
  }

  .note-control-bar button span,
  .note-status-file {
    display: none;
  }

  .note-control-bar button {
    padding: 3px 4px;
  }

  .note-control-bar kbd {
    padding: 1px 3px;
    font-size: 0.54rem;
  }

  .note-control-left,
  .note-control-right {
    gap: 2px;
  }

  .note-status-mode {
    min-width: 54px;
    padding: 3px 5px;
  }

  .note-status-cursor {
    font-size: 0.56rem;
  }

  .list-group-item {
    font-size: 0.95rem;
  }

  .btn {
    font-size: 0.95rem;
  }

  #add-task {
    margin-bottom: 65px;
  }

  .card-header {
    font-size: 1rem;
    text-align: center;
  }

  .row.mt-3 button {
    width: 45% !important;
    margin: 0 5px;
  }

  #restore-backup {
    top: 10px;
    right: 10px;
    bottom: auto;
    min-width: 44px;
    font-size: 0.75rem;
  }
}

.hidden {
  display: none !important;
}

/* ========================= */
/* Tablet / medium screens */
/* ========================= */
@media (min-width: 768px) and (max-width: 1399.98px) {
  #main-title {
    font-size: 2rem;
    margin-top: 10px;
  }

  .todo-container,
  .in-progress-container {
    max-height: 55vh;
  }

  .list-group-item {
    font-size: 1rem;
  }

  .btn {
    font-size: 0.95rem;
  }
}

/* ========================= */
/* Large screens */
/* ========================= */
@media (min-width: 1400px) {
  #main-title {
    font-size: 2.5rem;
    margin-top: 1.5rem;
  }

  .todo-container,
  .in-progress-container {
    max-height: 640px;
  }

  .list-group-item {
    font-size: 1.05rem;
  }

  .btn {
    font-size: 1rem;
  }
}
