/* My Media: the customer's Meta ad-account library, browsed live. */
.media-panel { max-width: 1100px }
.media-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px }
.media-header h2 { margin-bottom: 4px }
.media-header-actions { display: flex; gap: 8px; flex-shrink: 0 }

.media-pick-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 12px; border-radius: 10px;
  background: rgba(91,163,245,.10); border: 1px solid rgba(91,163,245,.4); font-size: 14px;
}

.media-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px }
.media-chip {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer;
}
.media-chip.active { color: var(--text); border-color: var(--accent); background: rgba(91,163,245,.12) }
.media-chip:disabled { opacity: .5; cursor: not-allowed }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px }
.media-empty { grid-column: 1 / -1; padding: 36px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; line-height: 1.6 }
.media-empty p { margin-bottom: 8px }

.media-tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; transition: border-color .15s, transform .15s }
.media-tile:hover { border-color: var(--accent); transform: translateY(-1px) }
.media-tile-thumb { position: relative; aspect-ratio: 4 / 3; background: var(--bg); display: flex; align-items: center; justify-content: center; overflow: hidden }
.media-tile-thumb img { width: 100%; height: 100%; object-fit: cover; display: block }
.media-tile-noimg { color: var(--muted); font-size: 28px }
.media-badge { position: absolute; right: 8px; bottom: 8px; padding: 2px 8px; border-radius: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: 11.5px; font-weight: 700; letter-spacing: .02em }
.media-badge-dim { font-weight: 600 }
.media-tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px }
.media-tile-title { font-size: 12.5px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.media-use { padding: 6px 10px !important; font-size: 12px !important; flex-shrink: 0 }
/* Off for a video Meta has not made ready (its badge says processing or error): it looked as live as the others, and a tap did
   nothing. The look of the other greyed-out buttons (misc.css #help-modal). */
.media-use:disabled { opacity: .45; cursor: default }

/* The play badge, shared with mediaThumb() on ad cards. */
.media-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 44px; height: 44px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 18px; padding-left: 4px; pointer-events: none;
}
.media-thumb-video { position: relative; width: 100%; height: 100%; min-height: 60px; background: var(--bg) center / cover no-repeat; border-radius: inherit }
.media-video { width: 100%; max-height: calc(70vh / var(--ui-zoom, 1)); display: block; background: #000; border-radius: 10px }

/* Preview overlay. It sits inside .main, which the app draws at 1.5x (js/ui.js applyZoom), and Chrome scales viewport
   units by that zoom too: a 70vh picture came out at 105vh on a 1080 screen, the close button and the foot off both ends. The
   heights divide by --ui-zoom, which applyZoom sets, so the card always fits the real screen. */
.media-preview { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.72); display: flex; align-items: center; justify-content: center; padding: 20px }
.media-preview-card { position: relative; width: min(900px, 100%); max-height: calc(92vh / var(--ui-zoom, 1)); overflow: auto; background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; padding: 14px }
.media-preview-card > img { width: 100%; max-height: calc(70vh / var(--ui-zoom, 1)); object-fit: contain; display: block; border-radius: 10px; background: #000 }
.media-preview-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; font-size: 14px }
.media-close { position: absolute; top: 8px; right: 10px; z-index: 2; width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(0,0,0,.55); color: #fff; font-size: 22px; line-height: 1; cursor: pointer }
.media-pick-list h3 { margin: 4px 0 12px; font-size: 17px }
.media-pick-ads { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px }
.media-pick-ad { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); text-align: left; cursor: pointer; font: inherit }
.media-pick-ad:hover { border-color: var(--accent) }
.media-pick-ad-thumb { width: 54px; height: 54px; flex-shrink: 0; border-radius: 8px; overflow: hidden; background: var(--panel2); display: flex; align-items: center; justify-content: center; position: relative }
.media-pick-ad-thumb img { width: 100%; height: 100%; object-fit: cover }
.media-pick-ad-name { font-size: 13.5px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }

@media (max-width: 560px) {
  .media-grid { grid-template-columns: repeat(2, 1fr); gap: 10px }
  .media-tile-foot { flex-direction: column; align-items: stretch }
  .media-use { width: 100% }
}

/* Uploads in flight */
.media-uploads { display: grid; gap: 8px; margin-bottom: 14px }
.media-upload-tile { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line) }
.media-upload-tile.is-done { border-color: rgba(52,200,138,.5) }
.media-upload-tile.is-error { border-color: rgba(224,88,88,.55) }
.media-upload-tile.is-processing { border-color: rgba(224,168,50,.5) }
.media-upload-icon { font-size: 18px; line-height: 1.2; flex-shrink: 0 }
.media-upload-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 }
.media-upload-name { font-size: 13.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.media-upload-status { font-size: 12.5px; color: var(--muted) }
.is-error .media-upload-status { color: var(--red) }
.is-done .media-upload-status { color: var(--green) }
.media-upload-bar { display: block; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 2px }
.media-upload-fill { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s }
.is-done .media-upload-fill { background: var(--green) }
.is-error .media-upload-fill { background: var(--red) }
.is-processing .media-upload-fill { background: var(--amber) }

/* "Make an ad with this" */
.media-preview-actions { display: inline-flex; gap: 8px; flex-wrap: wrap }
.media-banner-thumb img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; display: block }
.ad-media-note { font-size: 12.5px; color: var(--muted); margin: 6px 0 10px; line-height: 1.45 }
.ad-media-note strong { color: var(--text) }

/* Sections inside My Media: what Steadywork made, then what is in the Meta ad account */
.media-section { margin-bottom: 22px }
.media-section-h { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 0 0 10px }
.media-section-h h3 { margin: 0; font-size: 15px; font-weight: 800 }
.media-section-h .muted { font-size: 12.5px }
.media-tile-sub { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }

/* The business's own things in generated pictures (lib/brandRefs): the one-line state above the grid and the choice in
   the preview. The tile badge reuses .media-badge. */
.media-ref-line { margin: 0 0 14px }
.media-ref { display: flex; align-items: center; justify-content: flex-start; gap: 10px; flex-wrap: wrap; margin-top: 12px; font-size: 14px; color: var(--muted) }
.media-ref select { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; min-height: 40px }
.media-ref select:focus { outline: none; border-color: var(--accent) }
