/**
 * SICAKAP - Postal Code Search Component Styling
 */

/* Base container */
.postal-search-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  box-sizing: border-box;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.postal-search-container h2 {
  text-align: center;
  margin-bottom: 10px;
  color: #3f51b5;
  font-size: 24px;
}

.postal-search-container > p {
  text-align: center;
  margin-bottom: 30px;
  color: #6c757d;
}

/* Search method container */
.search-method {
  background-color: #f9f9fa;
  border-radius: 10px;
  padding: 25px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid #e0e0e0;
  width: 100%;
}

.search-method h3 {
    margin: 0 0 15px 0;
    color: #495057;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    font-size: 20px;
    font-weight: 600;
}


/* Text search form - widened layout */
.text-search-form {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 15px;
  width: 100%;
}

/* Make input field take up more space */
.text-search-input {
  flex: 1;
  padding: 14px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  width: calc(100% - 180px);
  box-sizing: border-box;
  height: 50px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.text-search-input:focus {
  outline: none;
  border-color: #3f51b5;
  box-shadow: 0 0 0 2px rgba(63, 81, 181, 0.2);
}

/* Search button */
#textSearchBtn {
  padding: 0 25px;
  background-color: #3f51b5;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
  transition: all 0.2s;
  white-space: nowrap;
  height: 50px;
  min-width: 160px;
  box-shadow: 0 2px 4px rgba(63, 81, 181, 0.2);
}

#textSearchBtn:hover {
  background-color: #303f9f;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(63, 81, 181, 0.3);
}

/* Loading spinner */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 20px 0;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(63, 81, 181, 0.1);
  border-left-color: #3f51b5;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* spin keyframes defined in base.css */

/* Error message */
.api-error {
  background-color: #ffebee;
  color: #d32f2f;
  padding: 12px 16px;
  border-radius: 6px;
  margin: 15px 0;
  font-weight: 500;
  display: none;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  border-left: 4px solid #d32f2f;
}

.api-error.show {
  display: block;
  animation: fadeIn 0.3s ease-in-out;
}

/* fadeIn keyframes defined in base.css */

/* Search results container */
.search-results {
  margin-top: 30px;
  background-color: #ffffff;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  border: 1px solid #e0e0e0;
}

/* Results header */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background-color: #f5f7ff;
  border-bottom: 1px solid #e0e0e0;
}

.results-header h3 {
  margin: 0;
  color: #3f51b5;
  font-size: 18px;
  font-weight: 600;
}

.results-count {
  color: #6c757d;
  font-size: 14px;
  background-color: #e8eaf6;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 500;
}

/* Results grid layout */
.postal-code-results {
  padding: 0;
  background-color: #f9f9fa;
}

/* When using dual results, override the grid */
.postal-code-results .dual-results-container {
  width: 100%;
}

/* Individual result card */
.postal-code-item {
  background-color: white;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid #e0e0e0;
}

.postal-code-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
  border-color: #c5cae9;
}

/* Postal code number */
.postal-code-number {
  font-size: 28px;
  font-weight: 700;
  color: #3f51b5;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
}

.postal-code-number::before {
  content: "📮";
  margin-right: 8px;
  font-size: 20px;
}

/* Address details */
.postal-code-address {
  flex: 1;
  margin-bottom: 15px;
  line-height: 1.5;
  color: #555;
  border-left: 3px solid #c5cae9;
  padding-left: 10px;
  margin-left: 5px;
}

.address-detail {
  display: block;
  font-size: 14px;
  color: #444;
}

/* Copy button */
.copy-postal-btn {
  background-color: #f5f7ff;
  border: 1px solid #c5cae9;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 500;
  color: #3f51b5;
  align-self: flex-end;
  transition: all 0.2s ease;
  font-size: 14px;
  margin-top: 5px;
}

.copy-postal-btn:hover {
  background-color: #e8eaf6;
  border-color: #7986cb;
}

.copy-postal-btn:active {
  transform: scale(0.95);
}

.copy-postal-btn .icon {
  font-size: 16px;
}

/* Copied state */
.copy-postal-btn.copied {
  background-color: #e8f5e9;
  border-color: #81c784;
  color: #2e7d32;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .text-search-form {
    flex-direction: column;
  }
  
  .text-search-input {
    width: 100%;
  }
  
  #textSearchBtn {
    width: 100%;
  }
  
  .results-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .postal-code-results {
    grid-template-columns: 1fr;
  }
  
  .postal-code-item {
    margin-bottom: 12px;
  }
}

/* Animation for new results - disabled to prevent flickering */
/*
.postal-code-item {
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
*/

/* Alternating row colors for better visual separation */
.postal-code-item:nth-child(odd) {
  background-color: #ffffff;
}

.postal-code-item:nth-child(even) {
  background-color: #fafbff;
}

/* Additional highlight for when user clicks on a card */
.postal-code-item:active {
  background-color: #e8eaf6;
}

/* Empty results state */
.postal-code-results:empty::after {
  content: "Tidak ada hasil yang ditemukan";
  display: block;
  text-align: center;
  padding: 40px 20px;
  color: #9e9e9e;
  font-style: italic;
  grid-column: 1 / -1;
}

/* Loading item styling */
.loading-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: #6c757d;
  font-style: italic;
  min-height: 60px;
  background: linear-gradient(90deg, #f5f5f5 0%, #f0f0f0 50%, #f5f5f5 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* shimmer keyframes defined in base.css */

/* No results styling */
.no-results {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: #9e9e9e;
  font-style: italic;
  min-height: 60px;
  background-color: #f9f9f9;
}

/* Dual Results Container - Side by Side */
.dual-results-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  width: 100%;
  padding: 1rem;
}

/* Triple Results Container - Three Columns */
.triple-results-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  width: 100%;
  padding: 1rem;
}

.dual-results-container .results-section,
.triple-results-container .results-section {
  background: #fff;
  border-radius: 10px;
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid #e0e0e0;
}

.dual-results-container .results-section.api-results,
.triple-results-container .results-section.api-results {
  border-top: 3px solid #17a2b8;
}

/* Pos Indonesia styling */
.triple-results-container .results-section.pos-indonesia-results {
  border-top: 3px solid #dc3545;
}

.dual-results-container .results-section.ai-results,
.triple-results-container .results-section.ai-results {
  border-top: 3px solid #667eea;
}

.results-section-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #eee;
}

.results-section-header .header-icon {
  font-size: 1.1rem;
}

.results-section-header .header-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.results-section-header .results-badge {
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.results-section-header .ref-badge {
  font-size: 0.65rem;
  color: #856404;
  background: #fff3cd;
  padding: 2px 6px;
  border-radius: 4px;
}

.dual-results-container .results-list,
.triple-results-container .results-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
}

.dual-results-container .postal-code-item,
.triple-results-container .postal-code-item {
  padding: 0.75rem;
  border-radius: 8px;
  background: #fafbff;
  border: 1px solid #e8e8e8;
}

/* Pos Indonesia source styling */
.triple-results-container .postal-code-item.pos-indonesia-source {
  border-left: 3px solid #dc3545;
}

.triple-results-container .no-results,
.dual-results-container .no-results {
  text-align: center;
  padding: 1rem;
  color: #666;
  font-style: italic;
  font-size: 0.9rem;
}

@media (max-width: 992px) {
  .triple-results-container {
    grid-template-columns: 1fr 1fr;
  }
  
  .triple-results-container .results-section:last-child {
    grid-column: span 2;
  }
}

@media (max-width: 768px) {
  .dual-results-container,
  .triple-results-container {
    grid-template-columns: 1fr;
  }
  
  .triple-results-container .results-section:last-child {
    grid-column: span 1;
  }
}


/* Postal Code Search Tab Styles */
.postal-search-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.search-method {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    background: #f8f9fa;
}


.text-search-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.text-search-input {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

/* Preview Container Improvements */
.preview-container {
    margin-top: 15px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    color: #495057;
}

.text-search-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}