/* ============================================
   SKLAD-BUMAGA — UI Contracts
   DataGrid / EntityPicker / SearchSuggest
   ============================================ */

/* Skip navigation for keyboard users */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 20000;
  background: var(--primary);
  color: var(--text-on-primary);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: var(--font-size-sm);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
}

.skip-link:focus {
  top: 0.75rem;
}

/* Unified keyboard focus indicators */
:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

.btn:focus-visible,
.btn-icon:focus-visible,
.modal-close:focus-visible,
.data-table a:focus-visible,
.header-search input:focus-visible,
.entity-picker-input:focus-visible {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

/* Row link for accessible table navigation */
.table-row-link {
  display: inline-flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
  min-height: 1.25rem;
}

.table-row-link:hover {
  text-decoration: underline;
}

/* Reserve values in order items: visually emphasize clickability */
.reserve-other-link {
  color: var(--primary);
  font-weight: 600;
}

.reserve-other-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Focus hint row (from deep-link navigation) */
.row-focused {
  animation: row-focus-pulse 1200ms var(--ease-out);
}

@keyframes row-focus-pulse {
  0% { background: var(--primary-50); }
  100% { background: transparent; }
}

/* Global search suggestions */
.global-search-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.global-search-dropdown {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  z-index: 120;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 360px;
  overflow: auto;
}

.global-search-empty {
  padding: 0.75rem 0.875rem;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.global-search-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  font-size: var(--font-size-sm);
}

.global-search-item:last-child {
  border-bottom: none;
}

.global-search-item:hover,
.global-search-item.is-active {
  background: var(--primary-50);
}

.global-search-item .type {
  flex: 0 0 auto;
}

.global-search-item .label {
  min-width: 0;
}

/* Entity picker */
.entity-picker {
  position: relative;
}

.entity-picker-selected {
  margin-top: 0.375rem;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
}

.entity-picker-dropdown {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 260px;
  overflow-y: auto;
  z-index: 1400;
}

.entity-picker--embedded .entity-picker-dropdown {
  position: static;
  margin-top: 0.375rem;
  height: 280px;
  min-height: 280px;
  max-height: 280px;
  box-shadow: none;
  z-index: auto;
}

.entity-picker--embedded .entity-picker-dropdown.hidden {
  display: block;
}

.entity-picker-option {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border-light);
  background: transparent;
  text-align: left;
  padding: 0.5rem 0.625rem;
  cursor: pointer;
  color: var(--text);
  font-size: var(--font-size-sm);
}

.entity-picker-option:last-child {
  border-bottom: none;
}

.entity-picker-option:hover,
.entity-picker-option.is-active {
  background: var(--primary-50);
}

.entity-picker-option.is-selected {
  background: color-mix(in srgb, var(--primary-50) 70%, white);
  outline: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
}

.entity-picker-option .meta {
  margin-top: 0.125rem;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
}

.entity-picker-empty {
  padding: 0.625rem;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

@media (max-width: 768px) {
  .global-search-wrap {
    max-width: 100%;
  }

  .global-search-dropdown {
    max-height: min(50vh, 360px);
  }
}
