/**
 * ACF-Feldtyp: Custom Image Upload - Styles.
 *
 * Deckt ab:
 *   - Feld-Darstellung im Formular (Preview, Buttons).
 *   - Modal-Popup (Backdrop, Dialog, Tabs).
 *   - Bibliothek-Grid (bereits hochgeladene Bilder).
 *   - Upload-Dropzone inkl. Progress und Fehlermeldung.
 *
 * Die Stile sind bewusst prefixed (acf-ciu / bdsf-ciu), um Kollisionen mit
 * Theme-/Plugin-Stilen zu vermeiden.
 */

.acf-ciu {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
}

.acf-ciu__preview {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border: 1px solid #d0d3d8;
    border-radius: 6px;
    background: #f6f7f8;
    padding: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.acf-ciu__preview img {
    display: block;
    max-width: 320px;
    max-height: 240px;
    height: auto;
    width: auto;
    border-radius: 3px;
}

.acf-ciu__empty {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 420px;
    padding: 16px 18px;
    background: #fafbfc;
    border: 1px dashed #cdd1d6;
    border-radius: 6px;
    color: #6b7280;
    font-size: 13px;
    font-style: normal;
}

.acf-ciu__empty::before {
    content: "";
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23003762' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='4' width='18' height='16' rx='2'/><circle cx='9' cy='10' r='1.5'/><path d='M21 17l-5-5-7 7'/></svg>");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.75;
}

.acf-ciu__actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.acf-ciu__btn.button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    border-radius: 4px;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}

.acf-ciu__btn.button:not(.acf-ciu__btn--remove) {
    background: #003762;
    border-color: #003762;
    color: #fff;
}

.acf-ciu__btn.button:not(.acf-ciu__btn--remove):hover,
.acf-ciu__btn.button:not(.acf-ciu__btn--remove):focus {
    background: #00568f;
    border-color: #00568f;
    color: #fff;
    box-shadow: 0 0 0 2px rgba(0, 55, 98, 0.2);
}

.acf-ciu__btn.button:not(.acf-ciu__btn--remove)::before {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='4' width='18' height='16' rx='2'/><circle cx='9' cy='10' r='1.5'/><path d='M21 17l-5-5-7 7'/></svg>");
    background-size: contain;
    background-repeat: no-repeat;
}

.acf-ciu__btn--remove.button {
    background: transparent;
    border-color: transparent;
    color: #b32d2e;
    padding: 6px 10px;
}

.acf-ciu__btn--remove.button:hover,
.acf-ciu__btn--remove.button:focus {
    background: #fdecec;
    border-color: #f5c2c2;
    color: #8a1f1f;
    box-shadow: none;
}

.acf-ciu__btn--remove.button::before {
    content: "\00d7";
    font-size: 16px;
    font-weight: 600;
    line-height: 1;
    margin-right: 2px;
}

/* -------- Modal -------- */

body.bdsf-ciu-modal-open {
    overflow: hidden;
}

.bdsf-ciu-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bdsf-ciu-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.bdsf-ciu-modal__dialog {
    position: relative;
    width: min(820px, 92vw);
    max-height: 88vh;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.bdsf-ciu-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #e4e6ea;
    background: #f6f7f8;
}

.bdsf-ciu-modal__header h3 {
    margin: 0;
    font-size: 16px;
    line-height: 1.2;
}

.bdsf-ciu-modal__close {
    background: none;
    border: 0;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: #333;
    padding: 4px 8px;
}

.bdsf-ciu-modal__close:hover {
    color: #b32d2e;
}

.bdsf-ciu-modal__tabs {
    display: flex;
    border-bottom: 1px solid #e4e6ea;
    background: #fff;
}

.bdsf-ciu-modal__tab {
    flex: 1;
    padding: 10px 14px;
    background: none;
    border: 0;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    color: #555;
}

.bdsf-ciu-modal__tab:hover {
    color: #003762;
}

.bdsf-ciu-modal__tab.is-active {
    color: #003762;
    border-bottom-color: #003762;
    font-weight: 600;
}

.bdsf-ciu-modal__body {
    flex: 1;
    overflow: auto;
    padding: 16px;
}

.bdsf-ciu-modal__pane {
    display: none;
}

.bdsf-ciu-modal__pane.is-active {
    display: block;
}

/* -------- Library Grid -------- */

.bdsf-ciu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
}

.bdsf-ciu-tile {
    position: relative;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 4px;
    background: #f6f7f8;
    cursor: pointer;
    overflow: hidden;
    aspect-ratio: 1 / 1;
}

.bdsf-ciu-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.bdsf-ciu-tile:hover {
    border-color: #003762;
}

.bdsf-ciu-tile.is-active {
    border-color: #003762;
    box-shadow: 0 0 0 2px #003762 inset;
}

.bdsf-ciu-tile.is-active::after {
    content: "\2713";
    position: absolute;
    top: 4px;
    right: 6px;
    color: #fff;
    font-size: 14px;
    background: #003762;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* -------- Upload Pane -------- */

.bdsf-ciu-drop {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    border: 2px dashed #bfc3c9;
    border-radius: 6px;
    background: #fafbfc;
    color: #666;
    text-align: center;
    cursor: pointer;
    padding: 24px;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.bdsf-ciu-drop:hover,
.bdsf-ciu-drop.is-dragover {
    background: #eef3f8;
    border-color: #003762;
    color: #003762;
}

.bdsf-ciu-drop__label {
    max-width: 340px;
    font-size: 14px;
    line-height: 1.35;
}

.bdsf-ciu-hint {
    margin: 10px 0 0;
    font-size: 13px;
    color: #666;
}

.bdsf-ciu-progress {
    margin-top: 12px;
    height: 8px;
    background: #eef0f3;
    border-radius: 4px;
    overflow: hidden;
}

.bdsf-ciu-progress__bar {
    height: 100%;
    width: 0;
    background: #003762;
    transition: width 0.2s ease;
}

.bdsf-ciu-error {
    margin-top: 12px;
    padding: 10px 12px;
    background: #fdecec;
    border: 1px solid #f5c2c2;
    color: #a42626;
    border-radius: 4px;
    font-size: 13px;
}
