/* =======================================================
   sidebar.css
   Floating notes panel + writing canvas
   ======================================================= */

.open-sidebar-btn {
  position: fixed;
  right: 1.05rem;
  bottom: calc(var(--footer-height) + 0.9rem);
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: linear-gradient(140deg, #1d8ed6 0%, #1779bd 55%, #1ab097 100%);
  color: #ffffff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.06rem;
  box-shadow: 0 16px 32px rgba(11, 76, 122, 0.36);
  border: 1px solid rgba(219, 241, 255, 0.42);
  z-index: 1265;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.open-sidebar-btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 20px 34px rgba(11, 76, 122, 0.42);
}

.open-sidebar-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 2px;
}

.sidebar {
  position: fixed;
  top: calc(var(--navbar-height) + 0.5rem);
  left: 0.72rem;
  width: clamp(320px, 34vw, 620px);
  height: clamp(420px, 62vh, 760px);
  min-width: 260px;
  min-height: 260px;
  max-width: calc(100vw - 1rem);
  max-height: calc(100dvh - var(--navbar-height) - 1rem);
  background:
    radial-gradient(circle at 88% -12%, rgba(16, 163, 213, 0.24), transparent 44%),
    linear-gradient(162deg, #182f45 0%, #1d3a53 52%, #172f45 100%);
  border: 1px solid rgba(200, 228, 247, 0.34);
  border-radius: 20px;
  box-shadow: 0 24px 44px rgba(8, 22, 36, 0.44);
  backdrop-filter: blur(8px);
  color: #f4f9ff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1260;
}

.sidebar.dragging,
.sidebar.resizing {
  box-shadow:
    0 28px 52px rgba(6, 14, 24, 0.58),
    0 0 0 2px rgba(20, 157, 216, 0.3);
}

.sidebar-header {
  min-height: 86px;
  padding: 0.68rem 0.72rem 0.72rem;
  border-bottom: 1px solid rgba(218, 236, 250, 0.2);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.04));
  display: grid;
  gap: 0.42rem;
  align-items: center;
  cursor: move;
}

.sidebar-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-sync-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: fit-content;
  max-width: 100%;
  border-radius: 999px;
  padding: 0.26rem 0.56rem;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  font-weight: 800;
  border: 1px solid rgba(214, 235, 249, 0.38);
  background: rgba(15, 36, 53, 0.45);
  color: #ecf6ff;
}

.sidebar-sync-status .sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #95b4cc;
}

.sidebar-sync-status .sync-text {
  white-space: nowrap;
}

.sidebar-sync-status--saved .sync-dot {
  background: #5fd7a4;
  box-shadow: 0 0 0 3px rgba(95, 215, 164, 0.18);
}

.sidebar-sync-status--dirty .sync-dot {
  background: #ffc86d;
  box-shadow: 0 0 0 3px rgba(255, 200, 109, 0.18);
}

.sidebar-sync-status--saving .sync-dot {
  background: #74b9ff;
  box-shadow: 0 0 0 3px rgba(116, 185, 255, 0.18);
}

.sidebar-sync-status--error .sync-dot {
  background: #ff8a7f;
  box-shadow: 0 0 0 3px rgba(255, 138, 127, 0.2);
}

.sidebar-kicker {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 800;
  color: #d7e8f8;
}

.sidebar-hint {
  font-size: 0.7rem;
  color: rgba(229, 239, 249, 0.78);
}

.sidebar-header #noteTitle {
  width: 100%;
  height: 42px;
  border-radius: 11px;
  border: 1px solid rgba(214, 235, 249, 0.38);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.13));
  color: #f5fbff;
  font-size: 0.96rem;
  font-weight: 700;
  padding: 0 0.8rem;
}

.sidebar-header #noteTitle::placeholder {
  color: rgba(236, 244, 252, 0.78);
}

.sidebar-header #noteTitle:focus {
  outline: 2px solid rgba(20, 157, 216, 0.3);
  outline-offset: 1px;
  border-color: rgba(20, 157, 216, 0.72);
}

.sidebar-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0.72rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.sidebar-editor-label {
  font-size: 0.67rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: #d3e5f7;
  font-weight: 800;
}

.sidebar-content #userInput {
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 0;
  border-radius: 13px;
  border: 1px solid rgba(214, 235, 249, 0.3);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06)),
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0) 0,
      rgba(255, 255, 255, 0) 29px,
      rgba(191, 216, 237, 0.18) 29px,
      rgba(191, 216, 237, 0.18) 30px
    );
  color: #f7fbff;
  font-size: 0.94rem;
  line-height: 1.62;
  padding: 0.9rem 0.95rem;
  resize: none;
  overflow: auto;
  box-sizing: border-box;
  font-family: "Manrope", "Segoe UI", sans-serif;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.sidebar-content #userInput::placeholder {
  color: rgba(237, 245, 252, 0.72);
}

.sidebar-content #userInput:focus {
  outline: 2px solid rgba(20, 157, 216, 0.28);
  outline-offset: 1px;
  border-color: rgba(20, 157, 216, 0.68);
}

.sidebar-actions {
  display: flex;
  gap: 0.52rem;
  padding: 0.7rem;
  border-top: 1px solid rgba(214, 235, 249, 0.18);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
}

.sidebar-actions a {
  flex: 1;
  text-decoration: none;
}

.sidebar-actions button {
  width: 100%;
  height: 41px;
  border: 1px solid rgba(207, 224, 238, 0.3);
  border-radius: 12px;
  cursor: pointer;
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.sidebar-actions button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.save-note-btn {
  background: linear-gradient(128deg, #0f77c5, #149dd8 56%, #16aa8f 100%);
  color: #ffffff;
  box-shadow: 0 10px 18px rgba(14, 115, 189, 0.34);
  border-color: transparent;
}

.new-note-btn {
  background: linear-gradient(145deg, #2c4861, #244056);
  color: #e7f1fb;
  box-shadow: 0 8px 16px rgba(7, 20, 33, 0.36);
}

.new-note-btn:hover {
  border-color: rgba(131, 172, 202, 0.78);
}

.resizer {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #d7e8f8;
  border: 1px solid rgba(0, 0, 0, 0.22);
}

.resizer.top-left {
  top: -5px;
  left: -5px;
  cursor: nw-resize;
}

.resizer.top-right {
  top: -5px;
  right: -5px;
  cursor: ne-resize;
}

.resizer.bottom-left {
  bottom: -5px;
  left: -5px;
  cursor: sw-resize;
}

.resizer.bottom-right {
  bottom: -5px;
  right: -5px;
  cursor: se-resize;
}

.resizer.top {
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  cursor: n-resize;
}

.resizer.bottom {
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  cursor: s-resize;
}

.resizer.left {
  left: -5px;
  top: 50%;
  transform: translateY(-50%);
  cursor: w-resize;
}

.resizer.right {
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
  cursor: e-resize;
}

.sidebar-toast-host {
  position: fixed;
  top: calc(var(--navbar-height) + 0.9rem);
  right: 1rem;
  width: min(340px, calc(100vw - 1.2rem));
  display: flex;
  flex-direction: column;
  gap: 0.48rem;
  z-index: 1400;
  pointer-events: none;
}

.sidebar-toast {
  border-radius: 13px;
  border: 1px solid rgba(206, 225, 241, 0.5);
  background: linear-gradient(150deg, rgba(20, 52, 75, 0.96), rgba(13, 38, 58, 0.94));
  color: #eef8ff;
  padding: 0.62rem 0.72rem;
  box-shadow: 0 14px 30px rgba(5, 17, 28, 0.44);
  transform: translateY(-8px);
  opacity: 0;
  animation: sidebar-toast-in 180ms ease forwards;
}

.sidebar-toast__title {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.sidebar-toast__message {
  margin-top: 0.18rem;
  font-size: 0.74rem;
  color: rgba(231, 244, 255, 0.88);
}

.sidebar-toast--success {
  border-color: rgba(99, 216, 173, 0.5);
}

.sidebar-toast--error {
  border-color: rgba(255, 145, 136, 0.56);
}

.sidebar-toast--info {
  border-color: rgba(126, 186, 245, 0.56);
}

.sidebar-toast--hide {
  animation: sidebar-toast-out 220ms ease forwards;
}

@keyframes sidebar-toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sidebar-toast-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}

body.dark-mode .open-sidebar-btn {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 16px 30px rgba(14, 115, 189, 0.46);
}

body.dark-mode .sidebar,
html.dark-mode .sidebar {
  background:
    radial-gradient(circle at 86% -16%, rgba(20, 157, 216, 0.2), transparent 46%),
    linear-gradient(160deg, #111a25 0%, #162433 50%, #0f1f2e 100%);
  border-color: rgba(255, 255, 255, 0.14);
}

body.dark-mode .sidebar-header,
html.dark-mode .sidebar-header {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
}

body.dark-mode .sidebar-header #noteTitle,
html.dark-mode .sidebar-header #noteTitle {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

body.dark-mode .sidebar-content #userInput,
html.dark-mode .sidebar-content #userInput {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03)),
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0) 0,
      rgba(255, 255, 255, 0) 29px,
      rgba(130, 160, 187, 0.22) 29px,
      rgba(130, 160, 187, 0.22) 30px
    );
  color: #f7fbff;
  border-color: rgba(255, 255, 255, 0.18);
}

body.dark-mode .sidebar-actions button,
html.dark-mode .sidebar-actions button {
  border-color: rgba(124, 157, 183, 0.34);
}

body.dark-mode .save-note-btn,
html.dark-mode .save-note-btn {
  background: linear-gradient(128deg, #2a8ed0, #2ba7e7 56%, #1eb091 100%);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.36);
}

body.dark-mode .new-note-btn,
html.dark-mode .new-note-btn {
  background: linear-gradient(145deg, #263d52, #1d2f41);
  color: #eaf4ff;
}

body.dark-mode .sidebar-sync-status,
html.dark-mode .sidebar-sync-status {
  background: rgba(7, 19, 30, 0.64);
  border-color: rgba(123, 164, 196, 0.35);
  color: #ecf6ff;
}

body.dark-mode .sidebar-toast,
html.dark-mode .sidebar-toast {
  background: linear-gradient(150deg, rgba(10, 23, 35, 0.97), rgba(8, 20, 32, 0.96));
  color: #eef8ff;
}

@media (max-width: 768px) {
  .sidebar {
    top: calc(var(--navbar-height) + 0.3rem);
    left: 0.5rem;
    width: calc(100% - 1rem);
    height: calc(100dvh - var(--navbar-height) - 0.95rem);
    min-width: 0;
    min-height: 0;
    max-height: none;
    border-radius: 16px;
  }

  .resizer {
    display: none;
  }

  .sidebar-toast-host {
    right: 0.5rem;
    width: calc(100vw - 1rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar-toast {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .sidebar-toast--hide {
    animation: none;
    opacity: 0;
  }
}

/* ==========================================================================
   Sidebar theme consolidation
   ========================================================================== */
.open-sidebar-btn {
  background: linear-gradient(145deg, #1f8ddb 0%, #1978c6 72%, #13b39f 100%) !important;
  border-color: rgba(221, 242, 255, 0.66) !important;
  box-shadow: 0 14px 28px rgba(11, 83, 137, 0.34) !important;
}

.sidebar {
  background:
    radial-gradient(circle at 90% -12%, rgba(122, 202, 255, 0.2), transparent 44%),
    linear-gradient(162deg, rgba(19, 42, 63, 0.68) 0%, rgba(15, 35, 54, 0.58) 54%, rgba(12, 30, 48, 0.54) 100%);
  border-color: rgba(194, 225, 248, 0.42);
  box-shadow: 0 24px 44px rgba(7, 19, 33, 0.34);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.sidebar-header {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.04));
  border-bottom-color: rgba(212, 234, 250, 0.24);
}

.sidebar-header #noteTitle {
  border-color: rgba(193, 224, 247, 0.58);
  background: linear-gradient(180deg, rgba(13, 41, 66, 0.4), rgba(15, 46, 73, 0.28));
  color: #f4faff;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.sidebar-header #noteTitle::placeholder {
  color: rgba(226, 240, 252, 0.84);
}

.sidebar-content #userInput {
  border-color: rgba(190, 222, 246, 0.5);
  color: #f6fbff;
  background:
    linear-gradient(180deg, rgba(12, 36, 57, 0.34), rgba(10, 31, 50, 0.24)),
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0) 0,
      rgba(255, 255, 255, 0) 29px,
      rgba(170, 213, 245, 0.18) 29px,
      rgba(170, 213, 245, 0.18) 30px
    );
  text-shadow: 0 1px 0 rgba(2, 10, 18, 0.34);
  backdrop-filter: blur(5px) saturate(120%);
  -webkit-backdrop-filter: blur(5px) saturate(120%);
}

.sidebar-content #userInput::placeholder {
  color: rgba(219, 236, 250, 0.74);
}

.sidebar-actions {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02));
  border-top-color: rgba(207, 231, 248, 0.24);
}

.save-note-btn {
  background: linear-gradient(145deg, #1984d1, #16a2da 64%, #1db59a 100%) !important;
  border-color: rgba(198, 236, 255, 0.68) !important;
  color: #f7fcff !important;
}

.new-note-btn {
  background: linear-gradient(145deg, rgba(23, 52, 80, 0.92), rgba(15, 38, 60, 0.9)) !important;
  color: #ebf6ff;
}

body.dark-mode .open-sidebar-btn {
  border-color: rgba(188, 228, 255, 0.52) !important;
  background: linear-gradient(145deg, #208ad4, #156ea9) !important;
  box-shadow: 0 16px 30px rgba(8, 41, 69, 0.44) !important;
}

body.dark-mode .sidebar,
html.dark-mode .sidebar {
  background:
    radial-gradient(circle at 86% -16%, rgba(123, 198, 255, 0.22), transparent 46%),
    linear-gradient(160deg, rgba(7, 19, 32, 0.72) 0%, rgba(8, 24, 38, 0.62) 50%, rgba(7, 18, 30, 0.58) 100%);
  border-color: rgba(170, 212, 241, 0.38);
}

body.dark-mode .sidebar-header #noteTitle,
html.dark-mode .sidebar-header #noteTitle {
  border-color: rgba(168, 208, 236, 0.42);
  background: rgba(123, 198, 255, 0.14);
  color: #f2f8ff;
}

body.dark-mode .sidebar-content #userInput,
html.dark-mode .sidebar-content #userInput {
  border-color: rgba(165, 207, 235, 0.34);
  color: #f4f9ff;
  background:
    linear-gradient(180deg, rgba(116, 190, 245, 0.14), rgba(116, 190, 245, 0.05)),
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0) 0,
      rgba(255, 255, 255, 0) 29px,
      rgba(160, 203, 234, 0.2) 29px,
      rgba(160, 203, 234, 0.2) 30px
    );
}
