/* Car Detail Page Specific Styles */

/* Padding override only for standalone car detail page (not SPA catalog) */
.car-detail-main {
  padding-top: 4rem;
  padding-bottom: 4rem;
}

#car-detail-view {
  padding-bottom: 4rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted-foreground);
  text-decoration: none;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.back-link:hover {
  color: var(--foreground);
}

.detail-grid {
  display: grid;
  gap: 2rem;
}

@media (min-width: 1024px) {
  .detail-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }
}

/* Gallery */
.gallery {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.main-image {
  position: relative;
  aspect-ratio: 4/3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--muted);
}

.main-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.2s;
}

.gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: white;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 2;
}

.main-image:hover .gallery-arrow {
  opacity: 1;
}

.gallery-arrow:hover {
  background: rgba(0, 0, 0, 0.7);
}

.gallery-arrow-left {
  left: 0.75rem;
}

.gallery-arrow-right {
  right: 0.75rem;
}

.image-counter {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  z-index: 2;
}

.thumbnails {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: none;
  min-width: 0;
}

.thumbnails::-webkit-scrollbar {
  display: none;
}

.thumbnail {
  width: 3.5rem;
  aspect-ratio: 4/3;
  flex-shrink: 0;
  border-radius: calc(var(--radius) / 2);
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s;
  background: var(--muted);
}

.thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumbnail.active {
  border-color: var(--primary);
}

.thumbnail:hover {
  border-color: var(--muted-foreground);
}

/* Info */
.info {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.badge {
  display: inline-block;
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.car-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

@media (min-width: 1024px) {
  .car-title {
    font-size: 2.5rem;
  }
}

.car-detail-price {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 0.5rem;
}

.location-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.location {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

.country-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--muted);
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 500;
}

.country-flag {
  font-size: 1.125rem;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.detail-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  font-size: 0.875rem;
}

.detail-badge.green {
  color: #059669;
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.detail-badge.amber {
  color: #d97706;
  border-color: #fde68a;
  background: #fffbeb;
}

/* Quick Specs */
.quick-specs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (min-width: 640px) {
  .quick-specs {
    grid-template-columns: repeat(auto-fit, minmax(0, auto));
    justify-content: start;
    gap: 1.5rem;
  }
}

.spec-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  white-space: nowrap;
}

.spec-icon {
  width: 1rem;
  height: 1rem;
}

.separator {
  height: 1px;
  background: var(--border);
}

/* Detailed Specs */
.specs-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.specs-grid {
  display: grid;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .specs-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem 1.5rem;
  }
}

.spec-row {
  display: flex;
  justify-content: space-between;
}

.spec-label {
  color: var(--muted-foreground);
}

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

/* Options */
.options-section {
  margin-top: 1.5rem;
}

.options-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.option-tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: var(--foreground);
}

/* Cost Breakdown */
.cost-breakdown {
  background: var(--muted);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  border: 1px solid var(--border);
}

.cost-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 0.5rem 0;
}

.cost-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cost-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.cost-icon {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--primary);
}

.cost-content {
  margin-top: 1rem;
}

.cost-section {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.cost-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.cost-item:last-of-type {
  border-bottom: none;
}

.cost-item-label {
  color: var(--muted-foreground);
}

.cost-item-desc {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.cost-item-value {
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
  font-size: 0.875rem;
}

.cost-total {
  margin-top: 0.75rem;
  padding: 1rem;
  background: rgba(16, 185, 129, 0.05);
  border-radius: var(--radius);
}

.cost-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cost-total-label {
  font-weight: 600;
}

.cost-total-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.cost-note {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  text-align: center;
  margin-top: 1rem;
}

/* CTA Buttons */
.cta-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .cta-buttons {
    flex-direction: row;
  }

  .cta-buttons .btn,
  .cta-buttons .msg-popup-wrap {
    flex: 1;
  }
}

/* Message Popup */
.msg-popup-wrap {
  position: relative;
  flex: 1;
}

.msg-popup-wrap .btn {
  width: 100%;
  line-height: 1.6;
}

.msg-popup {
  display: none;
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 0.5rem;
  z-index: 10;
}

.msg-popup-wrap.open .msg-popup {
  display: flex;
  flex-direction: column;
}

.msg-popup-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  border-radius: calc(var(--radius) / 2);
  text-decoration: none;
  color: var(--foreground);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s;
}

.msg-popup-link:hover {
  background: var(--muted);
}

.msg-popup-icon {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
}

.msg-popup-icon--max {
  color: #007aff;
}

.msg-popup-icon--tg {
  color: #0088cc;
}

.msg-popup-icon--wa {
  color: #25d366;
}

/* Description & Features */
.extra-section {
  margin-top: 3rem;
  display: grid;
  gap: 2rem;
}

@media (min-width: 1024px) {
  .extra-section {
    grid-template-columns: 1fr 1fr;
  }
}

.extra-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.description {
  color: var(--muted-foreground);
  line-height: 1.7;
}

.features-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

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

.feature-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

.feature-item .feature-icon {
  width: 0.75rem;
  height: 0.75rem;
  color: var(--primary);
}

/* Similar Cars */
.similar-section {
  margin-top: 3rem;
}

.similar-section .car-grid {
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 768px) {
  .similar-section .car-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  .similar-section .car-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* Cost breakdown mobile: stack label and value */
@media (max-width: 480px) {
  .cost-breakdown {
    padding: 0.75rem 1rem;
  }

  .cost-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.125rem;
  }

  .cost-item-value {
    text-align: left;
  }

  .cost-total-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
}
