/* Tampilan dasar dialog */
.pbx-dialog {
    width: min(480px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    padding: 0;
    border: 1px solid var(--app-border, #716a65);
    border-radius: 14px;
    background: var(--app-dark, #171416);
    color: var(--app-text-primary, #fff);
    box-shadow: 0 24px 80px #0007;
    font:
        15px/1.55 system-ui,
        sans-serif;
    text-align: center;
    overflow: auto;
    box-sizing: border-box;
}

/* Dialog terbuka dan backdrop */
.pbx-dialog[open] {
    animation: pbx-dialog-enter 180ms ease-out;
}

.pbx-dialog::backdrop {
    background: #0009;
}

/* Panel, judul, dan pesan */
.pbx-dialog__panel {
    position: relative;
    padding: 32px 28px 26px;
}

.pbx-dialog__title {
    margin: 12px 0;
    font-size: 25px;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.pbx-dialog__text {
    margin: 0;
    color: var(--app-text-secondary, #eee);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Ikon status */
.pbx-dialog__icon {
    display: grid;
    place-items: center;
    width: 76px;
    height: 76px;
    margin: 4px auto 20px;
    border: 4px solid currentColor;
    border-radius: 50%;
    font-size: 48px;
    line-height: 1;
    font-weight: 500;
    color: #8bc8f5;
}

.pbx-dialog__icon--success {
    color: #8fd49c;
}

.pbx-dialog__icon--error {
    color: #ff8c8c;
}

.pbx-dialog__icon--warning {
    color: #ffda83;
}

.pbx-dialog__icon--question {
    color: #bfafff;
}

/* Area aksi dan tombol */
.pbx-dialog__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 26px;
}

.pbx-dialog__actions:has(> [hidden]:first-child + [hidden]) {
    margin-top: 0;
}

.pbx-dialog button {
    font: inherit;
    cursor: pointer;
}

.pbx-dialog__confirm,
.pbx-dialog__cancel {
    min-height: 44px;
    padding: 10px 22px;
    border: 1px solid transparent;
    border-radius: 7px;
    font-weight: 600 !important;
}

.pbx-dialog__confirm {
    background: var(--app-primary, #ffbd32);
    color: var(--app-text-on-primary, #291c0b);
}

.pbx-dialog__confirm:hover {
    background: var(--app-primary-hover, #ffcc5c);
}

.pbx-dialog__cancel {
    background: var(--app-surface-input, #48433f);
    color: var(--app-text-primary, #fff);
    border-color: var(--app-border, #716a65);
}

.pbx-dialog__cancel:hover {
    filter: brightness(1.15);
}

/* Tombol tutup */
.pbx-dialog__close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--app-text-muted, #aaa);
    font-size: 28px !important;
}

.pbx-dialog__close:hover {
    color: var(--app-text-primary, #fff);
    background: #ffffff15;
}

/* Fokus keyboard dan tombol nonaktif */
.pbx-dialog button:focus-visible {
    outline: 3px solid var(--app-focus-ring, #ffbd32);
    outline-offset: 3px;
}

.pbx-dialog button:disabled {
    opacity: 0.55;
    cursor: wait;
}

/* Indikator loading */
.pbx-dialog__loader {
    width: 36px;
    height: 36px;
    box-sizing: border-box;
    margin: 22px auto 0;
    border: 3px solid #ffffff30;
    border-top-color: var(--app-primary, #ffbd32);
    border-radius: 50%;
    animation: pbx-dialog-spin 700ms linear infinite;
}

/* Pesan validasi dan visibilitas */
.pbx-dialog__validation {
    padding: 10px 12px;
    margin: 18px 0 0;
    border-radius: 6px;
    background: var(--app-error-background, #ff554411);
    color: var(--app-text-error, #ffbeb1);
    overflow-wrap: anywhere;
}

.pbx-dialog [hidden] {
    display: none;
}

/* Animasi */
@keyframes pbx-dialog-enter {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes pbx-dialog-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Preferensi pengurangan gerakan */
@media (prefers-reduced-motion: reduce) {
    .pbx-dialog[open] {
        animation: none;
    }

    .pbx-dialog__loader {
        animation-duration: 2s;
    }
}

/* Penyesuaian layar kecil */
@media (max-width: 480px) {
    .pbx-dialog__panel {
        padding: 28px 20px 22px;
    }

    .pbx-dialog__title {
        font-size: 22px;
    }
}
