/* ============================================================
   Product Image Gallery — utility page
   Styled to match /acm (Accounts Manager): Navy #0b1120, Cyan #00e5ff
   ============================================================ */
:root {
    --pgal-navy:      #0b1120;
    --pgal-navy-mid:  #111c35;
    --pgal-navy-lite: #182040;
    --pgal-cyan:      #00e5ff;
    --pgal-white:     #e8f0fe;
    --pgal-muted:     #6b7fa3;
    --pgal-border:    #1e2d50;
    --pgal-red:       #ff5e7a;
    --pgal-radius:    10px;
    --pgal-font:      'Outfit', 'Segoe UI', sans-serif;
}

#sc-pgal-app * { box-sizing: border-box; }
#sc-pgal-app {
    background: var(--pgal-navy);
    min-height: 100vh;
    font-family: var(--pgal-font);
    color: var(--pgal-white);
    padding-bottom: 40px;
    /* Break out of the theme's constrained .entry-content column so the
       80%/10% container below is measured against the real viewport,
       not an already-narrowed parent. */
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    overflow-x: hidden;
}

/* Hide theme chrome — this is a full-screen utility page, same convention
   as POS/PO's footer-hiding, extended here to the header/announcement bar
   too since this page is meant to stand alone. Selectors taken directly
   from the actual site markup (Astra theme), not guessed wildcards. */
#masthead, #colophon, #ast-desktop-header, #ast-mobile-header,
.site-header, .site-footer, .site-navigation, .entry-header,
#sc-announce, .sc-announcement-bar,
.woocommerce-breadcrumb, .announcement-bar,
.footer, .hfb-footer, .ast-footer, .ast-hfb-footer,
.elementor-element[class*="footer"], .wp-custom-header,
.elementor-section.elementor-top-section:last-of-type { display: none !important; }

/* Astra still reserves layout space for the header/title it no longer
   renders here (a sticky-header margin on #primary, a title-area padding
   on the article) — hiding the elements above doesn't collapse this, so
   it has to be zeroed explicitly or the page starts ~150px down with a
   dead gap above our own header. */
#primary.content-area { margin-top: 0 !important; }
article.ast-article-single { padding-top: 0 !important; }

/* ── Container: 80% width, 10% margin each side on desktop ── */
.pgal-container { width: 80%; margin: 0 10%; }
@media (max-width: 900px) {
    .pgal-container { width: 94%; margin: 0 3%; }
}

/* ── Header (matches /acm's .scam-header exactly) ── */
.pgal-header {
    background: var(--pgal-navy-mid);
    border-bottom: 1px solid var(--pgal-border);
    position: sticky; top: 0; z-index: 100;
    margin-bottom: 24px;
}
.pgal-header-inner {
    max-width: 100%; margin: 0 auto;
    padding: 14px 24px;
    display: flex; align-items: center; justify-content: space-between;
}
.pgal-logo { display: flex; align-items: center; gap: 12px; }
#sc-pgal-app .pgal-logo-img { height: 34.65px; width: auto; display: block; }
.pgal-logo-title { font-family: 'Bebas Neue', var(--pgal-font); font-size: 20px; letter-spacing: 2px; color: var(--pgal-cyan); }
.pgal-logo-sub { font-size: 11px; color: var(--pgal-muted); letter-spacing: 1px; text-transform: uppercase; }

.pgal-card {
    background: var(--pgal-navy-mid);
    border: 1px solid var(--pgal-border);
    border-radius: var(--pgal-radius);
    padding: 20px;
    margin-bottom: 20px;
}
.pgal-card-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; color: var(--pgal-white); }
.pgal-card-desc { font-size: 12px; color: var(--pgal-muted); margin-bottom: 14px; }

/* ── Bulk upload ── */
.pgal-dropzone {
    border: 2px dashed var(--pgal-border);
    border-radius: var(--pgal-radius);
    padding: 28px 16px;
    text-align: center;
    cursor: pointer;
    background: var(--pgal-navy-lite);
    transition: border-color 0.15s, background 0.15s;
}
.pgal-dropzone:hover, .pgal-dropzone-active { border-color: var(--pgal-cyan); background: rgba(0,229,255,0.06); }
.pgal-dropzone-icon { font-size: 26px; margin-bottom: 6px; color: var(--pgal-cyan); }
.pgal-dropzone-text { font-size: 13px; color: var(--pgal-muted); }
.pgal-bulk-progress { margin-top: 10px; font-size: 12px; color: var(--pgal-muted); }
.pgal-bulk-results { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.pgal-bulk-result-item {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    width: 84px; font-size: 10px; color: var(--pgal-muted); text-align: center;
    overflow: hidden;
}
.pgal-bulk-result-item img {
    width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--pgal-border);
}
.pgal-bulk-result-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }

/* ── Toolbar ── */
.pgal-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.pgal-search-input, .pgal-select {
    padding: 9px 12px; border-radius: 7px; border: 1px solid var(--pgal-border);
    font-size: 13px; font-family: var(--pgal-font);
    background: var(--pgal-navy-lite); color: var(--pgal-white);
}
.pgal-search-input:focus, .pgal-select:focus { outline: none; border-color: var(--pgal-cyan); }
.pgal-select option { background: var(--pgal-navy-mid); }
.pgal-search-input { flex: 1; min-width: 160px; }
.pgal-checkbox-label { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--pgal-muted); cursor: pointer; white-space: nowrap; }

/* ── Tree ── */
.pgal-empty { text-align: center; padding: 30px; color: var(--pgal-muted); font-size: 13px; }
.pgal-product-row { border: 1px solid var(--pgal-border); border-radius: 8px; margin-bottom: 8px; overflow: hidden; }
.pgal-product-main {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer;
    background: var(--pgal-navy-lite);
}
.pgal-product-main:hover { background: #1c2748; }
.pgal-chevron { font-size: 10px; color: var(--pgal-muted); width: 12px; flex-shrink: 0; }
.pgal-product-info { flex: 1; min-width: 0; }
.pgal-product-name { font-size: 13px; font-weight: 700; color: var(--pgal-white); }
.pgal-product-meta { font-size: 11px; color: var(--pgal-muted); }

.pgal-thumb {
    width: 44px; height: 44px; border-radius: 6px; object-fit: cover;
    border: 1px solid var(--pgal-border); flex-shrink: 0; background: var(--pgal-navy);
}
.pgal-thumb-empty {
    display: flex; align-items: center; justify-content: center;
    color: var(--pgal-muted); font-size: 16px;
}
.pgal-thumb-wrap { position: relative; flex-shrink: 0; }
.pgal-thumb-remove {
    position: absolute; top: -6px; right: -6px;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--pgal-red); color: #fff; border: 2px solid var(--pgal-navy-mid);
    font-size: 10px; line-height: 1; cursor: pointer; padding: 0;
    display: flex; align-items: center; justify-content: center;
}
.pgal-thumb-remove:hover { opacity: 0.85; }

.pgal-gallery-label {
    font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--pgal-muted); padding: 6px 12px 0 46px;
    background: var(--pgal-navy-lite);
    border-top: 1px solid var(--pgal-border);
}
.pgal-gallery-strip {
    display: flex; gap: 8px; flex-wrap: wrap;
    padding: 6px 12px 10px 46px;
    background: var(--pgal-navy-lite);
}
.pgal-gallery-item { position: relative; width: 36px; height: 36px; flex-shrink: 0; }
.pgal-gallery-item img { width: 100%; height: 100%; object-fit: cover; border-radius: 5px; border: 1px solid var(--pgal-border); }
.pgal-gallery-item .pgal-thumb-remove { width: 15px; height: 15px; font-size: 8px; top: -5px; right: -5px; }

.pgal-variant-list { border-top: 1px solid var(--pgal-border); }
.pgal-variant-row {
    display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 34px;
    border-top: 1px solid var(--pgal-border);
    background: var(--pgal-navy-mid);
}
.pgal-variant-row:first-child { border-top: none; }
.pgal-variant-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pgal-sku { font-family: 'Space Mono', monospace; font-size: 11px; background: rgba(0,229,255,0.08); border: 1px solid rgba(0,229,255,0.25); color: var(--pgal-cyan); border-radius: 5px; padding: 2px 6px; }
.pgal-attrs { font-size: 11px; color: var(--pgal-muted); }
.pgal-not-synced { font-size: 10px; color: var(--pgal-red); text-transform: uppercase; letter-spacing: 0.3px; }

/* ── Buttons ── */
.pgal-btn, .pgal-btn-sm {
    border: none; border-radius: 7px; cursor: pointer; font-family: var(--pgal-font);
    font-weight: 600; letter-spacing: 0.3px; transition: all 0.15s;
}
.pgal-btn { padding: 10px 20px; font-size: 14px; background: var(--pgal-cyan); color: var(--pgal-navy); }
.pgal-btn:hover:not(:disabled) { background: #33eeff; transform: translateY(-1px); }
.pgal-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pgal-btn-sm { padding: 7px 12px; font-size: 12px; background: var(--pgal-cyan); color: var(--pgal-navy); flex-shrink: 0; white-space: nowrap; }
.pgal-btn-sm:hover { background: #33eeff; }
.pgal-btn-ghost { background: transparent; color: var(--pgal-muted); border: 1px solid var(--pgal-border); }
.pgal-btn-ghost:hover { color: var(--pgal-white); border-color: var(--pgal-muted); }

/* ── Modal ── */
.pgal-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 16px; }
.pgal-modal-box { background: var(--pgal-navy-mid); border: 1px solid var(--pgal-border); border-radius: 12px; max-width: 640px; width: 100%; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
.pgal-modal-box-sm { max-width: 380px; }
.pgal-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--pgal-border); }
.pgal-modal-header h2 { font-size: 15px; margin: 0; color: var(--pgal-white); }
.pgal-modal-hint { font-size: 11px; color: var(--pgal-muted); font-weight: 400; }
.pgal-modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--pgal-muted); }
.pgal-modal-close:hover { color: var(--pgal-white); }
.pgal-modal-body { padding: 16px 18px; overflow-y: auto; }
.pgal-modal-footer {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 18px; border-top: 1px solid var(--pgal-border);
}

/* ── Choice popup (Upload from Device / Choose from Gallery) ── */
.pgal-choice-row { display: flex; flex-direction: column; gap: 10px; }
.pgal-choice-btn {
    display: flex; align-items: center; gap: 12px;
    padding: 16px; border-radius: 10px; border: 1px solid var(--pgal-border);
    background: var(--pgal-navy-lite); color: var(--pgal-white);
    font-family: var(--pgal-font); font-size: 14px; font-weight: 600;
    cursor: pointer; text-align: left; transition: border-color 0.15s, background 0.15s;
}
.pgal-choice-btn:hover { border-color: var(--pgal-cyan); background: rgba(0,229,255,0.06); }
.pgal-choice-icon { font-size: 22px; }

.pgal-library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; }
.pgal-library-item { position: relative; cursor: pointer; border-radius: 6px; overflow: hidden; border: 2px solid transparent; transition: border-color 0.15s; }
.pgal-library-item:hover { border-color: var(--pgal-muted); }
.pgal-library-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.pgal-library-check {
    position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 50%;
    background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.4);
    color: transparent; font-size: 11px; display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.pgal-library-selected { border-color: var(--pgal-cyan); }
.pgal-library-selected .pgal-library-check { background: var(--pgal-cyan); border-color: var(--pgal-cyan); color: var(--pgal-navy); }

/* ── Toast ── */
.pgal-toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: var(--pgal-navy-mid); border: 1px solid var(--pgal-border); color: var(--pgal-white);
    padding: 10px 18px; border-radius: 8px;
    font-size: 13px; z-index: 10000; box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.pgal-toast-success { border-color: var(--pgal-cyan); }
.pgal-toast-error { border-color: var(--pgal-red); color: var(--pgal-red); }

/* ── Tabs ── */
.pgal-tabbar { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--pgal-border); }
.pgal-tab-btn {
    background: none; border: none; border-bottom: 2px solid transparent;
    color: var(--pgal-muted); font-family: var(--pgal-font); font-size: 13px; font-weight: 600;
    padding: 10px 4px; margin-bottom: -1px; cursor: pointer; transition: color 0.15s, border-color 0.15s;
}
.pgal-tab-btn + .pgal-tab-btn { margin-left: 18px; }
.pgal-tab-btn:hover { color: var(--pgal-white); }
.pgal-tab-btn.active { color: var(--pgal-cyan); border-bottom-color: var(--pgal-cyan); }
.pgal-tabpanel { display: none; }
.pgal-tabpanel.active { display: block; }

/* ── Descriptions tab ── */
.pgal-desc-table-wrap { overflow-x: auto; }
.pgal-desc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pgal-desc-table th {
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--pgal-muted); padding: 8px 10px; border-bottom: 1px solid var(--pgal-border);
}
.pgal-desc-table td { padding: 10px; border-bottom: 1px solid var(--pgal-border); vertical-align: top; }
.pgal-desc-table tr:last-child td { border-bottom: none; }
.pgal-desc-sku { font-family: monospace; color: var(--pgal-cyan); white-space: nowrap; }
.pgal-desc-textarea {
    width: 100%; min-width: 220px; background: var(--pgal-navy-lite); border: 1px solid var(--pgal-border);
    border-radius: 6px; color: var(--pgal-white); font-family: var(--pgal-font); font-size: 12px;
    padding: 8px; resize: vertical;
}
.pgal-desc-textarea:focus { outline: none; border-color: var(--pgal-cyan); }

@media (max-width: 480px) {
    .pgal-card { padding: 14px; }
    .pgal-header-inner { flex-direction: column; align-items: flex-start; gap: 6px; }
    .pgal-logo-title { font-size: 16px; }
    .pgal-desc-textarea { min-width: 160px; }
}
