/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #344f79;
  background: #fff;
}

/* Container */
.estimator-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* Header */
.estimator-header {
  text-align: center;
  margin-bottom: 32px;
}

.estimator-header h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  color: #344f79;
  margin-bottom: 8px;
}

.estimator-header .subtitle {
  color: #344f79;
  opacity: 0.8;
  font-size: 1rem;
}

/* Filters */
.filters-section {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.filter-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #344f79;
}

.filter-group .required {
  color: #dc3545;
}

.filter-group select {
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s;
}

.filter-group select:focus {
  outline: none;
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.filter-required {
  margin-bottom: 20px;
}

.filter-required select {
  font-weight: 500;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* Banners */
.banners-container {
  margin-bottom: 16px;
}

.banner {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.banner-icon {
  flex-shrink: 0;
  font-size: 1.25rem;
}

.banner-message {
  color: #856404;
  font-size: 0.9rem;
}

/* Results Header */
.results-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 16px;
  padding: 0 4px;
  gap: 16px;
}

.results-info {
  font-size: 0.9rem;
  color: #344f79;
  margin-right: auto;
}

.results-info:empty {
  display: none;
}

.group-by-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.group-by-container label {
  font-size: 0.875rem;
  color: #344f79;
  font-weight: 500;
}

.group-by-container select {
  padding: 6px 10px;
  font-size: 0.875rem;
  font-family: 'Poppins', sans-serif;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  color: #344f79;
  cursor: pointer;
}

.group-by-container select:focus {
  outline: none;
  border-color: #344f79;
}

/* Results */
.results-container {
  margin-bottom: 32px;
}

/* Grid layout for cards on desktop */
.results-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 16px;
  align-items: start; /* Prevent cards from stretching to match tallest in row */
}

@media (min-width: 768px) {
  .results-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .results-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.initial-message {
  background: #fff;
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  color: #344f79;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.results-count {
  font-size: 0.9rem;
  color: #344f79;
  margin-bottom: 16px;
}

/* Group sections */
.results-group {
  margin-bottom: 24px;
  border: 1px solid #e0e6ed;
  border-radius: 12px;
  overflow: hidden;
}

.group-header {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.125rem;
  font-weight: 700;
  color: #344f79;
  padding: 16px 20px;
  background: #f8f9fb;
  cursor: pointer;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  user-select: none;
  transition: background 0.2s;
}

.group-header:hover {
  background: #f0f3f7;
}

.group-header::after {
  content: '▼';
  font-size: 0.75rem;
  margin-left: auto;
  transition: transform 0.2s;
}

.group-header.collapsed::after {
  transform: rotate(-90deg);
}

.group-count {
  font-family: 'Poppins', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  color: #344f79;
  opacity: 0.6;
  margin-left: 8px;
}

.group-content {
  padding: 16px;
}

.group-content.collapsed {
  display: none;
}

.no-results {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  color: #344f79;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Option Cards */
.option-card {
  background: #fff;
  border: 1px solid #e0e6ed;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(52, 79, 121, 0.08);
  overflow: hidden;
  transition: box-shadow 0.2s, border-color 0.2s;
  display: flex;
  flex-direction: column;
}

.option-card:hover {
  border-color: #c5d1de;
  box-shadow: 0 4px 16px rgba(52, 79, 121, 0.12);
}

.card-main {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

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

.card-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: #344f79;
  margin-bottom: 8px;
  line-height: 1.3;
}

.card-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 8px;
  font-size: 0.875rem;
  color: #344f79;
}

.card-specs .spec-item {
  display: flex;
  gap: 4px;
}

.card-specs .spec-label {
  font-weight: 500;
  opacity: 0.7;
}

.card-specs .spec-value {
  font-weight: 500;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-injection {
  background: #e3f2fd;
  color: #1565c0;
}

.badge-odt {
  background: #f3e5f5;
  color: #7b1fa2;
}

.pharmacy-name {
  color: #344f79;
  opacity: 0.7;
  font-size: 0.875rem;
}

.card-price {
  text-align: right;
  flex-shrink: 0;
  padding: 8px 12px;
  background: #f5f7fa;
  border-radius: 8px;
}

.price-amount {
  font-size: 1.125rem;
  font-weight: 600;
  color: #344f79;
}

.price-label {
  font-size: 0.7rem;
  color: #344f79;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.price-weekly {
  font-size: 0.75rem;
  color: #344f79;
  opacity: 0.8;
  margin-top: 4px;
  white-space: nowrap;
}

/* Details Toggle */
.details-toggle {
  display: block;
  width: 100%;
  padding: 12px 20px;
  background: #f8f9fa;
  border: none;
  border-top: 1px solid #eee;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  font-size: 0.875rem;
  color: #344f79;
  font-weight: 500;
  text-align: left;
  transition: background 0.2s;
  margin-top: auto;
}

.details-toggle:hover {
  background: #e9ecef;
}

.details-toggle::after {
  content: ' ▾';
}

.details-toggle.expanded::after {
  content: ' ▴';
}

/* Details Section */
.card-details {
  display: none;
  padding: 20px;
  background: #f8f9fa;
  border-top: 1px solid #eee;
}

.card-details.visible {
  display: block;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-label {
  font-size: 0.75rem;
  color: #344f79;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-value {
  font-size: 0.9rem;
  color: #344f79;
}

.price-breakdown {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #ddd;
}

.price-breakdown h4 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.price-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  padding: 4px 0;
}

.price-line.total {
  font-weight: 600;
  border-top: 1px solid #ddd;
  margin-top: 8px;
  padding-top: 8px;
}

/* Disclaimers */
.disclaimers {
  border-top: 1px solid #ddd;
  padding-top: 24px;
}

.disclaimer {
  font-size: 0.8rem;
  color: #344f79;
  opacity: 0.8;
  margin-bottom: 12px;
  line-height: 1.6;
}

.disclaimer strong {
  color: #344f79;
  opacity: 1;
}

/* Loading State */
.loading {
  text-align: center;
  padding: 48px 24px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #eee;
  border-top-color: #0066cc;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

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

/* Error State */
.error-message {
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  border-radius: 8px;
  padding: 16px;
  color: #721c24;
  text-align: center;
}

/* Responsive */
@media (max-width: 640px) {
  .estimator-container {
    padding: 16px 12px;
  }

  .estimator-header h1 {
    font-size: 1.5rem;
  }

  .filters-section {
    padding: 16px;
  }

  .filter-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .card-header {
    flex-direction: column;
    gap: 8px;
  }

  .card-price {
    text-align: left;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
  }

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

  .price-amount {
    font-size: 1rem;
  }
}

/* iframe embed styles */
@media (max-height: 600px) {
  .estimator-container {
    padding: 12px;
  }

  .estimator-header {
    margin-bottom: 16px;
  }

  .estimator-header h1 {
    font-size: 1.25rem;
  }
}
