/* ==========================================================
   AdStudioLab — UI components (Facebook-style light theme)
   ========================================================== */

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: 15px; }
.btn--lg { min-height: 48px; padding: 0 20px; font-size: 17px; }
.btn--xl { min-height: 48px; padding: 0 16px; font-size: 20px; font-weight: 700; }
.btn--block { width: 100%; }

.btn--primary { background: var(--blue); color: #FFFFFF; }
.btn--primary:hover { background: var(--blue-hover); }
.btn--primary:active { background: var(--blue-press); }

.btn--green { background: var(--green); color: #FFFFFF; font-weight: 700; }
.btn--green:hover { background: var(--green-hover); }

.btn--secondary { background: var(--secondary); color: var(--text); }
.btn--secondary:hover { background: var(--secondary-hover); }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  color: var(--link);
  font-size: 14px;
  font-weight: 500;
}
.link-btn:hover { text-decoration: underline; }
.link-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

.icon-btn {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--secondary);
  color: var(--text-2);
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--secondary-hover); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

/* ---------------- Pills ---------------- */
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; list-style: none; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 14px;
  font-weight: 600;
}
.pill svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------- Toolbar: tabs, search, view switch ---------------- */
.toolbar {
  position: sticky;
  top: calc(var(--header-h) + 8px);
  z-index: 40;
  display: grid;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.toolbar__row { display: flex; gap: 8px; }

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  height: 36px;
  padding: 0 12px;
  border-radius: 18px;
  color: var(--text-2);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s;
}
.tab:hover { background: var(--hover); }
.tab.is-active { background: var(--blue-soft); color: var(--blue); }
.tab__count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--secondary);
  color: var(--text-2);
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.tab.is-active .tab__count { background: var(--blue); color: #FFFFFF; }

.search { position: relative; display: flex; align-items: center; flex: 1; min-width: 0; }
.search svg {
  position: absolute;
  left: 12px;
  width: 16px; height: 16px;
  fill: none; stroke: var(--text-2); stroke-width: 2.4; stroke-linecap: round;
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 40px;
  padding: 0 40px 0 36px;
  border: 0;
  border-radius: 20px;
  background: var(--field);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.search input::placeholder { color: var(--text-2); }
.search input:focus { box-shadow: 0 0 0 2px var(--blue); background: var(--surface); }
.search kbd {
  position: absolute;
  right: 12px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--secondary);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 20px;
  pointer-events: none;
}
.search input:focus ~ kbd, .search input:not(:placeholder-shown) ~ kbd { display: none; }

.view-switch { display: flex; flex-shrink: 0; gap: 4px; padding: 2px; border-radius: 20px; background: var(--field); }
.view-switch__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border-radius: 18px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.view-switch__btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.view-switch__btn:hover { color: var(--text); }
.view-switch__btn.is-active { background: var(--surface); color: var(--blue); box-shadow: var(--shadow-1); }

/* ---------------- Gallery: cards styled as sponsored posts ---------------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: 16px;
  align-items: start;
}

.card {
  --card-accent: var(--blue);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 16px 4px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  animation: rise 0.35s var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.card__info { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card__head { display: flex; align-items: center; gap: 8px; }
.avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--card-accent);
  color: #FFFFFF;
  font-size: 17px;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.card__who { flex: 1; min-width: 0; }
.card__title { font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--text); }
.card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 4px;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.4;
}
.card__meta .globe { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }
.style-chip { color: var(--blue); font-weight: 600; }
.card__num { flex-shrink: 0; align-self: flex-start; color: var(--text-3); font-size: 13px; font-weight: 600; }
.card__value { color: var(--text); font-size: 15px; line-height: 1.34; }

.sizes { display: flex; gap: 6px; }
.size-btn {
  flex: 1;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--secondary);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s, color 0.15s;
}
.size-btn:hover { background: var(--secondary-hover); }
.size-btn.is-active { background: var(--blue-soft); color: var(--blue); }

.card__preview { display: flex; flex-direction: column; min-width: 0; }

.stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  margin: 0 -16px;
  padding: 36px 16px 20px;
  background-color: var(--bg);
  background-image: radial-gradient(var(--divider) 1px, transparent 1px);
  background-size: 14px 14px;
  overflow: hidden;
}
.fit { position: relative; flex-shrink: 0; overflow: hidden; }
.fit iframe { border: 0; transform-origin: 0 0; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); }
.stage__label {
  position: absolute;
  left: 10px;
  top: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

/* Action row like a post's Like / Comment / Share bar */
.card__toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-top: 8px;
  padding: 4px 0;
  border-top: 1px solid var(--divider);
}
.tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  transition: background 0.15s;
}
.tool svg { flex-shrink: 0; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tool:hover { background: var(--hover); }
.tool.is-spinning { color: var(--blue); }
.tool.is-spinning svg { animation: unspin 0.6s var(--ease); }
.tool--sm { min-height: 30px; padding: 4px 10px; background: var(--secondary); color: var(--text); }
.tool--sm:hover { background: var(--secondary-hover); }
@keyframes unspin { to { transform: rotate(-360deg); } }

/* Inspector-only details */
.card__inspect { display: none; }

.meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin: 4px 0; }
.meta-grid dt { color: var(--text-2); font-size: 12px; font-weight: 600; }
.meta-grid dd { font-size: 15px; font-weight: 600; }

.size-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.size-table th { padding: 8px 0; color: var(--text-2); font-size: 12px; font-weight: 600; text-align: left; border-bottom: 1px solid var(--divider); }
.size-table td { padding: 8px 0; border-bottom: 1px solid var(--divider-soft); color: var(--text-2); }
.size-table td:first-child { color: var(--text); font-weight: 600; }
.size-table th:last-child, .size-table td:last-child { text-align: right; }

.keywords { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; }
.keywords li { padding: 4px 10px; border-radius: 999px; background: var(--secondary); color: var(--text); font-size: 13px; font-weight: 500; }
.keywords li::before { content: "#"; color: var(--text-2); }

/* ---------------- Inspector view ---------------- */
.gallery--inspector { grid-template-columns: 1fr; }
.gallery--inspector .card {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 20px;
  padding: 16px;
}
.gallery--inspector .card__inspect { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.gallery--inspector .stage { min-height: 360px; margin: 0; border-radius: var(--radius); }

/* ---------------- Show more / empty state ---------------- */
.more { max-width: 680px; margin: 20px auto 0; }
.more:has([data-more][hidden]) { display: none; }

.empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 56px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  text-align: center;
}
.empty svg { width: 48px; height: 48px; fill: none; stroke: var(--text-3); stroke-width: 1.8; stroke-linecap: round; }
.empty h3 { font-size: 20px; font-weight: 700; }
.empty p { color: var(--text-2); margin-bottom: 8px; }

/* ---------------- Modal ---------------- */
.modal {
  width: min(548px, calc(100% - 24px));
  max-height: calc(100vh - 48px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-3);
}
.modal::backdrop { background: rgba(244, 244, 244, 0.8); }
.modal[open] { animation: pop 0.2s var(--ease); }
@keyframes pop { from { opacity: 0; transform: scale(0.97); } }

.modal__inner { display: flex; flex-direction: column; }
.modal__head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
}
.modal__heading { grid-column: 2; text-align: center; }
.modal__head h2 { font-size: 20px; font-weight: 700; line-height: 1.2; }
.modal__eyebrow { margin-top: 2px; color: var(--text-2); font-size: 13px; }
.modal__head .icon-btn { grid-column: 3; }
.modal__body { display: flex; flex-direction: column; gap: 16px; padding: 16px; }
.sizes--modal { margin: 0; }

.spec-list { display: grid; border-radius: var(--radius); background: var(--field); overflow: hidden; }
.spec-list > div { display: grid; grid-template-columns: 136px 1fr; gap: 12px; padding: 10px 14px; font-size: 14px; }
.spec-list > div + div { border-top: 1px solid var(--divider-soft); }
.spec-list dt { color: var(--text-2); }
.spec-list dd { font-weight: 600; }

.budget__head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 14px; color: var(--text-2); }
.budget__head strong { color: var(--text); font-variant-numeric: tabular-nums; }
.budget__bar { height: 8px; border-radius: 4px; background: var(--secondary); overflow: hidden; }
.budget__bar span { display: block; height: 100%; border-radius: inherit; background: var(--blue); }

.code { border-radius: var(--radius); border: 1px solid var(--divider); overflow: hidden; }
.code__head { display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 6px 14px; border-bottom: 1px solid var(--divider); background: var(--field); color: var(--text-2); font-size: 13px; font-weight: 600; }
.code pre { margin: 0; padding: 14px; overflow-x: auto; background: var(--surface); }
.code pre code { padding: 0; background: none; color: var(--text); font-size: 12.5px; line-height: 1.6; }

.modal__actions { display: flex; justify-content: flex-end; }
.modal__actions .btn { background: var(--blue); color: #FFFFFF; }
.modal__actions .btn:hover { background: var(--blue-hover); }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 300;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  box-shadow: var(--shadow-3);
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s var(--ease);
}
.toast::before { content: "✓"; display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 10px; border-radius: 50%; background: var(--green); color: #FFFFFF; font-size: 13px; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
  .pills { justify-content: center; }
  .gallery--inspector .card { grid-template-columns: 1fr; }
  .gallery--inspector .stage { min-height: 240px; }
}

@media (max-width: 640px) {
  .toolbar { position: static; }
  .toolbar__row { flex-direction: column; }
  .view-switch__btn { flex: 1; justify-content: center; height: 36px; }
  .search kbd { display: none; }
  .tool span { font-size: 13px; }
  .spec-list > div { grid-template-columns: 1fr; gap: 2px; }
}
