/* ============================================================
   FORMS - shared controls that must look the same everywhere
   Loaded by the app, artist and collector layouts.
   ============================================================ */

/* ─── Upload field (templates/partials/upload-field.php) ─────
   A panel with the native file input laid invisibly on top, so the
   whole area is clickable and native drag-and-drop still works. */

.upl {
    position: relative;
    display: block;
    border: 1.5px dashed #cbd7e6;
    border-radius: 14px;
    background: linear-gradient(180deg, #fbfdff 0%, #f6f9fc 100%);
    transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.upl:hover,
.upl.is-drag {
    border-color: var(--cyan, #15b7ff);
    background: #fff;
    box-shadow: 0 10px 26px -20px rgba(15, 25, 40, 0.45);
}

.upl.is-drag {
    border-style: solid;
}

.upl-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    /* Reset anything a page-level rule may have put on file inputs. */
    padding: 0;
    margin: 0;
    border: 0;
    background: none;
}

.upl-input:focus-visible + .upl-body,
.upl-input:focus-visible ~ .upl-body {
    outline: 2px solid var(--cyan, #15b7ff);
    outline-offset: 2px;
}

.upl-body {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    pointer-events: none; /* clicks belong to the input beneath */
}

.upl-thumb {
    flex-shrink: 0;
    width: 62px;
    height: 62px;
    border-radius: 12px;
    overflow: hidden;
    background: #eef3f9;
    color: #93a5bb;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upl-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.upl-thumb svg {
    width: 26px;
    height: 26px;
}

.upl-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.upl-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upl-help {
    font-size: 0.78rem;
    color: #7c8ca1;
}

.upl-btn {
    flex-shrink: 0;
    padding: 9px 18px;
    border-radius: 9px;
    background: #12294a;
    color: #fff;
    font-size: 0.84rem;
    font-weight: 700;
}

.upl:hover .upl-btn { filter: brightness(1.25); }

/* Chosen state: the panel firms up once a file is picked. */
.upl.is-chosen {
    border-style: solid;
    border-color: #22c55e;
    background: #fff;
}
.upl.is-chosen .upl-title { color: #15803d; }

/* Compact variant for tight rows (inline image swaps). */
.upl-compact .upl-body { padding: 12px 14px; gap: 12px; }
.upl-compact .upl-thumb { width: 44px; height: 44px; border-radius: 9px; }
.upl-compact .upl-thumb svg { width: 20px; height: 20px; }
.upl-compact .upl-title { font-size: 0.86rem; }
.upl-compact .upl-help { font-size: 0.74rem; }
.upl-compact .upl-btn { padding: 7px 14px; font-size: 0.8rem; }

@media (max-width: 560px) {
    .upl-body { flex-wrap: wrap; padding: 14px; gap: 12px; }
    .upl-btn { width: 100%; text-align: center; }
}

/* ─── Fallback: any bare file input still reads as part of the app ───
   Covers screens not yet migrated to the component above. */
/* :not([hidden]) is load-bearing: drop zones hide their real input with the
   hidden attribute and draw their own panel. Styling it re-exposed a raw
   "Choose File" button on top of them. */
input[type="file"]:not(.upl-input):not([hidden]) {
    display: block;
    width: 100%;
    max-width: 100%;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 0.86rem;
    color: #475569;
    background: #fbfdff;
    border: 1.5px dashed #cbd7e6;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

input[type="file"]:not(.upl-input):not([hidden]):hover {
    border-color: var(--cyan, #15b7ff);
    background: #fff;
}

input[type="file"]:not(.upl-input):not([hidden])::file-selector-button {
    margin-right: 14px;
    padding: 8px 16px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    color: #fff;
    background: #12294a;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: filter 0.15s ease;
}

input[type="file"]:not(.upl-input):not([hidden])::file-selector-button:hover { filter: brightness(1.25); }

/* ============================================================
   INFO TIP (templates/partials/info-tip.php)
   Lives here, not in theme.css, because theme.css only loads in the
   gallery-admin layout - the artist and collector portals were showing
   the bubble text inline as page copy.
   ============================================================ */

.info-tip {
    display: inline-flex;
    position: relative;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 6px;
    padding: 0;
    line-height: 0;
    color: var(--gray-400, #94a3b8);
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: help;
    vertical-align: middle;
    transition: color 0.16s ease, transform 0.16s ease;
}

.info-tip-glyph { display: block; width: 16px; height: 16px; flex-shrink: 0; }

.info-tip:hover,
.info-tip:focus-visible {
    color: var(--cyan, #15b7ff);
    transform: scale(1.1);
    outline: none;
}

.info-tip-bubble {
    position: absolute;
    bottom: calc(100% + 9px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    z-index: 60;
    width: max-content;
    max-width: 260px;
    padding: 9px 12px;
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.45;
    text-align: left;
    letter-spacing: 0;
    text-transform: none;
    color: #f1f5f9;
    background: #0f1c30;
    border-radius: 8px;
    box-shadow: 0 12px 30px -12px rgba(10, 22, 40, 0.7);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
}

.info-tip-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border: 5px solid transparent;
    border-top-color: #0f1c30;
}

.info-tip:hover .info-tip-bubble,
.info-tip:focus-visible .info-tip-bubble {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Near the right edge, flip the bubble so it can't overflow the page. */
.info-tip.info-tip-end .info-tip-bubble { left: auto; right: 0; transform: translateX(0) translateY(4px); }
.info-tip.info-tip-end .info-tip-bubble::after { left: auto; right: 4px; margin-left: 0; }
.info-tip.info-tip-end:hover .info-tip-bubble,
.info-tip.info-tip-end:focus-visible .info-tip-bubble { transform: translateX(0) translateY(0); }

/* ============================================================
   CROPPER - opened by upload fields that pass 'crop'
   ============================================================ */

.crp {
    position: fixed;
    inset: 0;
    z-index: 9500;
    background: rgba(10, 22, 40, 0.62);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.crp[hidden] { display: none; }

.crp-modal {
    background: #fff;
    border-radius: 18px;
    width: 100%;
    max-width: 460px;
    padding: 22px;
    box-shadow: 0 40px 80px -30px rgba(10, 22, 40, 0.75);
}

.crp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.crp-head h3 { margin: 0; font-size: 1.12rem; font-weight: 700; color: #0f172a; }
.crp-x { border: 0; background: none; font-size: 1.6rem; line-height: 1; color: #94a3b8; cursor: pointer; padding: 0 4px; }
.crp-x:hover { color: #0f172a; }
.crp-hint { margin: 6px 0 14px; font-size: 0.84rem; color: #64748b; line-height: 1.5; }

.crp-stage {
    width: 100%;
    height: 320px;
    border-radius: 14px;
    overflow: hidden;
    background: #0d1626;
}
.crp-canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.crp-canvas:active { cursor: grabbing; }

.crp-zoom { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.crp-zoom-ico { color: #94a3b8; font-size: 1.1rem; font-weight: 700; width: 14px; text-align: center; }
.crp-slider { flex: 1; accent-color: var(--cyan, #15b7ff); cursor: pointer; }

.crp-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.crp-btn { padding: 10px 20px; border-radius: 10px; border: 0; font-family: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer; }
.crp-btn-primary { background: #12294a; color: #fff; }
.crp-btn-primary:hover { filter: brightness(1.25); }
.crp-btn-ghost { background: #f1f5f9; color: #475569; }
.crp-btn-ghost:hover { background: #e2e8f0; }

@media (max-width: 520px) {
    .crp-modal { padding: 16px; }
    .crp-stage { height: 260px; }
    .crp-actions { flex-direction: column-reverse; }
    .crp-btn { width: 100%; }
}

/* Flipped: when a tip sits near the top of the page, the bubble drops below
   the icon instead of running off the screen. */
.info-tip.info-tip-below .info-tip-bubble { bottom: auto; top: calc(100% + 9px); transform: translateX(-50%) translateY(-4px); }
.info-tip.info-tip-below:hover .info-tip-bubble,
.info-tip.info-tip-below:focus-visible .info-tip-bubble { transform: translateX(-50%) translateY(0); }
.info-tip.info-tip-below .info-tip-bubble::after { top: auto; bottom: 100%; border-color: transparent transparent #0f1c30 transparent; }
.info-tip.info-tip-below.info-tip-end .info-tip-bubble { transform: translateX(0) translateY(-4px); }
.info-tip.info-tip-below.info-tip-end:hover .info-tip-bubble { transform: translateX(0) translateY(0); }
