/**
 * IoT Class Global Gallery Search Styles
 *
 * Uses IEEE color palette:
 * - Navy: #2C3E50 (primary)
 * - Teal: #16A085 (secondary)
 * - Orange: #E67E22 (highlights)
 * - Gray: #7F8C8D (neutral)
 */

/* ========================================
   Container & Layout
   ======================================== */

.global-search-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.global-search-header {
  text-align: center;
  margin-bottom: 2rem;
}

.global-search-header h2 {
  color: #2C3E50;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.search-description {
  color: #7F8C8D;
  font-size: 1rem;
  line-height: 1.6;
  max-width: 800px;
  margin: 0 auto;
}

/* ========================================
   Search Input
   ======================================== */

.global-search-input-wrapper {
  position: relative;
  max-width: 700px;
  margin: 0 auto 2rem;
}

.global-search-input {
  width: 100%;
  padding: 1rem 3rem 1rem 3.5rem;
  font-size: 1.1rem;
  border: 2px solid #e0e0e0;
  border-radius: 50px;
  outline: none;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.global-search-input:focus {
  border-color: #16A085;
  box-shadow: 0 4px 16px rgba(22, 160, 133, 0.2);
}

.global-search-input::placeholder {
  color: #95a5a6;
}

.search-icon {
  position: absolute;
  left: 1.2rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.3rem;
  color: #7F8C8D;
  pointer-events: none;
}

.search-stats {
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  color: #16A085;
  font-weight: 600;
  pointer-events: none;
}

/* ========================================
   Loading State
   ======================================== */

.search-loading {
  text-align: center;
  padding: 3rem;
  color: #7F8C8D;
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 1rem;
  border: 4px solid #e0e0e0;
  border-top-color: #16A085;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========================================
   Welcome & Error Messages
   ======================================== */

.search-welcome,
.search-no-results,
.search-error {
  text-align: center;
  padding: 3rem 2rem;
  color: #7F8C8D;
  background: #f8f9fa;
  border-radius: 12px;
  margin-top: 2rem;
}

.search-welcome p {
  font-size: 1.1rem;
  margin: 0.5rem 0;
}

.search-welcome p:first-child {
  font-size: 1.3rem;
  color: #2C3E50;
  font-weight: 600;
}

.search-no-results p {
  font-size: 1.1rem;
  margin: 0.5rem 0;
}

.search-no-results p:first-child {
  color: #2C3E50;
  font-weight: 600;
}

.search-error {
  background: #fff5f5;
  border: 2px solid #E67E22;
  color: #c0392b;
}

.error-detail {
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* ========================================
   Results Container
   ======================================== */

.global-search-results {
  margin-top: 2rem;
}

/* ========================================
   Gallery Groups
   ======================================== */

.search-gallery-group {
  margin-bottom: 2.5rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  transition: box-shadow 0.3s ease;
}

.search-gallery-group:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.gallery-group-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-left: 5px solid #16A085;
  border-bottom: 1px solid #e0e0e0;
}

.gallery-icon {
  font-size: 1.5rem;
}

.gallery-group-header h3 {
  flex: 1;
  margin: 0;
  font-size: 1.3rem;
  color: #2C3E50;
  font-weight: 700;
}

.gallery-count {
  font-size: 0.9rem;
  color: #7F8C8D;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  background: white;
  border-radius: 20px;
}

/* ========================================
   Gallery Items
   ======================================== */

.gallery-group-items {
  padding: 0.5rem;
}

/* ========================================
   Individual Result Items
   ======================================== */

.search-result-item {
  display: block;
  padding: 1.25rem 1.5rem;
  margin: 0.5rem;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  background: white;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.search-result-item:hover {
  border-color: #16A085;
  background: #f8fffe;
  box-shadow: 0 2px 8px rgba(22, 160, 133, 0.15);
  transform: translateY(-2px);
}

.result-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.result-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
  line-height: 1;
}

.result-titles {
  flex: 1;
  min-width: 0;
}

.result-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #2C3E50;
  margin-bottom: 0.25rem;
  line-height: 1.4;
}

.result-subtitle {
  font-size: 1rem;
  color: #16A085;
  font-weight: 600;
  line-height: 1.4;
}

.result-description {
  font-size: 0.95rem;
  color: #555;
  line-height: 1.6;
  margin: 0.5rem 0;
  padding-left: 2.8rem;
}

.result-chapter {
  font-size: 0.85rem;
  color: #7F8C8D;
  margin-top: 0.5rem;
  padding: 0.4rem 0.8rem;
  padding-left: 2.8rem;
  background: #f8f9fa;
  border-radius: 4px;
  display: inline-block;
}

/* ========================================
   Highlight Matches
   ======================================== */

mark {
  background-color: #ffe066;
  color: #2C3E50;
  font-weight: 600;
  padding: 0.1rem 0.2rem;
  border-radius: 3px;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
  .global-search-container {
    padding: 1rem 0.5rem;
  }

  .global-search-header h2 {
    font-size: 1.5rem;
  }

  .search-description {
    font-size: 0.9rem;
  }

  .global-search-input {
    font-size: 1rem;
    padding: 0.9rem 2.5rem 0.9rem 3rem;
  }

  .search-icon {
    font-size: 1.1rem;
    left: 1rem;
  }

  .search-stats {
    font-size: 0.8rem;
    right: 1rem;
  }

  .gallery-group-header {
    padding: 1rem;
    flex-wrap: wrap;
  }

  .gallery-group-header h3 {
    font-size: 1.1rem;
    flex-basis: 100%;
    margin-bottom: 0.5rem;
  }

  .gallery-count {
    font-size: 0.85rem;
  }

  .search-result-item {
    padding: 1rem;
  }

  .result-header {
    gap: 0.75rem;
  }

  .result-icon {
    font-size: 1.5rem;
  }

  .result-title {
    font-size: 1.05rem;
  }

  .result-subtitle {
    font-size: 0.9rem;
  }

  .result-description {
    font-size: 0.9rem;
    padding-left: 2.25rem;
  }

  .result-chapter {
    font-size: 0.8rem;
    padding-left: 2.25rem;
  }
}

@media (max-width: 480px) {
  .global-search-header h2 {
    font-size: 1.3rem;
  }

  .search-description {
    font-size: 0.85rem;
    line-height: 1.5;
  }

  .global-search-input {
    padding: 0.8rem 2rem 0.8rem 2.5rem;
    font-size: 0.95rem;
  }

  .search-icon {
    font-size: 1rem;
    left: 0.8rem;
  }

  .search-stats {
    display: none;
  }

  .result-icon {
    font-size: 1.3rem;
  }

  .result-title {
    font-size: 1rem;
  }

  .result-description,
  .result-chapter {
    padding-left: 0;
  }
}

/* ========================================
   Touch Targets (WCAG 2.1)
   ======================================== */

@media (pointer: coarse) {
  .search-result-item {
    min-height: 44px;
    padding: 1.5rem 1rem;
  }

  .global-search-input {
    min-height: 44px;
  }
}

/* ========================================
   High Contrast Mode
   ======================================== */

@media (prefers-contrast: high) {
  .global-search-input {
    border-width: 3px;
  }

  .search-result-item {
    border-width: 2px;
  }

  mark {
    outline: 2px solid #2C3E50;
  }
}

/* ========================================
   Dark Mode Support
   ======================================== */

@media (prefers-color-scheme: dark) {
  .global-search-container {
    color: #e0e0e0;
  }

  .global-search-header h2,
  .result-title {
    color: #e0e0e0;
  }

  .search-description,
  .gallery-count,
  .result-chapter {
    color: #a0a0a0;
  }

  .global-search-input {
    background: #2a2a2a;
    border-color: #444;
    color: #e0e0e0;
  }

  .global-search-input:focus {
    border-color: #16A085;
    background: #333;
  }

  .search-result-item {
    background: #2a2a2a;
    border-color: #444;
  }

  .search-result-item:hover {
    background: #333;
    border-color: #16A085;
  }

  .gallery-group-header {
    background: linear-gradient(135deg, #2a2a2a 0%, #333 100%);
    border-bottom-color: #444;
  }

  .search-gallery-group {
    background: #1e1e1e;
  }

  .result-description {
    color: #b0b0b0;
  }

  .result-chapter {
    background: #333;
  }

  mark {
    background-color: #E67E22;
    color: white;
  }

  .search-welcome,
  .search-no-results {
    background: #2a2a2a;
  }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
  .global-search-input-wrapper,
  .search-loading {
    display: none;
  }

  .search-result-item {
    border: 1px solid #000;
    page-break-inside: avoid;
  }

  mark {
    background: none;
    font-weight: bold;
    text-decoration: underline;
  }
}
