/* ===================================================================
   TOOLBAR - Professional, Clean, Figma/Adobe-style
   - Consistent button sizing and spacing
   - Enterprise-grade visual hierarchy
   - Smooth interactions and states
   =================================================================== */

/* === CORE BUTTON STYLES === */

.btn {
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.btn-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  min-height: 40px;
  border-radius: var(--radius-md, 8px);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-primary, #111827);
  cursor: pointer;
  background: transparent;
  transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  user-select: none;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover {
  background: var(--color-gray-100, #f3f4f6);
  border-color: var(--color-gray-200, #e5e7eb);
}

.btn-toolbar:hover {
  background: var(--color-gray-100, #f3f4f6);
  color: var(--color-text-primary, #111827);
}

.btn-toolbar:active {
  background: var(--color-gray-200, #e5e7eb);
  transform: translateY(0.5px);
}

.btn-toolbar:focus-visible {
  outline: 2px solid var(--color-primary-500, #6366f1);
  outline-offset: 2px;
}

.btn-toolbar:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Active state for toggle buttons (Measure only - not dropdown triggers) */
.btn-toolbar.is-active,
.btn-toolbar[aria-pressed='true'] {
  background: var(--color-primary-50, #eef2ff);
  color: var(--color-primary-700, #4338ca);
  border-color: var(--color-primary-200, #c7d2fe);
}

.btn-toolbar.is-active:hover,
.btn-toolbar[aria-pressed='true']:hover {
  background: var(--color-primary-100, #e0e7ff);
  border-color: var(--color-primary-300, #a5b4fc);
}

/* === ICON STYLES === */

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--color-text-secondary, #6b7280);
}

/* SVG sizing for icons (less-specific rules first to satisfy no-descending-specificity) */
.btn-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
}

/* Chevron SVG sizing — placed before more-specific .btn-icon-only rules */
.btn-chevron svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

.btn-icon-only {
  padding: 9px;
  width: 40px;
  height: 40px;
  justify-content: center;
}

.btn-icon-only .btn-icon {
  width: 20px;
  height: 20px;
}

.btn-icon-only .btn-icon svg {
  width: 20px;
  height: 20px;
}

.btn-toolbar:hover .btn-icon {
  color: var(--color-text-primary, #111827);
}

.btn-toolbar.is-active .btn-icon,
.btn-toolbar[aria-pressed='true'] .btn-icon {
  color: var(--color-primary-700, #4338ca);
}

.dropdown-item .item-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
}

/* Dropdown triggers should NOT have active state styling */
.dropdown > .btn-toolbar.is-active,
.dropdown > .btn-toolbar[aria-pressed='true'] {
  background: var(--color-neutral-100, #f3f4f6);
  color: var(--color-text-primary, #111827);
  border-color: var(--color-border-medium, #d1d5db);
}

.dropdown > .btn-toolbar.is-active:hover,
.dropdown > .btn-toolbar[aria-pressed='true']:hover {
  background: var(--color-neutral-200, #e5e7eb);
  border-color: var(--color-border-strong, #9ca3af);
}

.dropdown > .btn-toolbar.is-active .btn-icon,
.dropdown > .btn-toolbar[aria-pressed='true'] .btn-icon {
  color: var(--color-text-secondary, #6b7280);
}

.dropdown > .btn-toolbar.is-active:hover .btn-icon,
.dropdown > .btn-toolbar[aria-pressed='true']:hover .btn-icon {
  color: var(--color-text-primary, #111827);
}

#btn-text.is-active {
  background: var(--color-danger-50, #fef2f2);
  color: var(--color-danger-700, #b91c1c);
  border-color: var(--color-danger-200, #fecaca);
}

#btn-text.is-active .btn-icon,
#btn-text.is-active .btn-icon svg {
  color: var(--color-danger-700, #b91c1c);
  fill: var(--color-danger-700, #b91c1c);
  stroke: none;
  stroke-width: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#btn-text.is-active .btn-icon svg path {
  fill: var(--color-danger-700, #b91c1c);
  stroke: none;
}

#btn-measure.is-active {
  background: var(--color-danger-50, #fef2f2);
  color: var(--color-danger-700, #b91c1c);
  border-color: var(--color-danger-200, #fecaca);
}

#btn-measure.is-active .btn-icon,
#btn-measure.is-active .btn-icon svg {
  color: var(--color-danger-700, #b91c1c);
  stroke: currentcolor;
}

/* === LABEL STYLES === */

.btn-label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

/* === VALUE DISPLAY (for Zoom %) === */

.btn-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary, #6b7280);
  min-width: 36px;
  text-align: right;
}

/* === CHEVRON (dropdown indicator) === */

.btn-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin-left: -1px;
  color: var(--color-text-tertiary, #9ca3af);
}

/* === DROPDOWN CONTAINER === */

.dropdown {
  position: relative;
  display: inline-block;
}

/* === DROPDOWN MENU === */

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: white;
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: var(--radius-md, 8px);
  box-shadow:
    0 4px 6px -1px rgb(0 0 0 / 8%),
    0 2px 4px -2px rgb(0 0 0 / 4%),
    0 0 0 1px rgb(0 0 0 / 2%);
  min-width: 220px;
  z-index: 1000;
  display: none;
  max-height: var(--dropdown-max-height, min(70vh, 420px));
  overflow: hidden auto;
}

.dropdown-menu.show {
  display: block;
  animation: dropdown-fade-in 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-menu.dropdown-menu--below {
  top: calc(100% + 6px);
  bottom: auto;
}

.dropdown-menu.dropdown-menu--above {
  top: auto;
  bottom: calc(100% + 6px);
}

@keyframes dropdown-fade-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === DROPDOWN LIST === */

.dropdown-list {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
}

/* === DROPDOWN ITEM === */

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  width: 100%;
  min-height: 38px;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-primary, #111827);
  transition:
    background 100ms ease,
    color 100ms ease;
  user-select: none;
}

.dropdown-item:hover {
  background: var(--color-gray-100, #f3f4f6);
}

.dropdown-item:active {
  background: var(--color-gray-200, #e5e7eb);
}

.dropdown-item:focus-visible {
  outline: 2px solid var(--color-primary-500, #6366f1);
  outline-offset: -2px;
}

.dropdown-item.active {
  background: rgb(var(--color-primary-rgb) / 8%);
  color: var(--color-primary);
  font-weight: 700;
}

.dropdown-item:disabled,
.dropdown-item[aria-disabled='true'] {
  cursor: not-allowed;
  opacity: 0.45;
}

.dropdown-item:disabled:hover,
.dropdown-item[aria-disabled='true']:hover {
  background: transparent;
}

/* === DROPDOWN ITEM ICON === */

.dropdown-item .item-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-text-secondary, #6b7280);
}

.dropdown-item:hover .item-icon {
  color: var(--color-text-primary, #111827);
}

/* === DROPDOWN ITEM LABEL === */

.dropdown-item .item-label {
  flex: 1;
  line-height: 1.4;
}

/* === DROPDOWN DIVIDER === */

.dropdown-divider {
  height: 1px;
  background: var(--color-border, #e5e7eb);
  margin: 6px 0;
}

/* === ZOOM PANEL === */

.zoom-panel {
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.zoom-slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-primary, #111827);
}

.zoom-slider-label span:first-child {
  color: var(--color-text-secondary, #6b7280);
}

.zoom-slider-label span:last-child {
  color: var(--color-primary, #b42518);
  font-weight: 600;
  min-width: 40px;
  text-align: right;
}

/* === ZOOM SLIDER === */

.zoom-slider {
  width: 100%;
  height: 6px;
  appearance: none;
  background: var(--color-gray-200, #e5e7eb);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  margin: 0;
  padding: 0;
}

.zoom-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: var(--color-gray-200, #e5e7eb);
  border-radius: 3px;
}

.zoom-slider::-moz-range-track {
  width: 100%;
  height: 6px;
  background: var(--color-gray-200, #e5e7eb);
  border-radius: 3px;
  border: none;
}

.zoom-slider::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--color-primary, #b42518);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgb(0 0 0 / 15%);
  transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.zoom-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-primary, #b42518);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgb(0 0 0 / 15%);
  transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.zoom-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 4px rgb(0 0 0 / 20%);
  background: var(--color-primary-hover, #962014);
}

.zoom-slider::-moz-range-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 4px rgb(0 0 0 / 20%);
  background: var(--color-primary-hover, #962014);
}

.zoom-slider::-webkit-slider-thumb:active {
  transform: scale(1.05);
}

.zoom-slider::-moz-range-thumb:active {
  transform: scale(1.05);
}

.zoom-slider:focus-visible {
  outline: 2px solid var(--color-primary, #b42518);
  outline-offset: 2px;
}

/* === TOOLBAR LAYOUT === */

.toolbar {
  background: white;
  border-bottom: 1px solid var(--color-border, #e5e7eb);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 52px;
  flex-shrink: 0;
  overflow: visible;
}

.toolbar::-webkit-scrollbar {
  height: 4px;
}

.toolbar::-webkit-scrollbar-thumb {
  background: var(--color-gray-300, #d1d5db);
  border-radius: 2px;
}

/* === TOOLBAR SECTIONS === */

.toolbar-section {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* === TOOLBAR DIVIDER === */

.toolbar-divider {
  width: 1px;
  height: 32px;
  background: var(--color-border, #e5e7eb);
  margin: 0 8px;
  flex-shrink: 0;
}

/* === TOOLTIPS (Built-in) === */

.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translate(-50%, -4px);
  background: rgb(0 0 0 / 90%);
  color: white;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 150ms ease,
    transform 150ms ease;
  transition-delay: 0s;
  z-index: 1100;
  line-height: 1.4;
}

.tooltip:hover::after {
  opacity: 1;
  transform: translate(-50%, 0);
  transition-delay: 800ms;
}

/* === FLOATING TOOLBAR === */

.floating-toolbar {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--color-bg-panel, white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-sm);
  padding: 3px 8px;
  width: max-content;
  white-space: nowrap;
  flex-wrap: nowrap;
  display: flex;
  gap: 2px;
  max-width: min(80vw, calc(100% - 32px));
  overflow: visible;
  min-height: 5px;
  height: 50px;
}

.floating-toolbar .dropdown-menu {
  z-index: 1200;
}

.floating-toolbar .btn-toolbar {
  padding: 6px 10px;
  min-height: 4px;
  height: 44px;
}

.floating-toolbar .toolbar-divider {
  margin: 0 6px;
}

.toolbar-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  cursor: grab;
}

.toolbar-drag-handle:active {
  cursor: grabbing;
}

.drag-grip {
  width: 4px;
  height: 16px;
  background: linear-gradient(
    to bottom,
    var(--color-border) 0%,
    var(--color-border) 20%,
    transparent 20%,
    transparent 40%,
    var(--color-border) 40%,
    var(--color-border) 60%,
    transparent 60%,
    transparent 80%,
    var(--color-border) 80%,
    var(--color-border) 100%
  );
  border-radius: 2px;
  opacity: 0.5;
}

.floating-toolbar:hover .drag-grip {
  opacity: 0.8;
}

.toolbar-group {
  display: flex;
  gap: 4px;
}

/* === RESPONSIVE BEHAVIOR === */

/* Medium screens: Hide button labels to prevent toolbar cutoff */
@media (width <= 1024px) and (width > 768px) {
  .floating-toolbar .btn-label {
    display: none;
  }

  .floating-toolbar .btn-toolbar {
    padding: 9px;
    gap: 0;
  }

  .floating-toolbar .btn-chevron {
    margin-left: 4px;
  }

  .floating-toolbar {
    max-width: calc(100% - 24px);
  }
}

/* === MOBILE COMPATIBILITY === */

@media (width <= 768px) {
  /* Keep toolbar visible but let mobile-redesign.css handle specific mobile UI */
  .toolbar,
  .floating-toolbar {
    overflow: visible;
  }

  .toolbar-section {
    gap: 2px;
  }

  .btn-toolbar {
    padding: 8px 12px;
    font-size: 12px;
  }

  .btn-label {
    font-size: 12px;
  }
}

/* === HIDE CLIENTS BUTTON === */

#btn-clients,
#btn-clients + .header-actions-divider {
  display: none !important;
}
