/*
 * กล่องอัปโหลด (FilePond) กันพื้นที่ตั้งแต่ HTML แรก — รอบ 4c #5 (ผู้ใช้แจ้ง: กรอบขึ้นช้ากว่าหน้า → กระพริบ)
 *
 * FilePond โหลดแบบ async (x-load) → ก่อนพร้อม .fi-fo-file-upload มีแค่ <input type=file> เปล่า (สูง 0–20px)
 * แล้วกระโดดเป็นกล่อง ~67px เมื่อ FilePond สร้าง .filepond--root
 * → ระหว่างยังไม่มี .filepond--root: วาดกรอบหน้าตา/ขนาดเดียวกับ FilePond (ข้อความเดียวกันจาก data-ms-upload-placeholder
 *   ที่ UiDefaultsServiceProvider ใส่ให้ทุกช่อง) · พอ FilePond พร้อม selector ไม่ตรงอีก → แสดง FilePond ที่สูงเท่ากันแทน
 * ค่าขนาด/สี = ของ Filament สำหรับ .filepond--root / .filepond--drop-label (vendor/filament/forms/resources/css/components/file-upload.css)
 * ไม่แตะ input/change → guard "ถามก่อนปิด" ของ popup ไม่นับเป็นการแก้
 */

.fi-fo-file-upload[data-ms-upload-placeholder]:not(:has(.filepond--root))::before {
    content: attr(data-ms-upload-placeholder);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    /* .filepond--drop-label: min-height 4.75em @ text-sm · padding p-3 */
    min-height: 4.75em;
    padding: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    text-align: center;
    color: var(--gray-600);
    /* .filepond--root: rounded-lg bg-white shadow-sm ring-1 ring-gray-950/10 */
    border-radius: 0.5rem;
    background-color: #fff;
    box-shadow:
        0 0 0 1px color-mix(in oklab, var(--gray-950) 10%, transparent),
        0 1px 2px 0 rgb(0 0 0 / 0.05);
    animation: ms-upload-wait 1.4s ease-in-out infinite;
}

:where(.dark) .fi-fo-file-upload[data-ms-upload-placeholder]:not(:has(.filepond--root))::before {
    color: var(--gray-400);
    background-color: rgb(255 255 255 / 0.05);
    box-shadow:
        0 0 0 1px rgb(255 255 255 / 0.2),
        0 1px 2px 0 rgb(0 0 0 / 0.05);
}

/* input เปล่าก่อน FilePond พร้อม — ไม่ให้กินที่/ไม่ให้ gap ของ flex เพิ่มความสูง (ยังอยู่ใน DOM ให้ FilePond หยิบไปสร้าง) */
.fi-fo-file-upload[data-ms-upload-placeholder]:not(:has(.filepond--root)) > .fi-fo-file-upload-input-ctn {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@keyframes ms-upload-wait {
    50% {
        opacity: 0.6;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fi-fo-file-upload[data-ms-upload-placeholder]:not(:has(.filepond--root))::before {
        animation: none;
    }
}
