/* ===========================
   SEARCH PAGE STYLES
   Lysning v1.6.0
   =========================== */

/* Search Container */
.search-container {
  width: 100%;
  padding: 0;
  display: block !important;
}

/* Search Input Box */
.search-box {
  margin-bottom: 2rem;
}

.search-input-wrapper {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
}

.search-input {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  font-size: 1.1rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  transition: border-color 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: #2B5797;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
  font-size: 1.2rem;
}

/* Search Filters */
.search-filters {
  background: #f8f9fa;
  padding: 1.5rem;
  border-radius: 8px;
  margin-bottom: 2rem;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
}

.filter-label {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #333;
  font-size: 0.9rem;
}

.filter-select {
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  font-size: 0.95rem;
}

/* Filter Checkboxes */
.filter-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.filter-checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.filter-checkbox-label {
  cursor: pointer;
  font-size: 0.95rem;
}

/* Reset Button */
.filter-reset {
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  background: #666;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s ease;
}

.filter-reset:hover {
  background: #444;
}

/* Tag Cloud */
.tag-cloud {
  margin-bottom: 2rem;
}

.tag-cloud-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #333;
}

.tag-cloud-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag-badge {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  background: #e8f4f8;
  color: #2B5797;
  border-radius: 16px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.tag-badge:hover {
  background: #2B5797;
  color: white;
}

.tag-badge.active {
  background: #2B5797;
  color: white;
  border-color: #1a3a5f;
}

.tag-count {
  font-size: 0.8rem;
  opacity: 0.8;
  margin-left: 0.3rem;
}

/* Search Results */
.search-results {
  margin-top: 2rem;
}

/* Grid layout definito alla fine del file per override completo */

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e0e0e0;
}

.results-count {
  font-size: 1.1rem;
  color: #666;
}

.results-sort {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sort-label {
  font-size: 0.9rem;
  color: #666;
}

.sort-select {
  padding: 0.4rem 0.8rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
}

/* Result Items */
.result-item {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1.5rem;
  transition: all 0.2s ease;
  height: 100%;  /* Per allineamento grid */
  display: flex;
  flex-direction: column;
}

.result-header-section {
  cursor: pointer;
}

.result-item:hover {
  border-color: #2B5797;
  box-shadow: 0 2px 8px rgba(43, 87, 151, 0.1);
}

.result-item.expanded {
  grid-column: 1 / -1; /* Occupa tutte le colonne */
  height: auto;
}

.result-type {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  background: #f0f0f0;
  color: #666;
  border-radius: 4px;
  font-size: 0.8rem;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.result-type.diplomacy { background: #e3f2fd; color: #1976d2; }
.result-type.threats { background: #fff3e0; color: #f57c00; }
.result-type.crimes { background: #ffebee; color: #c62828; }
.result-type.articles { background: #e8f5e9; color: #2e7d32; }
.result-type.questions { background: #f3e5f5; color: #7b1fa2; }

.result-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #2B5797;
}

.result-date {
  font-size: 0.85rem;
  color: #999;
  margin-bottom: 0.5rem;
}

.result-summary {
  font-size: 0.95rem;
  line-height: 1.5;
  color: #555;
  margin-bottom: 0.75rem;
}

.result-tags {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e0e0e0;
}

.result-tags-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #999;
  margin-bottom: 0.4rem;
  display: block;
}

.result-tag {
  display: inline;
  color: #2B5797;
  text-decoration: none;
  font-size: 0.85rem;
  cursor: pointer;
}

.result-tag:hover {
  text-decoration: underline;
}

.result-tag:not(:last-child)::after {
  content: " • ";
  color: #999;
  margin: 0 0.3rem;
}

/* No Results */
.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: #999;
}

.no-results-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.no-results-text {
  font-size: 1.1rem;
}

.no-results-suggestion {
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

/* Loading State */
.search-loading {
  text-align: center;
  padding: 2rem;
  color: #999;
}

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

  .search-input {
    font-size: 1rem;
    padding: 0.8rem 0.8rem 0.8rem 2.5rem;
  }

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

  .filters-grid {
    grid-template-columns: 1fr;
  }

  .filter-checkboxes {
    flex-direction: column;
    gap: 0.5rem;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  #search-results-list {
    grid-template-columns: 1fr;  /* Single column on mobile */
  }

  .result-item {
    padding: 1rem;
  }

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

  .tag-cloud-items {
    gap: 0.4rem;
  }

  .tag-badge {
    font-size: 0.85rem;
    padding: 0.3rem 0.6rem;
  }
}

/* Print Styles */
@media print {
  .search-box,
  .search-filters,
  .tag-cloud,
  .results-sort {
    display: none;
  }

  .result-item {
    page-break-inside: avoid;
    border: 1px solid #ddd;
    margin-bottom: 1rem;
  }
}

/* ===============================================
   SEARCH LAYOUT - USA LAYOUT STANDARD COME TIMELINE
   =============================================== */

/* CRITICO: Disabilita grid su container parent */
[data-section="search"] .articles-grid,
[data-section="search"] #articles-container {
  display: block !important;
  grid-template-columns: none !important;
}

/* Search container deve essere block, non grid */
.search-container {
  width: 100%;
  display: block !important;
}

/* Grid risultati - 3 colonne come timeline */
/* IMPORTANTE: Solo search-results-list ha grid */
[data-section="search"] #search-results-list,
.search-container #search-results-list,
#search-results-list {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)) !important;
  gap: 1.5rem !important;
  align-items: start !important;
  width: 100% !important;
}

@media (max-width: 1100px) {
  [data-section="search"] #search-results-list,
  .search-container #search-results-list,
  #search-results-list {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) !important;
  }
}

@media (max-width: 768px) {
  [data-section="search"] #search-results-list,
  .search-container #search-results-list,
  #search-results-list {
    grid-template-columns: 1fr !important;
  }
}

/* ===============================================
   EXPANDED RESULT VIEW (in-place)
   =============================================== */

.result-item.expanded {
  grid-column: 1 / -1; /* Occupa tutte le colonne */
  max-width: none;
}

.result-expanded-content {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 2px solid #e0e0e0;
}

.result-body {
  font-size: 1rem;
  line-height: 1.7;
  color: #333;
  margin-bottom: 1.5rem;
}

.result-body h2,
.result-body h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: #2B5797;
}

.result-body p {
  margin-bottom: 1rem;
}

.result-body ul,
.result-body ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.result-sources {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e0e0e0;
}

.result-sources-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #999;
  margin-bottom: 0.75rem;
  display: block;
}

.result-source-link {
  display: block;
  color: #2B5797;
  text-decoration: none;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.result-source-link:hover {
  text-decoration: underline;
}

.result-collapse-btn {
  margin-top: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95rem;
  color: #555;
  transition: all 0.2s ease;
}

.result-collapse-btn:hover {
  background: #e0e0e0;
  border-color: #ccc;
}
