/* GOLPOOGRO - Instagram-Style Global Search Subsystem Stylesheet */

#global-search-overlay {
  position: fixed;
  top: 70px; /* Under the main top action navbar */
  left: 270px; /* Right of the sidebar */
  right: 0;
  bottom: 0;
  background: rgba(10, 10, 12, 0.88);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  z-index: 999;
  display: flex;
  flex-direction: column;
  color: var(--text-primary, #ffffff);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  overscroll-behavior: contain;
}

#global-search-overlay.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Prevent body scrolling when search is active */
body.search-active {
  overflow: hidden !important;
  height: 100vh !important;
}

.mobile-search-header {
  display: none;
}

/* On tablet and mobile, adjust layout to be full overlay */
@media (max-width: 1024px) {
  #global-search-overlay {
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
    background: #0a0b12 !important;
    border: none !important;
  }

  [data-theme="light"] #global-search-overlay {
    background: #ffffff !important;
  }

  /* Show mobile search input header */
  .mobile-search-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(13, 14, 22, 0.95);
    width: 100%;
    flex-shrink: 0;
  }

  [data-theme="light"] .mobile-search-header {
    background: #f8f9fa;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  }

  .mobile-back-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
  }

  .mobile-back-btn:hover {
    background: rgba(255, 255, 255, 0.05);
  }

  [data-theme="light"] .mobile-back-btn:hover {
    background: rgba(0, 0, 0, 0.04);
  }

  .search-bar-container-mob {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
  }

  .search-bar-container-mob svg {
    position: absolute;
    left: 12px;
    pointer-events: none;
    color: var(--text-secondary);
  }

  .glass-input-mob {
    width: 100%;
    height: 38px;
    padding: 8px 36px 8px 36px !important;
    border-radius: 20px !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: var(--text-primary) !important;
    font-size: 0.92rem !important;
    outline: none !important;
    transition: all 0.2s ease;
  }

  [data-theme="light"] .glass-input-mob {
    background: rgba(0, 0, 0, 0.03) !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
  }

  .glass-input-mob:focus {
    background: rgba(255, 255, 255, 0.09) !important;
    border-color: var(--accent-gold) !important;
  }

  [data-theme="light"] .glass-input-mob:focus {
    background: rgba(0, 0, 0, 0.05) !important;
    border-color: var(--accent-gold) !important;
  }

  .search-clear-btn-mob {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 2px;
    cursor: pointer;
    display: none; /* Controlled dynamically in JS */
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
  }

  .search-clear-btn-mob:hover {
    color: var(--text-primary);
  }

  .search-panel-container {
    padding: 12px 12px !important;
    height: calc(100% - 62px) !important;
  }
}

.search-panel-container {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Instagram-style Tabs Layout */
.search-tabs-row {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none; /* Hide scrollbars */
}

.search-tabs-row::-webkit-scrollbar {
  display: none;
}

.search-tab {
  background: none;
  border: none;
  color: var(--text-muted, #a0aec0);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 20px;
  transition: all 0.2s ease-in-out;
  white-space: nowrap;
}

.search-tab:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.search-tab.active {
  color: var(--text-primary, #ffffff);
  background: var(--accent-gold, #d4af37);
  font-weight: 600;
}

/* List Items, Cards, and Sections Group */
.search-results-scrollable {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.search-section {
  margin-bottom: 24px;
}

.search-section-header {
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-gold, #d4af37);
  margin-bottom: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.search-section-count {
  font-family: var(--font-mono, monospace);
  color: var(--text-faint, #718096);
}

.search-results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

/* Results layout cards (Instagram structure) */
.search-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-item-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

.search-item-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.search-avatar-wrapper {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
}

.search-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.search-book-cover-wrapper {
  width: 46px;
  height: 64px;
  border-radius: 6px;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(135deg, var(--accent-gold, #d4af37) 0%, #1e1e24 100%);
}

.search-book-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.search-post-preview-wrapper {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  flex-shrink: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-post-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.search-badge-pill {
  font-family: var(--font-mono, monospace);
  font-size: 0.65rem;
  background: rgba(212, 175, 55, 0.12);
  color: var(--accent-gold, #d4af37);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

.search-info-block {
  min-width: 0;
  flex: 1;
}

.search-title-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.25;
}

.search-subtitle-row {
  font-size: 0.82rem;
  color: var(--text-muted, #718096);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-stats-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--text-faint, #a0aec0);
  margin-top: 4px;
}

.search-stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Action Follow/Unfollow Button */
.search-action-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-primary, #ffffff);
  border-radius: 16px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  user-select: none;
}

.search-action-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
}

.search-action-btn.active-following {
  background: rgba(13, 148, 136, 0.2);
  border-color: rgba(13, 148, 136, 0.4);
  color: #2dd4bf;
}

/* Pulsing visual loading skeletons */
.search-skeleton-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.01);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.02);
}

.search-skeleton-pulse {
  animation: search-pulse-kf 1.5s infinite ease-in-out;
  background: linear-gradient(90deg, rgba(255,255,255,0.02) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.02) 75%);
  background-size: 200% 100%;
}

@keyframes search-pulse-kf {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.search-skeleton-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
}

.search-skeleton-bar-long {
  height: 14px;
  width: 140px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.search-skeleton-bar-short {
  height: 10px;
  width: 80px;
  border-radius: 4px;
}

/* Empty State Styles */
.search-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 40px;
  text-align: center;
  color: var(--text-muted, #718096);
}

.search-empty-icon {
  margin-bottom: 16px;
  color: rgba(255, 255, 255, 0.2);
}

.search-empty-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 6px;
}

.search-empty-desc {
  font-size: 0.85rem;
  max-width: 320px;
}
