/* Design Catalog Stylesheet */

/* Hub Page Layout */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-top: 24px;
}

.hub-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.hub-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.hub-card:hover:not(.disabled) {
  transform: translateY(-4px);
  border-color: var(--teal);
  box-shadow: var(--shadow-hover);
  text-decoration: none;
}

.hub-card:hover:not(.disabled)::before {
  opacity: 1;
}

.hub-card.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--surface-2);
}

.hub-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--teal-2);
  color: var(--teal);
  display: grid;
  place-items: center;
  margin-bottom: 20px;
  transition: all 0.3s ease;
}

.hub-card:hover:not(.disabled) .hub-card-icon {
  background: var(--teal);
  color: white;
  transform: scale(1.05);
}

.hub-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px 0;
}

.hub-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 24px 0;
  flex-grow: 1;
}

.hub-card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  color: var(--teal);
  margin-top: auto;
}

.hub-card-footer i {
  transition: transform 0.2s ease;
}

.hub-card:hover:not(.disabled) .hub-card-footer i {
  transform: translateX(4px);
}

/* Controls Bar (Search + Filters) */
.controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.search-wrapper {
  position: relative;
  flex-grow: 1;
  min-width: 200px;
}

.search-input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--teal);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.search-wrapper i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-select {
  padding: 10px 32px 10px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23475569' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 8.25l-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  min-width: 160px;
  transition: all 0.2s ease;
}

.filter-select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.btn-reset {
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-reset:hover {
  background: var(--surface-2);
  color: var(--ink);
}

/* Catalog Card Grid */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 80px;
}

.catalog-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.catalog-card:hover {
  border-color: var(--teal-accent);
  box-shadow: var(--shadow-hover);
}

.catalog-card.selected {
  border-color: var(--teal);
  background: var(--teal-2);
}

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

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  line-height: 1.3;
}

.btn-star {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #cbd5e1;
  transition: all 0.2s ease;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-star:hover {
  background: var(--surface-2);
  color: var(--amber);
}

.catalog-card.selected .btn-star {
  color: var(--amber);
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
  width: fit-content;
}

.badge-tag.family {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}

.badge-tag.buildable {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(21, 128, 61, 0.15);
}

.badge-tag.partial {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid rgba(180, 83, 9, 0.15);
}

.badge-tag.not-yet {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(185, 28, 28, 0.15);
}

.card-body-text {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  margin: 0 0 12px 0;
}

.card-body-text strong {
  color: var(--muted);
  font-weight: 600;
  display: inline-block;
  min-width: 75px;
}

.card-divider {
  height: 1px;
  background: var(--line);
  margin: 12px 0;
}

/* Inline Preview Controls */
.preview-container {
  margin-top: 12px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  position: relative;
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.preview-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity 0.3s ease;
  opacity: 0;
}

.preview-container img.loaded {
  opacity: 1;
}

.preview-placeholder {
  position: absolute;
  text-align: center;
  padding: 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.btn-preview-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--teal);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: auto;
}

.btn-preview-toggle:hover {
  background: var(--teal-2);
  border-color: var(--teal);
}

.btn-preview-toggle.active {
  background: var(--teal);
  color: white;
  border-color: var(--teal);
}

/* Row holding the per-card action buttons (preview + copy spec) */
.card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.card-actions .btn-preview-toggle {
  margin-top: 0;
  flex: 1;
}

/* Copy-spec button: copies a paste-ready build brief for one card */
.btn-copy-spec {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-copy-spec:hover {
  background: var(--surface-2);
  border-color: var(--teal);
  color: var(--teal);
}

.btn-copy-spec.copied {
  background: var(--green-bg);
  border-color: var(--green);
  color: var(--green);
}

/* Sticky Action Bar */
.action-bar {
  position: fixed;
  bottom: 24px;
  left: 284px; /* Grid sidebar is 260px, padding is 40px -> 260+40 = 300px. Left 284px aligns nicely */
  right: 40px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.3), var(--shadow-hover);
  border-radius: 16px;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
  transform: translateY(120px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.action-bar.visible {
  transform: translateY(0);
}

.action-bar-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  color: var(--ink);
}

.action-bar-badge {
  background: var(--teal);
  color: white;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.action-bar-buttons {
  display: flex;
  gap: 12px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--teal);
  color: white;
  border: 1px solid var(--teal);
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(15, 118, 110, 0.1);
}

.btn-primary:hover {
  background: #0d5f58;
  border-color: #0d5f58;
  transform: translateY(-1px);
}

.btn-secondary-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary-action:hover {
  background: var(--surface-2);
  color: var(--ink);
}

/* Fast Tooltips */
[data-tooltip] {
  position: relative;
  cursor: pointer;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: var(--ink);
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
  z-index: 10;
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* Segmented Control for Metrics Page */
.segmented-control {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 4px;
  border-radius: 10px;
  gap: 2px;
}

.btn-segment {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-segment:hover {
  color: var(--ink);
}

.btn-segment.active {
  background: var(--surface);
  color: var(--teal);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

/* Empty State */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
}

.empty-state i {
  font-size: 32px;
  color: #cbd5e1;
  margin-bottom: 12px;
  display: block;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 8px 0;
  color: var(--ink);
}

.empty-state p {
  font-size: 14px;
  margin: 0;
}

@media (max-width: 768px) {
  .action-bar {
    left: 20px;
    right: 20px;
  }
}
