/* ==========================================================================
   TermaType — Toolbar Styles
   ========================================================================== */

#toolbar {
  height: var(--h-toolbar);
  background: var(--c-toolbar);
  border-bottom: 1px solid var(--c-border-toolbar);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 2px;
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

#toolbar::-webkit-scrollbar { height: 3px; }
#toolbar::-webkit-scrollbar-thumb { background: var(--c-border-2); border-radius: 2px; }

/* ── TOOLBAR GROUPS ────────────────────────────────────────────────────────── */
.tbar-group {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}

.tbar-sep {
  width: 1px;
  height: 22px;
  background: var(--c-border-2);
  margin: 0 3px;
  flex-shrink: 0;
  opacity: 0.6;
}

/* ── BASE TOOLBAR BUTTON ──────────────────────────────────────────────────── */
.tbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 32px;
  min-width: 32px;
  padding: 0 5px;
  border: none;
  background: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--c-text-2);
  font-size: 12.5px;
  font-family: var(--font-ui);
  font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap;
  user-select: none;
  position: relative;
}

.tbar-btn:hover {
  background: var(--c-bg);
  color: var(--c-text);
}

.tbar-btn:active {
  background: var(--c-border);
}

.tbar-btn.active {
  background: var(--c-accent-pale);
  color: var(--c-accent-dark);
  font-weight: 600;
}

.tbar-btn[disabled] {
  opacity: 0.4;
  pointer-events: none;
}

/* Icon-sized square buttons */
.tbar-btn.icon-btn {
  width: 32px;
  padding: 0;
  font-size: 14px;
}

/* Text format buttons */
.tbar-btn.fmt-bold   { font-weight: 700; font-size: 14px; }
.tbar-btn.fmt-italic { font-style: italic; font-size: 14px; }
.tbar-btn.fmt-under  { text-decoration: underline; font-size: 14px; }
.tbar-btn.fmt-strike { text-decoration: line-through; font-size: 14px; }

/* ── SELECTS ─────────────────────────────────────────────────────────────── */
.tbar-select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  background: var(--c-page);
  color: var(--c-text);
  font-size: 12.5px;
  font-family: var(--font-ui);
  cursor: pointer;
  outline: none;
  transition: border-color var(--t-fast);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238A837B'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

.tbar-select:hover { border-color: var(--c-border-2); }
.tbar-select:focus { border-color: var(--c-accent); box-shadow: 0 0 0 2px rgba(201,122,30,0.15); }

.tbar-select.font-select {
  min-width: 110px;
  max-width: 160px;
}

.tbar-select.size-select {
  width: 68px;
}

/* ── COLOR INPUT ────────────────────────────────────────────────────────── */
.tbar-color-wrap {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--c-border);
  cursor: pointer;
  transition: border-color var(--t-fast);
}

.tbar-color-wrap:hover { border-color: var(--c-border-2); }

.tbar-color-swatch {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--c-text);
  pointer-events: none;
}

.tbar-color-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -55%);
  font-size: 14px;
  pointer-events: none;
  color: var(--c-text);
}

input[type="color"].tbar-color-input {
  opacity: 0;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  border: none;
  padding: 0;
}

/* ── FILE MENU TRIGGER ────────────────────────────────────────────────── */
.tbar-menu-trigger {
  padding: 0 8px !important;
  font-weight: 500;
}

.tbar-menu-trigger[aria-expanded="true"] {
  background: var(--c-accent-pale);
  color: var(--c-accent-dark);
}

/* ── HEADING SELECT ────────────────────────────────────────────────────── */
.tbar-select.heading-select {
  min-width: 100px;
}

/* ── SVG ICONS ───────────────────────────────────────────────────────────── */
.tbar-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ── ALIGNMENT PICKER ────────────────────────────────────────────────────── */
#align-picker {
  position: fixed;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 4px;
  background: var(--c-toolbar);
  border: none;
  border-radius: var(--r-md);
  box-shadow: 0 2px 12px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.06);
  z-index: 1000;
}

#align-picker.hidden { display: none; }

/* ── TABLE PICKER POPUP ──────────────────────────────────────────────────── */
#table-picker {
  padding: 10px;
  min-width: 180px;
}

.table-picker-title {
  font-size: 11px;
  color: var(--c-text-3);
  text-align: center;
  margin-bottom: 8px;
}

#table-grid {
  display: grid;
  grid-template-columns: repeat(8, 20px);
  gap: 2px;
  margin-bottom: 8px;
}

.tg-cell {
  width: 20px;
  height: 20px;
  border: 1px solid var(--c-border);
  border-radius: 2px;
  cursor: pointer;
  background: var(--c-toolbar);
  transition: all var(--t-fast);
}

.tg-cell.highlighted {
  background: var(--c-accent-pale);
  border-color: var(--c-accent);
}

#table-size-label {
  font-size: 11px;
  color: var(--c-text-3);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Tooltips: use native title attribute (CSS tooltips clipped by toolbar overflow) */
