/*
 * frontend/css/notify.css
 * Toasts and dialogs for frontend/js/notify.js — the site's replacement for
 * the browser's alert(), confirm() and prompt(). Every class is prefixed
 * "pk-" so nothing here collides with a page's own styles.
 */

:root {
    --pk-card:      #1c1c1f;
    --pk-card-edge: #2e2e33;
    --pk-text:      #f3f4f6;
    --pk-muted:     #a1a1aa;
    --pk-red:       #e11d48;
    --pk-red-hover: #be123c;
    --pk-green:     #10b981;
    --pk-orange:    #f59e0b;
    --pk-blue:      #3b82f6;
}

/* ---------------------------------------------------------------
   Toasts
   --------------------------------------------------------------- */

.pk-toast-stack {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 360px;
    max-width: calc(100vw - 32px);
    pointer-events: none; /* only the toasts themselves catch clicks */
}

.pk-toast {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 14px 16px;
    background: var(--pk-card);
    color: var(--pk-text);
    border: 1px solid var(--pk-card-edge);
    border-left: 4px solid var(--pk-accent);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.45;
    overflow: hidden;
    pointer-events: auto;
    animation: pk-slide-in 0.28s ease-out;
}

.pk-toast.pk-leaving {
    animation: pk-slide-out 0.22s ease-in forwards;
}

.pk-toast-success { --pk-accent: var(--pk-green); }
.pk-toast-error   { --pk-accent: var(--pk-red); }
.pk-toast-warning { --pk-accent: var(--pk-orange); }
.pk-toast-info    { --pk-accent: var(--pk-blue); }

.pk-toast-icon {
    color: var(--pk-accent);
    font-size: 1.15rem;
    line-height: 1.25;
    flex-shrink: 0;
}

.pk-toast-message {
    flex: 1;
    min-width: 0;
    word-wrap: break-word;
}

.pk-toast-close {
    background: none;
    border: none;
    color: var(--pk-muted);
    font-size: 1.25rem;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
    flex-shrink: 0;
}

.pk-toast-close:hover,
.pk-toast-close:focus-visible { color: var(--pk-text); }

.pk-toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    background: var(--pk-accent);
    opacity: 0.75;
    transform-origin: left center;
    animation: pk-progress linear forwards;
}

.pk-toast:hover .pk-toast-progress { animation-play-state: paused; }

@keyframes pk-slide-in {
    from { opacity: 0; transform: translateX(110%); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes pk-slide-out {
    to { opacity: 0; transform: translateX(110%); }
}

@keyframes pk-progress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* Phones: top centre, full width. */
@media (max-width: 767px) {
    .pk-toast-stack {
        top: 12px;
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
    }

    @keyframes pk-slide-in {
        from { opacity: 0; transform: translateY(-120%); }
        to   { opacity: 1; transform: translateY(0); }
    }

    @keyframes pk-slide-out {
        to { opacity: 0; transform: translateY(-120%); }
    }
}

/* ---------------------------------------------------------------
   Dialogs (confirm / prompt)
   --------------------------------------------------------------- */

.pk-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: pk-fade-in 0.18s ease-out;
}

.pk-modal {
    position: relative;
    width: 100%;
    max-width: 420px;
    padding: 24px;
    background: var(--pk-card);
    color: var(--pk-text);
    border: 1px solid var(--pk-card-edge);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
    font-family: inherit;
    animation: pk-pop-in 0.2s ease-out;
}

.pk-modal-success { --pk-accent: var(--pk-green);  --pk-accent-soft: rgba(16, 185, 129, 0.15); }
.pk-modal-error   { --pk-accent: var(--pk-red);    --pk-accent-soft: rgba(225, 29, 72, 0.15); }
.pk-modal-warning { --pk-accent: var(--pk-orange); --pk-accent-soft: rgba(245, 158, 11, 0.15); }
.pk-modal-info    { --pk-accent: var(--pk-blue);   --pk-accent-soft: rgba(59, 130, 246, 0.15); }

.pk-modal-x {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    color: var(--pk-muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.pk-modal-x:hover,
.pk-modal-x:focus-visible { color: var(--pk-text); }

.pk-modal-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    padding-right: 24px;
}

.pk-modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    color: var(--pk-accent);
    background: var(--pk-accent-soft);
    font-size: 1.15rem;
}

.pk-modal-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--pk-text);
}

.pk-modal-message {
    margin: 0 0 20px;
    color: #d4d4d8;
    font-size: 0.92rem;
    line-height: 1.55;
    white-space: pre-line;
}

.pk-modal-label {
    display: block;
    margin: -8px 0 6px;
    color: #d4d4d8;
    font-size: 0.85rem;
}

.pk-modal-input {
    width: 100%;
    margin-bottom: 20px;
    padding: 10px 12px;
    background: #2a2a2a;
    color: #fff;
    border: 1px solid #3f3f46;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.pk-modal-input:focus {
    outline: none;
    border-color: var(--pk-red);
}

.pk-modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Same look as the existing buttons: red primary, outlined grey Cancel. */
.pk-btn {
    padding: 9px 18px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.pk-btn-primary {
    background: var(--pk-red);
    color: #fff;
    border: 1px solid var(--pk-red);
}

.pk-btn-primary:hover,
.pk-btn-primary:focus-visible { background: var(--pk-red-hover); border-color: var(--pk-red-hover); }

.pk-btn-secondary {
    background: transparent;
    color: var(--pk-muted);
    border: 1px solid #3f3f46;
}

.pk-btn-secondary:hover,
.pk-btn-secondary:focus-visible { color: #fff; border-color: #71717a; }

.pk-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

html.pk-modal-open { overflow: hidden; }

/* Tall dialogs (the export form, long messages) scroll inside the card. */
.pk-modal {
    max-width: min(420px, 95vw);
    max-height: 90vh;
    overflow-y: auto;
}

.pk-modal-message {
    overflow-wrap: anywhere;
}

/* Phones: full-width buttons, the confirming one on top. */
@media (max-width: 767px) {
    .pk-modal-backdrop {
        padding: 10px;
    }

    .pk-modal {
        max-width: 95vw;
        padding: 22px 16px 18px;
    }

    .pk-modal-foot {
        flex-direction: column-reverse;
    }

    .pk-btn {
        width: 100%;
        min-height: 46px;
    }

    .pk-modal-x {
        top: 6px;
        right: 6px;
        width: 44px;
        height: 44px;
    }

    .pk-modal-input {
        font-size: 16px;
    }

    .pk-toast-close {
        width: 36px;
        height: 36px;
        margin: -8px -6px -8px 0;
    }
}

@keyframes pk-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes pk-pop-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .pk-toast, .pk-toast.pk-leaving, .pk-modal, .pk-modal-backdrop { animation: none; }
}
