/* ==========================================================================
   toolbar.css
   Floating Toolbar — solid style, icon buttons, dropdown, scroll horizontal.
   ========================================================================== */

/* Sekarang bukan elemen fixed sendiri — ikut sebagai flex child di
   .note-topbar (lihat layout.css), sebaris dengan back button. Karena
   toolbar sudah pindah ke ATAS (bukan mengambang dekat keyboard di
   bawah lagi), tidak perlu lagi logic "dock ke atas keyboard". */
.floating-toolbar-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.floating-toolbar {
  pointer-events: auto;
}

.floating-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  /* Dulu punya background/border/border-radius-xl sendiri (pill terpisah
     dari back button). Sekarang .note-topbar yang jadi satu-satunya bar
     header, jadi di sini tinggal transparan + padding tipis kiri/kanan
     saja (bukan var(--space-sm) penuh) supaya tetap hemat tempat. */
  padding: 0 var(--space-2xs);
  /* Scrollable horizontal di layar sempit — ikon tidak pernah dikecilkan,
     yang scroll hanya area toolbar-nya (lihat .toolbar-btn/.toolbar-dropdown
     flex: 0 0 auto di bawah). */
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  scrollbar-width: none;
  max-width: 100%;
}
.floating-toolbar::-webkit-scrollbar { display: none; }

.toolbar-divider {
  flex: 0 0 auto;
  width: 1px;
  height: 24px;
  background-color: var(--color-border);
  margin: 0 var(--space-2xs);
}

.toolbar-btn {
  flex: 0 0 auto;
  padding: 5px;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-size: var(--text-base);
  transition: background-color var(--duration-fast) var(--ease-out),
              transform var(--duration-instant) var(--ease-out);
}

.toolbar-btn:hover {
  background-color: var(--color-accent-soft);
}

.toolbar-btn:active {
  transform: scale(0.96);
}

.toolbar-btn.is-active {
  background-color: var(--color-accent-soft);
  color: var(--color-accent);
}

.toolbar-btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

.toolbar-btn--bold   { font-weight: var(--weight-bold); }
.toolbar-btn--italic { font-style: italic; }
.toolbar-btn--underline { text-decoration: underline; }
.toolbar-btn--strike { text-decoration: line-through; }

/* Dropdown trigger (Heading, Font Family, Font Size, dst.) */
.toolbar-dropdown {
  flex: 0 0 auto;
  padding: 5px;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-primary);
  white-space: nowrap;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.toolbar-dropdown:hover {
  background-color: var(--color-accent-soft);
}

.toolbar-dropdown.is-active {
  background-color: var(--color-accent-soft);
  color: var(--color-accent);
}

.toolbar-dropdown__chevron {
  font-size: var(--text-2xs);
  color: var(--color-text-secondary);
}

/* Color / highlight swatch button */
.toolbar-swatch {
  flex: 0 0 auto;
  padding: 5px;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.toolbar-swatch:hover {
  background-color: var(--color-accent-soft);
}

.toolbar-swatch__glyph {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  position: relative;
}

.toolbar-swatch__glyph::after {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  bottom: -3px;
  height: 3px;
  border-radius: var(--radius-full);
  background-color: var(--color-accent);
}

.toolbar-swatch--highlight .toolbar-swatch__glyph {
  background-color: var(--highlight-amber);
  padding: 0 var(--space-2xs);
  border-radius: var(--radius-xs);
}
.toolbar-swatch--highlight .toolbar-swatch__glyph::after {
  content: none;
}

@keyframes cornerIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   Dropdown open state & floating panels (heading, font size/weight, align,
   text color, highlight). Panel-nya sendiri dipasang lewat JS (dom.js
   openPanel) sebagai elemen fixed di document.body, supaya tidak terpotong
   overflow-x:auto milik .floating-toolbar.
   ========================================================================== */

.toolbar-dropdown.is-open,
.toolbar-swatch.is-open {
  background-color: var(--color-accent-soft);
  color: var(--color-accent);
}

.toolbar-panel {
  position: fixed;
  z-index: var(--z-dropdown);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 16px rgba(var(--shadow-color), 0.12);
  padding: var(--space-xs);
  width: max-content;
  animation: panelIn var(--anim-scale) var(--ease-standard) both;
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.toolbar-panel__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 60vh;
  overflow-y: auto;
  min-width: 168px;
}

.toolbar-panel__item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  text-align: left;
  white-space: nowrap;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.toolbar-panel__item:hover {
  background-color: var(--color-accent-soft);
}

.toolbar-panel__item.is-active {
  background-color: var(--color-accent-soft);
  color: var(--color-accent);
  font-weight: var(--weight-semibold);
}

.toolbar-panel__item--heading-1 { font-size: var(--text-xl); font-weight: var(--weight-semibold); }
.toolbar-panel__item--heading-2 { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.toolbar-panel__item--heading-3 { font-size: var(--text-md); font-weight: var(--weight-semibold); }

.toolbar-panel__item--align svg { flex: 0 0 auto; }

.toolbar-panel__empty {
  padding: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.toolbar-panel__item--manage-fonts {
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-2xs);
  padding-top: var(--space-sm);
  color: var(--color-accent);
  font-weight: var(--weight-medium);
  text-decoration: none;
  cursor: pointer;
}

.toolbar-panel__item--manage-fonts:hover {
  background-color: var(--color-accent-soft);
}

.toolbar-panel__colors {
  display: grid;
  grid-template-columns: repeat(4, 32px);
  gap: var(--space-xs);
  padding: var(--space-2xs);
  width: max-content;
}

.toolbar-panel__swatch {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background-color: var(--color-text-primary);
  transition: transform var(--duration-instant) var(--ease-out);
}

.toolbar-panel__swatch:hover {
  transform: scale(1.08);
}

.toolbar-panel__swatch--none {
  background-color: transparent;
  background-image: linear-gradient(45deg, transparent 45%, var(--color-danger) 45%, var(--color-danger) 55%, transparent 55%);
}

.toolbar-panel__custom-color {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  cursor: pointer;
}

.toolbar-panel__custom-color input[type="color"] {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  cursor: pointer;
}

/* ==========================================================================
   Color bar (baris kedua .note-topbar) — Warna Teks & Highlight.
   Dipakai oleh color-picker.js / highlight-picker.js lewat openColorBar()
   di dom.js. Satu baris, flex:0 0 auto per swatch, scroll horizontal
   ditangani oleh .color-picker-bar (layout.css).
   ========================================================================== */

.color-bar__swatch {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background-color: var(--color-text-primary);
  transition: transform var(--duration-instant) var(--ease-out);
}

.color-bar__swatch:hover {
  transform: scale(1.08);
}

.color-bar__swatch.is-active {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.color-bar__swatch--none {
  background-color: transparent;
  background-image: linear-gradient(45deg, transparent 45%, var(--color-danger) 45%, var(--color-danger) 55%, transparent 55%);
}

.color-bar__divider {
  flex: 0 0 auto;
  width: 1px;
  height: 24px;
  background-color: var(--color-border);
  margin: 0 var(--space-2xs);
}

.color-bar__custom {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-2xs) var(--space-xs);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  white-space: nowrap;
  cursor: pointer;
}

.color-bar__custom:hover {
  background-color: var(--color-accent-soft);
}

.color-bar__custom input[type="color"] {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  cursor: pointer;
}

/* Panel Hyperlink */
.toolbar-panel__link {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm);
  width: min(280px, 80vw);
}

.toolbar-panel__link-input {
  height: var(--touch-target-min);
  padding: 0 var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  color: var(--color-text-primary);
  background-color: var(--color-surface);
}

.toolbar-panel__link-input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.toolbar-panel__link-hint {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

.toolbar-panel__link-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-xs);
}

.toolbar-panel__link-remove,
.toolbar-panel__link-apply {
  height: var(--touch-target-min);
  padding: 0 var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.toolbar-panel__link-remove {
  color: var(--color-danger);
}

.toolbar-panel__link-remove:hover {
  background-color: var(--color-accent-soft);
}

.toolbar-panel__link-apply {
  background-color: var(--color-accent);
  color: var(--color-surface);
}

.toolbar-panel__link-apply:hover {
  opacity: 0.92;
}
