/* ============================================================
   Уведомления и диалоги подтверждения — по центру экрана (1.3)
   Подключается из inc/extras.php, логика — assets/js/notify.js
   ============================================================ */

/* ---------- Контейнер тостов ---------- */
#sn-notify-root {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    pointer-events: none;            /* клики проходят сквозь пустое место */
    box-sizing: border-box;
}

.sn-note {
    --sn-note-color: #6366f1;
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    width: min(420px, 100%);
    box-sizing: border-box;
    padding: 16px 44px 18px 16px;
    border-radius: 20px;
    background: var(--card, #fff);
    color: var(--text, #0f172a);
    border: 1px solid var(--border, rgba(15, 23, 42, .08));
    box-shadow: 0 24px 60px rgba(15, 23, 42, .28), 0 2px 8px rgba(15, 23, 42, .08);
    font-size: 15px;
    line-height: 1.45;
    overflow: hidden;
    pointer-events: auto;
    cursor: pointer;
    opacity: 0;
    transform: translateY(8px) scale(.92);
    transition: opacity .22s ease, transform .22s cubic-bezier(.2, .9, .3, 1.2);
    -webkit-tap-highlight-color: transparent;
}
.sn-note.is-in { opacity: 1; transform: none; }
.sn-note.is-out { opacity: 0; transform: translateY(-6px) scale(.94); transition-duration: .18s; }

.sn-note.is-success { --sn-note-color: #16a34a; }
.sn-note.is-error   { --sn-note-color: #ef4444; }
.sn-note.is-warning { --sn-note-color: #f59e0b; }
.sn-note.is-info    { --sn-note-color: #6366f1; }

.sn-note-icon {
    flex: 0 0 40px;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: rgba(100, 116, 139, .14);   /* запасной цвет для старых браузеров */
    background: color-mix(in srgb, var(--sn-note-color) 16%, transparent);
    color: var(--sn-note-color);
    font-size: 20px;
    line-height: 1;
}
.sn-note-icon svg { width: 22px; height: 22px; display: block; }

.sn-note-text {
    flex: 1;
    min-width: 0;
    white-space: pre-line;           /* переносы \n из alert() */
    overflow-wrap: anywhere;
    font-weight: 500;
}

.sn-note-close {
    position: absolute;
    top: 8px; right: 8px;
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border: 0; border-radius: 50%;
    background: transparent;
    color: var(--muted, #64748b);
    font-size: 15px; line-height: 1;
    cursor: pointer;
}
.sn-note-close:hover { background: var(--sn-soft, rgba(100, 116, 139, .14)); color: var(--text, #0f172a); }

/* Полоска оставшегося времени */
.sn-note-bar {
    position: absolute;
    left: 0; bottom: 0;
    height: 3px; width: 100%;
    background: var(--sn-note-color);
    opacity: .75;
    transform-origin: left center;
    animation: sn-note-bar linear forwards;
    animation-duration: var(--sn-note-time, 3500ms);
}
.sn-note:hover .sn-note-bar { animation-play-state: paused; }
@keyframes sn-note-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- Диалог подтверждения ---------- */
.sn-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 100001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    background: rgba(15, 23, 42, .45);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity .2s ease;
}
.sn-dialog-overlay.is-in { opacity: 1; }

.sn-dialog {
    width: min(400px, 100%);
    box-sizing: border-box;
    padding: 26px 24px 22px;
    border-radius: 24px;
    background: var(--card, #fff);
    color: var(--text, #0f172a);
    border: 1px solid var(--border, rgba(15, 23, 42, .08));
    box-shadow: 0 30px 80px rgba(15, 23, 42, .35);
    text-align: center;
    transform: translateY(10px) scale(.94);
    transition: transform .22s cubic-bezier(.2, .9, .3, 1.2);
}
.sn-dialog-overlay.is-in .sn-dialog { transform: none; }

.sn-dialog-icon {
    width: 56px; height: 56px;
    margin: 0 auto 14px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: rgba(245, 158, 11, .16);
    color: #f59e0b;
}
.sn-dialog-icon.is-danger { background: rgba(239, 68, 68, .14); color: #ef4444; }
.sn-dialog-icon svg { width: 28px; height: 28px; display: block; }

.sn-dialog-text {
    margin: 0 0 20px;
    font-size: 16px;
    line-height: 1.5;
    font-weight: 500;
    white-space: pre-line;
    overflow-wrap: anywhere;
}
.sn-dialog-actions { display: flex; gap: 10px; }
.sn-dialog-actions button {
    flex: 1;
    min-height: 44px;
    padding: 10px 16px;
    border-radius: 14px;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border, rgba(15, 23, 42, .14));
    background: var(--card, #fff);
    color: var(--text, #0f172a);
    transition: background .15s, transform .1s;
}
.sn-dialog-actions button:hover { background: var(--sn-soft, rgba(100, 116, 139, .1)); }
.sn-dialog-actions button:active { transform: scale(.97); }
.sn-dialog-actions .sn-dialog-ok {
    border-color: transparent;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
}
.sn-dialog-actions .sn-dialog-ok:hover { background: linear-gradient(135deg, #5558e8, #7c4de8); }
.sn-dialog-actions .sn-dialog-ok.is-danger { background: linear-gradient(135deg, #ef4444, #dc2626); }
.sn-dialog-actions .sn-dialog-ok.is-danger:hover { background: linear-gradient(135deg, #e23838, #c91f1f); }

/* ---------- Баннеры .flash заменяются тостом ---------- */
.flash.sn-flash-moved { display: none !important; }

/* ---------- Тёмная тема ---------- */
html.theme-dark .sn-note { box-shadow: 0 24px 60px rgba(0, 0, 0, .6); border-color: rgba(255, 255, 255, .08); }
html.theme-dark .sn-dialog-overlay { background: rgba(0, 0, 0, .6); }

/* ---------- Телефон ---------- */
@media (max-width: 480px) {
    .sn-note { padding: 14px 40px 16px 14px; font-size: 14.5px; border-radius: 18px; }
    .sn-dialog { padding: 22px 18px 18px; border-radius: 22px; }
}
@media (prefers-reduced-motion: reduce) {
    .sn-note, .sn-dialog, .sn-dialog-overlay { transition: none; }
    .sn-note-bar { animation: none; display: none; }
}

/* ---------- Коды восстановления (1.3.2) ---------- */
.sn-codes-dialog { width: min(440px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; }
.sn-codes-title { margin: 0 0 8px; font-size: 19px; }
.sn-codes-dialog .sn-dialog-text { font-size: 14px; color: var(--muted, #64748b); margin-bottom: 14px; }
.sn-codes-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    margin-bottom: 12px;
}
.sn-codes-grid code {
    padding: 9px 6px; border-radius: 10px;
    background: var(--sn-soft, rgba(100, 116, 139, .12));
    font: 600 14px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: .04em; user-select: all;
}
.sn-codes-tools { display: flex; gap: 8px; margin-bottom: 14px; }
.sn-codes-tools button {
    flex: 1; min-height: 40px; border-radius: 12px; cursor: pointer;
    border: 1px solid var(--border, rgba(15, 23, 42, .14)); background: var(--card, #fff); color: inherit;
    font: inherit; font-size: 14px; font-weight: 600;
}
.sn-codes-tools button:hover { background: var(--sn-soft, rgba(100, 116, 139, .1)); }
.sn-codes-ack { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 14px; font-size: 14px; cursor: pointer; }
.sn-dialog-actions .sn-dialog-ok:disabled { opacity: .45; cursor: not-allowed; }
.settings-grid-btn { display: flex; align-items: flex-end; }
.flash.warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ============================================================
   1.3.14 — плашки о новых сообщениях и уведомлениях (правый верхний угол)
   ============================================================ */
#sn-pop-root {
    position: fixed;
    top: calc(74px + env(safe-area-inset-top, 0px));
    right: 18px;
    z-index: 99990;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100vw - 24px));
    pointer-events: none;
    box-sizing: border-box;
}
.sn-pop {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 40px 14px 12px;
    border-radius: 18px;
    background: var(--card, #fff);
    color: var(--text, #0f172a);
    border: 1px solid var(--border, rgba(15, 23, 42, .08));
    box-shadow: 0 18px 44px rgba(15, 23, 42, .22), 0 2px 8px rgba(15, 23, 42, .08);
    text-decoration: none;
    overflow: hidden;
    pointer-events: auto;
    cursor: pointer;
    opacity: 0;
    transform: translateX(28px);
    transition: opacity .22s ease, transform .26s cubic-bezier(.2, .9, .3, 1.15);
    -webkit-tap-highlight-color: transparent;
}
.sn-pop:hover { text-decoration: none; color: var(--text, #0f172a); }
.sn-pop.is-in  { opacity: 1; transform: none; }
.sn-pop.is-out { opacity: 0; transform: translateX(28px); transition-duration: .2s; }

.sn-pop-ava {
    position: relative;
    flex: 0 0 46px;
    width: 46px; height: 46px;
    border-radius: 50%;
    background: rgba(99, 102, 241, .14);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; line-height: 1;
}
.sn-pop-ava img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.sn-pop-kind {
    position: absolute;
    right: -4px; bottom: -4px;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--card, #fff);
    border: 2px solid var(--card, #fff);
    box-shadow: 0 1px 4px rgba(15, 23, 42, .25);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; line-height: 1;
}
.sn-pop-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sn-pop-body strong {
    font-size: 14px; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sn-pop-body span {
    font-size: 14px; line-height: 1.35;
    color: var(--muted, #64748b);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; overflow-wrap: anywhere;
}
.sn-pop-close {
    position: absolute; top: 8px; right: 8px;
    width: 26px; height: 26px;
    border: 0; border-radius: 50%;
    background: transparent; color: var(--muted, #64748b);
    font-size: 13px; line-height: 1; cursor: pointer;
}
.sn-pop-close:hover { background: rgba(100, 116, 139, .16); }
.sn-pop-bar {
    position: absolute; left: 0; right: 0; bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, #6366f1, #a855f7);
    transform-origin: left;
    animation: sn-pop-bar var(--sn-pop-time, 7s) linear forwards;
}
@keyframes sn-pop-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
html.theme-dark .sn-pop { box-shadow: 0 18px 44px rgba(0, 0, 0, .55); border-color: rgba(255, 255, 255, .08); }

@media (max-width: 768px) {
    #sn-pop-root { top: calc(64px + env(safe-area-inset-top, 0px)); right: 12px; left: 12px; width: auto; }
}
@media (prefers-reduced-motion: reduce) {
    .sn-pop { transition: opacity .15s ease; transform: none; }
    .sn-pop-bar { animation: none; }
}

