/* ==================================================
   SIMAS — Modal konfirmasi modern (ganti confirm() bawaan browser)
   Dipakai lewat SweetAlert2, dipanggil dari simas-confirm.js
   Versi 3: ikon beranimasi, popup masuk/keluar halus, timer, toast.
   ================================================== */

.swal2-container {
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    background: rgba(15, 23, 42, .45) !important;
}

.simas-swal-popup {
    position: relative;
    overflow: hidden;
    border-radius: 26px !important;
    padding: 46px 36px 34px !important;
    font-family: inherit !important;
    width: auto !important;
    max-width: 400px !important;
    box-shadow:
        0 32px 70px -18px rgba(15, 23, 42, .38),
        0 12px 28px -14px rgba(15, 23, 42, .22) !important;
}

/* Aksen warna tipis di tepi atas, menyesuaikan tema aksi */
.simas-swal-popup::before {
    content: '';
    position: absolute;
    top: 0;
    left: 8%;
    right: 8%;
    height: 5px;
    border-radius: 0 0 6px 6px;
    background: linear-gradient(90deg,
        transparent,
        var(--simas-color, #4F46E5),
        transparent);
}

.simas-swal-icon {
    position: relative;
    width: 82px;
    height: 82px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2px auto 24px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .55);
    animation: simasIconPop .5s cubic-bezier(.34, 1.56, .64, 1) both;
}

/* Cincin yang mekar sekali saat modal terbuka — bukan animasi berulang */
.simas-swal-icon::after {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 2px solid currentColor;
    opacity: 0;
    animation: simasRingPop .85s cubic-bezier(.22, .61, .36, 1) .05s both;
}

.simas-swal-icon svg {
    position: relative;
    z-index: 1;
    width: 36px;
    height: 36px;
}

@keyframes simasIconPop {
    0%   { transform: scale(.35); opacity: 0; }
    60%  { transform: scale(1.12); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes simasRingPop {
    0%   { transform: scale(.7); opacity: .55; }
    100% { transform: scale(1.6); opacity: 0; }
}

.simas-swal-title {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 800;
    color: #161b26;
    line-height: 1.4;
    letter-spacing: -.01em;
}

.simas-swal-msg {
    margin: 8px 0 0;
    font-size: 14.5px;
    color: #6b7280;
    line-height: 1.65;
}

.simas-swal-actions {
    width: 100% !important;
    gap: 10px !important;
    margin: 30px 0 0 !important;
}

.simas-swal-btn {
    flex: 1 1 0;
    min-width: 0;
    border: none;
    border-radius: 14px;
    padding: 14px 10px;
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: filter .15s ease, transform .12s ease, box-shadow .15s ease;
}

.simas-swal-btn:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
}

.simas-swal-btn:active {
    transform: scale(.97) translateY(0);
}

.simas-swal-cancel {
    background: #f1f2f6;
    color: #4b5563;
    box-shadow: inset 0 0 0 1px #e5e7eb;
}

.simas-swal-cancel:hover {
    background: #e9eaef;
}

/* Warna & gradien tombol konfirmasi diberikan lewat inline style
   (dihitung dari tema di simas-confirm.js) supaya otomatis mengikuti
   warna aksi: biru admin, hijau guru, oranye/merah untuk peringatan, dst. */
.simas-swal-confirm {
    color: #fff;
    box-shadow: 0 12px 24px -10px var(--simas-shadow, rgba(79, 70, 229, .55));
}

@media (max-width: 420px) {
    .simas-swal-popup {
        padding: 38px 24px 28px !important;
    }
}


/* ==================================================
   v3 — ANIMASI IKON
   Garis ikon "digambar" lewat stroke-dashoffset (path pakai pathLength=1).
   ================================================== */

.simas-swal-icon .sa-draw {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: saDraw .55s cubic-bezier(.65, 0, .35, 1) .28s forwards;
}
.simas-swal-icon .sa-draw.sa-d2 { animation-delay: .5s; animation-duration: .4s; }

@keyframes saDraw { to { stroke-dashoffset: 0; } }

/* Sukses: lingkaran hijau "berdenyut" sekali setelah centang selesai */
.simas-i-success { animation: simasIconPop .5s cubic-bezier(.34, 1.56, .64, 1) both, saPulse .6s ease .75s; }
@keyframes saPulse {
    0%   { box-shadow: 0 0 0 0 rgba(22, 163, 74, .45); }
    100% { box-shadow: 0 0 0 22px rgba(22, 163, 74, 0); }
}

/* Gagal: ikon bergetar ke kiri-kanan setelah silang tergambar */
.simas-i-danger { animation: simasIconPop .5s cubic-bezier(.34, 1.56, .64, 1) both, saShake .55s ease .8s; }
@keyframes saShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(3px); }
}

/* Peringatan: segitiga memantul, titik berkedip */
.simas-i-warn { animation: simasIconPop .5s cubic-bezier(.34, 1.56, .64, 1) both, saBounce .7s ease .8s; }
@keyframes saBounce {
    0%, 100% { transform: translateY(0); }
    35% { transform: translateY(-9px); }
    65% { transform: translateY(0); }
    82% { transform: translateY(-3px); }
}
.simas-i-warn .sa-dot { opacity: 0; animation: saFade .2s ease .75s forwards; }
@keyframes saFade { to { opacity: 1; } }

/* Info: cincin bernapas pelan */
.simas-i-info { animation: simasIconPop .5s cubic-bezier(.34, 1.56, .64, 1) both, saBreath 2.4s ease-in-out 1s infinite; }
@keyframes saBreath {
    0%, 100% { box-shadow: 0 0 0 0 rgba(2, 132, 199, .28); }
    50% { box-shadow: 0 0 0 12px rgba(2, 132, 199, 0); }
}

/* Konfirmasi hapus / logout: ikon bergoyang halus agar menarik perhatian */
.simas-i-confirm-danger, .simas-i-logout, .simas-i-trash {
    animation: simasIconPop .5s cubic-bezier(.34, 1.56, .64, 1) both, saWiggle .6s ease .7s;
}
@keyframes saWiggle {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-9deg); }
    55% { transform: rotate(7deg); }
    80% { transform: rotate(-3deg); }
}
.simas-i-logout .sa-arrow { animation: saArrow .9s ease-in-out .8s 2; }
@keyframes saArrow { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(2.2px); } }

/* ==================================================
   v3 — POPUP MASUK / KELUAR
   ================================================== */

.simas-pop-in  { animation: simasPopIn .38s cubic-bezier(.34, 1.4, .64, 1) both !important; }
.simas-pop-out { animation: simasPopOut .22s ease-in both !important; }
.simas-fade-in  { animation: simasFadeIn .25s ease both !important; }
.simas-fade-out { animation: simasFadeOut .22s ease both !important; }

@keyframes simasPopIn {
    0%   { transform: translateY(26px) scale(.82); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes simasPopOut {
    0%   { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(14px) scale(.92); opacity: 0; }
}
@keyframes simasFadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes simasFadeOut { from { opacity: 1; } to { opacity: 0; } }

/* Progress bar auto-close (notifikasi sukses) */
.simas-swal-timer {
    height: 4px !important;
    border-radius: 0 4px 4px 0;
    opacity: .85;
}

/* Pesan panjang / daftar error tetap rapi */
.simas-swal-msg { word-break: break-word; }
.simas-swal-msg ul, .simas-swal-msg ol { text-align: left; margin: 10px 0 0; padding-left: 20px; }
.simas-swal-msg b, .simas-swal-msg strong { color: #374151; }

.simas-swal-confirm.swal2-loading,
.simas-swal-confirm:disabled { opacity: .85; cursor: wait; }
.simas-swal-popup .swal2-loader { border-color: #fff transparent #fff transparent; }

/* ==================================================
   v3 — TOAST (pojok kanan atas)
   ================================================== */

#simas-toast-wrap {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}

.simas-toast {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 38px 16px 14px;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    pointer-events: auto;
    box-shadow: 0 18px 40px -14px rgba(15, 23, 42, .35), 0 4px 12px -6px rgba(15, 23, 42, .18);
    border-left: 5px solid var(--simas-color, #4F46E5);
    animation: toastIn .45s cubic-bezier(.34, 1.4, .64, 1) both;
}
.simas-toast.out { animation: toastOut .3s ease-in forwards; }

@keyframes toastIn  { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { to { transform: translateX(120%); opacity: 0; } }

.simas-toast-icon {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.simas-toast-icon svg { width: 21px; height: 21px; }
.simas-toast-icon .sa-draw { animation-delay: .15s; }
.simas-toast-icon .sa-draw.sa-d2 { animation-delay: .35s; }

.simas-toast-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
.simas-toast-body strong { font-size: 14.5px; font-weight: 800; color: #161b26; }
.simas-toast-body span { font-size: 13.5px; color: #6b7280; word-break: break-word; }

.simas-toast-x {
    position: absolute;
    top: 6px;
    right: 8px;
    border: 0;
    background: none;
    font-size: 22px;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
    transition: color .15s ease, transform .15s ease;
}
.simas-toast-x:hover { color: #374151; transform: rotate(90deg); }

.simas-toast-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    background: var(--simas-color, #4F46E5);
    transform-origin: left;
    animation: toastBar linear forwards;
}
.simas-toast.paused .simas-toast-bar { animation-play-state: paused; }
@keyframes toastBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

@media (max-width: 480px) {
    #simas-toast-wrap { top: 10px; right: 16px; left: 16px; width: auto; }
}

/* Hormati pengguna yang menonaktifkan animasi di perangkatnya */
@media (prefers-reduced-motion: reduce) {
    .simas-swal-icon, .simas-swal-icon::after, .simas-swal-icon .sa-draw,
    .simas-pop-in, .simas-pop-out, .simas-toast, .simas-toast-bar,
    .simas-i-logout .sa-arrow, .simas-swal-icon .sa-dot { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; }
}

/* Fokus tombol: cincin lembut berwarna tema (bukan outline hitam bawaan browser) */
.simas-swal-btn:focus { outline: none; }
.simas-swal-btn:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--simas-color, #4F46E5) 35%, transparent);
    outline-offset: 2px;
}

/* Biarkan cincin animasi ikon keluar dari kotak tanpa terpotong */
.simas-swal-popup .swal2-html-container { overflow: visible !important; margin: 0 !important; padding: 0 !important; }
