/* Bundle Master admin — Polaris-inspired, refined.
   Native feel inside the Shopify admin iframe. */

:root {
  --bm-bg: #f1f1f1;
  --bm-surface: #ffffff;
  --bm-surface-hover: #fafbfb;
  --bm-border: #e3e3e3;
  --bm-border-strong: #8a8a8a;
  --bm-text: #303030;
  --bm-text-subdued: #616161;
  --bm-primary: #303030;
  --bm-primary-hover: #1a1a1a;
  --bm-accent: #4169E1;
  --bm-accent-soft: #eef2ff;
  --bm-critical: #8e0b21;
  --bm-critical-soft: #fff1f2;
  --bm-success: #0c5132;
  --bm-success-bg: #cdfee1;
  --bm-warning-bg: #fff1e3;
  --bm-warning: #7a4100;
  --bm-radius: 10px;
  --bm-radius-sm: 8px;
  --bm-shadow: 0 1px 0 rgba(0,0,0,0.05), 0 0 0 1px rgba(0,0,0,0.06);
  --bm-shadow-pop: 0 4px 16px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.06);
  --bm-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--bm-font);
  background: var(--bm-bg);
  color: var(--bm-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.bm-loading {
  display: flex; align-items: center; justify-content: center;
  min-height: 60vh; color: var(--bm-text-subdued);
}

.bm-page { max-width: 1000px; margin: 0 auto; padding: 24px 16px 80px; }

/* Header */
.bm-page__header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
.bm-page__title { font-size: 21px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
.bm-page__subtitle { color: var(--bm-text-subdued); margin: 4px 0 0; font-size: 13px; }
.bm-back {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--bm-text-subdued); font-size: 13px; font-weight: 550;
  background: none; border: none; cursor: pointer; padding: 0 0 8px;
}
.bm-back:hover { color: var(--bm-text); }

/* Cards */
.bm-card {
  background: var(--bm-surface);
  border-radius: var(--bm-radius);
  box-shadow: var(--bm-shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.bm-card__section { padding: 16px 20px; }
.bm-card__section + .bm-card__section { border-top: 1px solid var(--bm-border); }
.bm-card__title { font-size: 14px; font-weight: 650; margin: 0 0 4px; }
.bm-card__hint-top { font-size: 13px; color: var(--bm-text-subdued); margin: 0 0 16px; }

/* Buttons */
.bm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--bm-border-strong);
  background: linear-gradient(180deg, #fff, #f7f7f7);
  color: var(--bm-text);
  padding: 8px 15px; border-radius: var(--bm-radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .12s ease, box-shadow .12s ease, transform .04s ease;
  font-family: inherit;
}
.bm-btn:hover { background: linear-gradient(180deg, #fff, #f0f0f0); }
.bm-btn:active { transform: translateY(0.5px); }
.bm-btn--primary {
  background: var(--bm-primary); color: #fff; border-color: var(--bm-primary);
}
.bm-btn--primary:hover { background: var(--bm-primary-hover); }
.bm-btn--critical { color: var(--bm-critical); border-color: #f0c2c9; background: #fff; }
.bm-btn--critical:hover { background: var(--bm-critical-soft); }
.bm-btn--plain { border-color: transparent; background: transparent; color: var(--bm-accent); padding: 4px 6px; }
.bm-btn--plain:hover { background: var(--bm-accent-soft); }
.bm-btn:disabled { opacity: .5; cursor: default; }
.bm-btn--sm { padding: 5px 10px; font-size: 12px; }

/* Table (bundle list) */
.bm-list { display: flex; flex-direction: column; }
.bm-list__row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; border-top: 1px solid var(--bm-border);
  cursor: pointer; transition: background .1s ease;
  text-align: left; background: none; border-left: none; border-right: none;
  width: 100%; font-family: inherit;
}
.bm-list__row:first-child { border-top: none; }
.bm-list__row:hover { background: var(--bm-surface-hover); }
.bm-list__thumb {
  width: 44px; height: 44px; border-radius: var(--bm-radius-sm);
  object-fit: cover; background: #f3f4f6; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #b5b5b5; font-size: 18px;
}
.bm-list__main { flex: 1; min-width: 0; }
.bm-list__name { font-weight: 600; font-size: 14px; margin: 0; }
.bm-list__meta { color: var(--bm-text-subdued); font-size: 12px; margin: 2px 0 0; }
.bm-list__price { font-weight: 600; font-size: 14px; white-space: nowrap; }
.bm-list__right { display: flex; align-items: center; gap: 12px; }

/* Badges */
.bm-badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.bm-badge--active { background: var(--bm-success-bg); color: var(--bm-success); }
.bm-badge--draft { background: #ebebeb; color: #616161; }
.bm-badge--archived { background: var(--bm-warning-bg); color: var(--bm-warning); }

/* Forms */
.bm-field { margin-bottom: 16px; }
.bm-field:last-child { margin-bottom: 0; }
.bm-field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.bm-field input, .bm-field select, .bm-field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-sm); font-size: 14px; font-family: inherit;
  background: #fff; transition: outline .1s ease, border-color .1s ease;
}
.bm-field input:focus, .bm-field select:focus, .bm-field textarea:focus {
  outline: 2px solid var(--bm-accent); outline-offset: -1px; border-color: var(--bm-accent);
}
.bm-field__hint { font-size: 12px; color: var(--bm-text-subdued); margin-top: 5px; }
.bm-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Product picker */
.bm-picker { position: relative; }
.bm-picker__input-wrap { position: relative; }
.bm-picker__input-wrap::before {
  content: "🔍"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  font-size: 13px; opacity: .5; pointer-events: none;
}
.bm-picker input { padding-left: 32px; }

.bm-results {
  border: 1px solid var(--bm-border); border-radius: var(--bm-radius-sm);
  max-height: 320px; overflow-y: auto; margin-top: 8px;
  box-shadow: var(--bm-shadow);
}
.bm-results:empty { display: none; }
.bm-result {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; cursor: pointer;
  border-top: 1px solid #f1f1f1; transition: background .1s ease;
}
.bm-result:first-child { border-top: none; }
.bm-result:hover { background: var(--bm-accent-soft); }
.bm-result--added { opacity: .45; cursor: default; }
.bm-result--added:hover { background: transparent; }
.bm-result__img {
  width: 34px; height: 34px; border-radius: 6px; object-fit: cover;
  background: #f3f4f6; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #b5b5b5; font-size: 14px;
}
.bm-result__main { flex: 1; min-width: 0; }
.bm-result__title { font-size: 13px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-result__sub { font-size: 12px; color: var(--bm-text-subdued); }
.bm-result__check { color: var(--bm-success); font-weight: 700; }

/* Selected components */
.bm-comp {
  display: flex; align-items: center; gap: 12px; padding: 11px 0;
  border-top: 1px solid var(--bm-border);
}
.bm-comp:first-child { border-top: none; }
.bm-comp__img {
  width: 40px; height: 40px; border-radius: 7px; object-fit: cover; background: #f3f4f6;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #b5b5b5;
}
.bm-comp__main { flex: 1; min-width: 0; }
.bm-comp__title { font-size: 13px; font-weight: 550; }
.bm-comp__sub { font-size: 12px; color: var(--bm-text-subdued); }
.bm-comp__qty-wrap { display: flex; align-items: center; gap: 6px; }
.bm-comp__qty-label { font-size: 12px; color: var(--bm-text-subdued); }
.bm-comp__qty { width: 58px; text-align: center; }

/* Empty states */
.bm-empty { text-align: center; padding: 56px 16px; color: var(--bm-text-subdued); }
.bm-empty__icon { font-size: 40px; margin-bottom: 12px; opacity: .7; }
.bm-empty h3 { color: var(--bm-text); margin: 0 0 6px; font-size: 16px; }
.bm-empty p { margin: 0 0 4px; font-size: 13px; }

.bm-spinner { color: var(--bm-text-subdued); font-size: 13px; padding: 12px; text-align: center; }

/* Sticky action bar */
.bm-actions {
  display: flex; gap: 10px; justify-content: flex-end; align-items: center;
  margin-top: 16px; padding: 14px 20px;
  background: var(--bm-surface); border-radius: var(--bm-radius);
  box-shadow: var(--bm-shadow); position: sticky; bottom: 16px;
}
.bm-actions__spacer { flex: 1; }

/* Toast */
.bm-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(8px);
  background: #303030; color: #fff; padding: 11px 20px; border-radius: var(--bm-radius-sm);
  font-size: 13px; font-weight: 550; opacity: 0; transition: opacity .2s ease, transform .2s ease;
  pointer-events: none; z-index: 100; box-shadow: var(--bm-shadow-pop);
}
.bm-toast--show { opacity: 1; transform: translateX(-50%) translateY(0); }
.bm-toast--critical { background: var(--bm-critical); }

/* Summary chip row on form */
.bm-summary { display: flex; gap: 20px; flex-wrap: wrap; padding: 4px 0; }
.bm-summary__item { }
.bm-summary__label { font-size: 12px; color: var(--bm-text-subdued); display: block; }
.bm-summary__value { font-size: 16px; font-weight: 650; }
.bm-summary__value--save { color: var(--bm-success); }

@media (max-width: 640px) {
  .bm-grid-2 { grid-template-columns: 1fr; }
  .bm-page { padding: 16px 12px 80px; }
}
