/* ============================================================
 *  CGBG UI dialogs — toast + modal + prompt
 *  Replaces native alert() / confirm() / prompt() with
 *  consistent, branded UI. Loaded globally via layout.phtml.
 * ============================================================ */

/* ---------- Toast ---------- */
.ui-toast-host {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: calc(100vw - 40px);
}

.ui-toast {
    pointer-events: auto;
    min-width: 280px;
    max-width: 420px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(15, 23, 42, 0.06);
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-left: 4px solid #4F46E5;
    animation: ui-toast-in 220ms cubic-bezier(0.18, 0.89, 0.32, 1.28) both;
    font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    color: #0f172a;
}

.ui-toast.ui-toast-out {
    animation: ui-toast-out 160ms ease-in both;
}

.ui-toast-success { border-left-color: #16a34a; }
.ui-toast-error   { border-left-color: #dc2626; }
.ui-toast-warning { border-left-color: #f59e0b; }
.ui-toast-info    { border-left-color: #2563eb; }

.ui-toast-icon {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 13px;
    font-weight: bold;
    line-height: 1;
    margin-top: 1px;
}
.ui-toast-success .ui-toast-icon { background: #16a34a; }
.ui-toast-error   .ui-toast-icon { background: #dc2626; }
.ui-toast-warning .ui-toast-icon { background: #f59e0b; }
.ui-toast-info    .ui-toast-icon { background: #2563eb; }

.ui-toast-body {
    flex: 1 1 auto;
    min-width: 0;
    word-wrap: break-word;
    white-space: pre-line;
}

.ui-toast-close {
    flex: 0 0 auto;
    border: 0;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 6px;
    transition: background 120ms;
}
.ui-toast-close:hover { background: #f1f5f9; color: #0f172a; }

@keyframes ui-toast-in {
    from { opacity: 0; transform: translateX(20px) scale(0.95); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes ui-toast-out {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(20px); }
}

/* ---------- Modal (confirm / prompt) ---------- */
.ui-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: ui-backdrop-in 160ms ease-out both;
}

.ui-modal-backdrop.ui-modal-out {
    animation: ui-backdrop-out 140ms ease-in both;
}

.ui-modal {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 30px 80px rgba(15, 23, 42, 0.35), 0 8px 24px rgba(15, 23, 42, 0.12);
    max-width: 460px;
    width: 100%;
    padding: 24px 24px 20px;
    animation: ui-modal-in 220ms cubic-bezier(0.18, 0.89, 0.32, 1.28) both;
    font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.ui-modal-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}

.ui-modal-icon {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 22px;
    font-weight: bold;
}
.ui-modal-primary .ui-modal-icon { background: #0b5fff; }
.ui-modal-danger  .ui-modal-icon { background: #dc2626; }
.ui-modal-warning .ui-modal-icon { background: #f59e0b; }
.ui-modal-info    .ui-modal-icon { background: #2563eb; }
.ui-modal-success .ui-modal-icon { background: #16a34a; }

.ui-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #0f172a;
}

.ui-modal-body {
    margin: 0 0 20px;
    color: #475569;
    font-size: 15px;
    line-height: 1.55;
    white-space: pre-line;
    word-wrap: break-word;
}

.ui-modal-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 15px;
    margin-bottom: 16px;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color 120ms, box-shadow 120ms;
}
.ui-modal-input:focus {
    outline: 0;
    border-color: #0b5fff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.ui-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.ui-modal-btn {
    border: 0;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 120ms, transform 120ms, box-shadow 120ms;
    line-height: 1.2;
}
.ui-modal-btn:active { transform: translateY(1px); }

.ui-modal-btn-cancel {
    background: #f1f5f9;
    color: #475569;
}
.ui-modal-btn-cancel:hover { background: #e2e8f0; color: #0f172a; }

.ui-modal-btn-confirm {
    background: #0b5fff;;
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}
.ui-modal-btn-confirm:hover { background: #4338ca; }

.ui-modal-danger .ui-modal-btn-confirm {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}
.ui-modal-danger .ui-modal-btn-confirm:hover { background: #b91c1c; }

.ui-modal-warning .ui-modal-btn-confirm {
    background: #f59e0b;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}
.ui-modal-warning .ui-modal-btn-confirm:hover { background: #d97706; }

@keyframes ui-backdrop-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes ui-backdrop-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}
@keyframes ui-modal-in {
    from { opacity: 0; transform: translateY(8px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Mobile tweaks ---------- */
@media (max-width: 640px) {
    .ui-toast-host {
        top: 12px;
        right: 12px;
        left: 12px;
        max-width: none;
    }
    .ui-toast { min-width: 0; max-width: none; }
    .ui-modal {
        max-width: none;
        padding: 20px 18px 16px;
    }
    .ui-modal-actions {
        flex-direction: column-reverse;
    }
    .ui-modal-btn {
        width: 100%;
        text-align: center;
        padding: 12px;
    }
}
