/* ==========================================================
   Komponen "Pilih Berkas" berbahasa Indonesia.

   Dipakai di:
     - user_pendaftar.php   Upload Bukti Pembayaran & Bukti Transfer Top-Up
     - pengaturan.php       Gambar QRIS

   Kenapa perlu komponen sendiri?
   <input type="file"> asli me-render teks milik BROWSER ("Choose File" /
   "No file chosen") yang mengikuti bahasa browser, bukan bahasa halaman.
   Teks itu tidak bisa diubah lewat HTML, CSS, atau JS. Satu-satunya cara
   agar tampil Bahasa Indonesia: sembunyikan input aslinya secara visual
   (tetap ada di DOM, tetap bisa difokus, tetap terkirim ke server) lalu
   menggantinya dengan <label> + teks kita sendiri.

   PENTING — nama kelas HARUS sama persis dengan markup PHP & unggah.js:
     .unggah (wrap) .unggah-tombol .unggah-ikon .unggah-teks .unggah-input
     .unggah-nama .unggah-catatan .unggah-salah
   Dahulu sebagian selektor memakai awalan .upload-* sehingga TIDAK ADA satu
   pun aturan yang terpakai (markup & JS memakai unggah-*) dan tombol tampil
   seperti teks label polos tanpa latar, padding, maupun radius.

   Syarat supaya ramah pengguna awam:
     1. Tombolnya harus JELAS tombol: warna biru solid, teks putih, tebal,
        ada bayangan & elevasi saat hover - bukan sekadar teks di dalam
        kotak. Warna ditulis HEX langsung (bukan var(--aksen) yang di panel
        ini bernilai cokelat/amber) supaya tidak berubah jadi warna lain.
        Biru #2b6cb0 sengaja disamakan dengan .btn.biru di style.css.
     2. Teks "Belum ada berkas dipilih" TIDAK ditampilkan saat kosong - itu
        terbaca seperti status, bukan perintah. Yang tampil: tombol +
        catatan "Klik tombol ...". Nama berkas baru muncul setelah dipilih,
        berupa chip berwarna (hijau = OK, merah = bermasalah).
     3. Setelah berkas dipilih tombol berubah jadi "Ganti Berkas" (dari
        data-label), jadi pengguna tahu masih bisa menggantinya.

   Warna lain memakai token style.css (--teks / --merah / ...) supaya
   otomatis ikut mode gelap :root[data-tema="gelap"].
   ========================================================== */

/* ---------- Wrap: tombol + nama berkas sebaris, turun bila sempit ----- */
.unggah {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    width: 100%;
    min-width: 0;
}

/* ---------- Tombol "Pilih Berkas" -------------------------------------
   position:relative jadi acuan input tersembunyi-nya.
   Warna ditulis HEX + !important supaya tetap biru solid di kedua tema dan
   tidak tertimpa gaya lain. */
.unggah-tombol {
    position: relative;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 9px;
    margin: 0;
    padding: 11px 20px;
    background: #2b6cb0 !important;
    background-image: none !important;
    color: #fff !important;
    border: 1px solid #1f4e80 !important;
    border-radius: 10px;
    /* cahaya atas + bayangan bawah = terlihat "terangkat", bukan kotak datar */
    box-shadow: 0 2px 5px rgba(31, 78, 128, .28), inset 0 1px 0 rgba(255, 255, 255, .18);
    font-size: 13.5px;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: .2px;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    cursor: pointer;
    transition: background .18s, box-shadow .18s, transform .08s;
}
.unggah-tombol:hover {
    background: #1f4e80 !important;
    color: #fff !important;
    text-decoration: none;
    box-shadow: 0 6px 14px rgba(31, 78, 128, .32), inset 0 1px 0 rgba(255, 255, 255, .18);
    transform: translateY(-1px);
}
.unggah-tombol:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(31, 78, 128, .3), inset 0 2px 4px rgba(0, 0, 0, .18);
}
/* Mode gelap: biru sedikit lebih terang supaya kontras di atas kartu gelap. */
:root[data-tema="gelap"] .unggah-tombol {
    background: #2f72b8 !important;
    border-color: #4a90d9 !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .12);
}
:root[data-tema="gelap"] .unggah-tombol:hover { background: #3d84cc !important; }

/* Cincin fokus: :focus-within tetap bekerja walau JS gagal memasang kelas
   .fokus (dipertahankan untuk kompatibilitas). */
.unggah:focus-within .unggah-tombol,
.unggah.fokus .unggah-tombol {
    box-shadow: 0 0 0 3px rgba(43, 108, 176, .38), 0 4px 10px rgba(31, 78, 128, .25);
}
:root[data-tema="gelap"] .unggah:focus-within .unggah-tombol,
:root[data-tema="gelap"] .unggah.fokus .unggah-tombol {
    box-shadow: 0 0 0 3px rgba(96, 165, 250, .42), 0 4px 10px rgba(0, 0, 0, .45);
}

/* ---------- Ikon 📁: chip kecil semi-transparan di dalam tombol ------- */
.unggah-ikon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    font-size: 13px;
    line-height: 1;
    background: rgba(255, 255, 255, .18);
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 6px;
    transition: background .18s;
}
.unggah-tombol:hover .unggah-ikon { background: rgba(255, 255, 255, .28); }

.input-form[type="file"].unggah-input,
input[type="file"].unggah-input {
    /* Input aslinya disembunyikan secara visual, tetap ada di DOM & bisa
       difokus. PENTING: spesifisitas harus MELEBIHI aturan umum
       .input-form / input di style.css (0,1,1). Karena itu pakai
       input[type="file"].unggah-input (0,2,1) + !important pada properti
       utama - kalau kalah spesifisitas, input native browser
       ("Choose File / No file chosen") muncul kembali. */
    position: absolute !important;
    width: 1px !important; height: 1px !important;
    padding: 0 !important; margin: -1px !important;
    border: 0 !important; min-width: 0 !important; max-width: none !important;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ---------- Chip nama berkas: baru muncul setelah ada berkas dipilih -- */
.unggah-nama {
    flex: 1 1 200px;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 11px;
    font-size: 12.5px;
    line-height: 1.4;
    font-weight: 600;
    color: var(--teks-2);
    background: var(--kartu-2);
    border: 1px dashed var(--garis);
    border-radius: 9px;
    overflow-wrap: anywhere;
}
/* Ikon status di depan nama berkas (teks nama ditulis unggah.js). */
.unggah-nama::before { content: ""; flex: 0 0 auto; line-height: 1; }
.unggah.ada-berkas .unggah-nama {
    color: var(--ijo-tua);
    background: var(--ijo-lembut);
    border: 1px solid var(--ijo);
}
.unggah.ada-berkas .unggah-nama::before {
    content: "✓";
    font-size: 12px;
    font-weight: 800;
    color: var(--ijo);
}
.unggah.kebaca-besar .unggah-nama,
.unggah.bukan-berkas .unggah-nama {
    color: var(--merah);
    background: var(--merah-lembut);
    border: 1px solid var(--merah);
}
.unggah.kebaca-besar .unggah-nama::before,
.unggah.bukan-berkas .unggah-nama::before {
    content: "⚠";
    font-size: 12px;
    color: var(--merah);
}
/* Keadaan kosong: sembunyikan, biar tidak membingungkan.
   ATURAN INI HARUS SETELAH aturan chip di atas supaya menang. */
.unggah:not(.ada-berkas):not(.kebaca-besar):not(.bukan-berkas) .unggah-nama {
    display: none;
}

/* ---------- Catatan kecil di bawah tombol ---------------------------- */
.unggah-catatan {
    display: block;
    max-width: 68ch;
    font-size: 11.5px;
    line-height: 1.55;
    color: var(--teks-3);
}
.unggah-catatan b { color: var(--teks-2); }

/* Dipakai unggah.js bila form dikirim padahal berkas wajib belum dipilih -
   pengganti gelung validasi bawaan browser yang bahasanya ikut setelan
   browser, bukan bahasa halaman. */
.unggah-salah {
    flex: 1 0 100%;
    padding: 7px 10px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--merah);
    background: var(--merah-lembut);
    border: 1px solid var(--merah);
    border-radius: 8px;
}

/* ---------- Hormati preferensi kurangi animasi ------------------------ */
@media (prefers-reduced-motion: reduce) {
    .unggah-tombol,
    .unggah-ikon { transition: none; }
    .unggah-tombol:hover,
    .unggah-tombol:active { transform: none; }
}
