/*
  Component styles
  Purpose:
  - Cards
  - Buttons
  - Toggles
  - Toasts
  - Icons
*/

/* =========================
   Home Collection Card
   ========================= */

.home-card {
  position: relative;
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

/* Image area */
.home-card__image {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background-color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.home-card__image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Content area */
.home-card__content {
  padding: var(--space-3);
  background-color: #fff;
  color: #000;
}

.home-card__title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.home-card__progress {
  font-size: 14px;
  color: var(--color-text-secondary);
}

.home-card__remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background-color: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: auto;
}

.home-card:hover .home-card__remove {
  opacity: 1;
}

.home-card__remove:active {
  opacity: 0.8;
  transform: scale(0.95);
}

/* Trophy icon for completed castings */
.home-card__trophy {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: #FFD700;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
  pointer-events: none;
}

.home-card__trophy img {
  width: 14px;
  height: 14px;
  display: block;
  filter: brightness(0);
}

/* -----------------------------
   Detail card (compact)
----------------------------- */

.detail-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: transparent;
  padding: 0;
}

/* Image is the ONLY card */
.detail-card__image {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.detail-card__image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.detail-card__meta {
  font-size: 13px;
  color: #111; /* or your Home text color */
  padding: 0 0 10px 10px;
}

/* -----------------------------
   Detail card surface (match Home)
----------------------------- */

.detail-card__surface {
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
}
.detail-card__toggle {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 16px;
}

.detail-summary {
  grid-column: 1 / -1;
  margin: 4px 0 8px;
}
/* =========================
   App Header (2-row)
   ========================= */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;

  background-color: var(--color-bg);

}

/* ---------- Top Bar ---------- */

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--color-divider);
  padding: 14px 20px;
  min-height: 56px;
}

.topbar__brand {
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar__brand img {
  height: 36px;
  width: auto;
  display: block;
}

.topbar__center {
  justify-self: center;
}

.topbar__right {
  justify-self: end;
}

/* ---------- Sub Header ---------- */

.subheader {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  padding: 10px 16px 12px 16px;
}

.subheader__title {
  grid-column: 2 / 3;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--color-text-primary);

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  
}

/* ---------- Icon Buttons ---------- */

.icon-button {
  width: 40px;
  height: 40px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 999px;
  background-color: #fff;

  font-size: 14px;
  color: var(--color-text-primary);
}

.icon-button:active {
  opacity: 0.7;
}

/* Share button should feel lighter on the subheader */
.icon-button--ghost {
  background-color: transparent;
  border: 1px solid var(--color-divider);
}

/* Back & Cancel button spacing */
#backBtn, #cancelBtn {
  margin-right: 12px;
}

.icon-button img {
  width: 22px;
  height: 22px;
  display: block;
}

/* =========================
   Floating Action Button (FAB)
   ========================= */

.fab {
  position: fixed;

  /* Anchor to app shell, not full screen */
  right: calc(50% - 210px + var(--space-4));
  bottom: calc(env(safe-area-inset-bottom) + var(--space-4));

  width: 56px;
  height: 56px;

  border-radius: 50%;
  background-color: #ffffff;
  color: #000000;

  font-size: 32px;
  line-height: 1;

  display: flex;
  align-items: center;
  justify-content: center;

  box-shadow: var(--shadow-md);
  z-index: 20;
}

.fab img,
.fab svg {
  width: 24px;
  height: 24px;
  display: block;
}

/* Pressed state */
.fab:active {
  transform: scale(0.95);
  opacity: 0.9;
}

body.is-shared .fab {
  display: none;
}

/* =========================
   Add Car Row
   ========================= */

.add-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);

  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  cursor: pointer;
}

.add-row:active {
  background-color: var(--color-surface-elevated);
}

/* Image */
.add-row__image {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background-color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-row__image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Content */
.add-row__content {
  flex: 1;
}

.add-row__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.add-row__meta {
  font-size: 13px;
  color: var(--color-text-secondary);
}

/* Action */
.add-row__action {
  width: 32px;
  height: 32px;

  border-radius: 50%;
  background-color: var(--color-surface-elevated);

  display: flex;
  align-items: center;
  justify-content: center;
}

.add-row__plus {
  font-size: 20px;
  line-height: 1;
}

/* =========================
   Add Row — Already Added
   ========================= */

.add-row.is-added {
  opacity: 0.5;
  pointer-events: none;
}

.add-row__check {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.add-row.is-added .add-row__action {
  background-color: transparent;
}

.add-row:active {
  transform: scale(0.99);
}

/* =========================
   Text Button (Done)
   ========================= */

.text-button {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-accent);
  padding: 6px 8px;
}

.text-button:active {
  opacity: 0.7;
}



/* =========================
   Detail Card (Home-style)
   ========================= */

.detail-card {
  position: relative;
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

/* Image */
.detail-card__image {
  width: 100%;
  aspect-ratio: 1 / 1;
  background-color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.detail-card__image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Content */
.detail-card__content {
  padding: var(--space-3);
  background-color: #fff;
}

.detail-card__meta {
  font-size: 14px;
  color: var(--color-text-secondary);
}

/* Collected toggle (top-left) */
.detail-card__toggle {
  position: absolute;
  top: 10px;
  left: 10px;

  width: 28px;
  height: 28px;
  border-radius: 999px;

  background-color: rgba(255, 255, 255, 0.9);
  color: #000;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 16px;
  line-height: 1;
  z-index: 2;
}

/* Collected state */
.detail-card.is-collected .detail-card__toggle {
  background-color: #000;
  color: #fff;
}

/* Disabled state (share mode) */
.detail-card__toggle--disabled,
.detail-card__toggle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Diamond indicator (top-right) */
.detail-card__diamond {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 20px;
  height: 20px;
  opacity: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-card__diamond img {
  width: 100%;
  height: 100%;
  display: block;
}

/* Show diamond for special cars */
.detail-card.is-th .detail-card__diamond,
.detail-card.is-sth .detail-card__diamond,
.detail-card.is-variant .detail-card__diamond {
  opacity: 1;
}

.detail-card__meta {
  font-size: 14px;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.detail-card__tier {
  text-transform: capitalize;
}

/* =========================
   Global Empty State
   ========================= */

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 160px);
  padding: 24px;
  text-align: center;
}

.empty-state__content {
  max-width: 280px;
}

.empty-state__icon {
  font-size: 40px;
  margin-bottom: 16px;
}

.empty-state__title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.empty-state__text {
  font-size: 15px;
  color: var(--color-text-secondary);
}

/* =========================
   Friend Card
   ========================= */

.friend-card {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.friend-card:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-xs);
}

.friend-card__content {
  padding: var(--space-4);
}

.friend-card__name {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--color-text-primary);
}

.friend-card__stats {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.friend-card__count {
  font-weight: 600;
}

.friend-card__status {
  font-size: 14px;
  color: var(--color-text-primary);
  padding: var(--space-2);
  background-color: var(--color-surface-elevated);
  border-radius: var(--radius-sm);
  margin-top: var(--space-2);
  font-style: italic;
}

/* =========================
   Skeleton Loading States
   ========================= */

.skeleton {
  background-color: #e8e8e8;
  border-radius: var(--radius-sm);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-text {
  display: block;
  border-radius: 4px;
}

@keyframes skeleton-pulse {
  0%, 100% {
    opacity: 1;
    background-color: #e8e8e8;
  }
  50% {
    opacity: 0.6;
    background-color: #f0f0f0;
  }
}

/* Skeleton states for cards */
.home-card--skeleton,
.detail-card--skeleton,
.friend-card--skeleton {
  pointer-events: none;
  opacity: 0.7;
}

.home-card--skeleton .skeleton,
.detail-card--skeleton .skeleton,
.friend-card--skeleton .skeleton {
  min-height: 1px;
}

