/* port-search.css */

/* ========================================
   SEARCH CONTAINER — expanded state
   ======================================== */

.port-search-container {
  width: 100%;
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
  position: relative;
  box-sizing: border-box;
}

/* ========================================
   COLLAPSED STATE
   — matches the .tool icon style exactly
   ======================================== */

.sidebar:not(.expanded):not(:hover):not(.pinned):not(.focused) .port-search-container {
  padding: 0;
  background: transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* The icon pill — mirrors .tool .icon */
.sidebar:not(.expanded):not(:hover):not(.pinned):not(.focused) .port-search-container .search-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--glass, rgba(255,255,255,0.03));
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar:not(.expanded):not(:hover):not(.pinned):not(.focused) .port-search-container .search-wrapper:hover {
  background: rgba(255, 255, 255, 0.07);
}

/* Hide input and suggestions in collapsed */
.sidebar:not(.expanded):not(:hover):not(.pinned):not(.focused) .port-search-container #portSearchInput,
.sidebar:not(.expanded):not(:hover):not(.pinned):not(.focused) .port-search-container .port-search-suggestions {
  display: none;
}

/* Icon in collapsed — centered, accent color like .tool .icon */
.sidebar:not(.expanded):not(:hover):not(.pinned):not(.focused) .port-search-container .search-icon {
  position: static;
  transform: none;
  font-size: 18px;
  color: var(--accent, #1e90ff);
  pointer-events: none;
}

/* ========================================
   EXPANDED STATE
   — icon left, input right, inline row
   ======================================== */

.sidebar.expanded .port-search-container .search-wrapper,
.sidebar:hover .port-search-container .search-wrapper,
.sidebar.pinned .port-search-container .search-wrapper,
.sidebar.focused .port-search-container .search-wrapper {
  display: flex;
  align-items: center;
  width: 100%;
  position: relative;
}

/* Icon: absolute inside wrapper on left */
.sidebar.expanded .port-search-container .search-icon,
.sidebar:hover .port-search-container .search-icon,
.sidebar.pinned .port-search-container .search-icon,
.sidebar.focused .port-search-container .search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: rgba(255, 255, 255, 0.45);
  pointer-events: none;
  z-index: 2;
  transition: color 0.2s;
}

.sidebar.expanded .search-wrapper.focused .search-icon,
.sidebar:hover .search-wrapper.focused .search-icon,
.sidebar.pinned .search-wrapper.focused .search-icon,
.sidebar.focused .search-wrapper.focused .search-icon {
  color: #4a9eff;
}

/* ========================================
   INPUT
   ======================================== */

#portSearchInput {
  width: 100%;
  padding: 9px 12px 9px 36px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  outline: none;
  box-sizing: border-box;
  transition: background 0.2s, border-color 0.2s;
  box-shadow: none !important;
}

#portSearchInput::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

#portSearchInput:focus {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(74, 158, 255, 0.6);
  box-shadow: none !important;
  outline: none;
}

/* ========================================
   SUGGESTIONS DROPDOWN
   — contained inside sidebar, no external glow
   ======================================== */

.port-search-suggestions {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: rgba(13, 20, 35, 0.99);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  max-height: 260px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.suggestion-item {
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.12s, padding-left 0.12s;
  color: rgba(255, 255, 255, 0.88);
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.suggestion-item:hover,
.suggestion-item.highlight {
  background: rgba(74, 158, 255, 0.14);
  padding-left: 18px;
}

.suggestion-item strong {
  color: #4a9eff;
  font-weight: 600;
}

.port-search-suggestions::-webkit-scrollbar { width: 3px; }
.port-search-suggestions::-webkit-scrollbar-track { background: transparent; }
.port-search-suggestions::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }

/* ========================================
   SAFETY: prevent any shadow/outline from
   bleeding outside the sidebar boundary
   ======================================== */
#portSearchInput,
.port-search-container,
.port-search-container * {
  outline-offset: -1px;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
  .port-search-container { padding: 8px; }
  #portSearchInput { font-size: 13px; padding: 8px 10px 8px 34px; }
  .suggestion-item { font-size: 12px; padding: 8px 12px; }
}
