﻿.popup {
    --accent: #2563eb;
    /* Explicit centering (survives CSS resets such as * { margin: 0 }) */
    position: fixed;
    inset: 0;
    margin: auto;
    height: fit-content;
    max-height: calc(100vh - 32px);
    width: 440px;
    max-width: calc(100vw - 32px);
    padding: 0;
    border: 0;
    border-radius: 8px;
    overflow: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,.3);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: #1f2937;
}

    .popup::backdrop {
        background: rgba(0,0,0,.45);
    }

    .popup[open] {
        animation: popup-in .15s ease-out;
    }

@keyframes popup-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ---------- Header ---------- */
.popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--accent);
    color: #fff;
}

.popup-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.popup-close {
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

/* ---------- Body ---------- */
.popup-body {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 16px;
    background: #fff;
}

.popup-icon {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    line-height: 40px;
    text-align: center;
}

.popup-content {
    flex: 1;
    min-width: 0;
}

.popup-message {
    margin: 0 0 10px;
    font-size: 14px;
    line-height: 1.5;
}

    .popup-message a, .popup-submessage a {
        color: var(--accent);
    }

    .popup-message ul, .popup-submessage ul {
        margin: 6px 0;
        padding-left: 20px;
    }

/* Sub message placeholder */
.popup-submessage {
    margin: -4px 0 10px;
    font-size: 13px;
    line-height: 1.5;
    color: #6b7280;
}

/* Error code placeholder */
.popup-code {
    display: inline-block;
    margin-bottom: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    background: #f3f4f6;
    font-size: 12px;
    color: #374151;
}

    .popup-code code {
        font-weight: 700;
    }

/* Details placeholder */
.popup-details summary {
    cursor: pointer;
    font-size: 13px;
    color: #4b5563;
}

.popup-details pre {
    margin: 8px 0 0;
    padding: 10px;
    max-height: 160px;
    overflow: auto;
    border-radius: 4px;
    background: #f3f4f6;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Optional input field (confirm type) */
.popup-field {
    margin-top: 12px;
}

.popup-field-label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 600;
}

.popup-input {
    box-sizing: border-box;
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font: inherit;
    font-size: 14px;
}

textarea.popup-input {
    resize: vertical;
}

.popup-input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 0;
    border-color: var(--accent);
}

.popup-input.invalid {
    border-color: #dc2626;
}

.popup-field-error {
    margin-top: 4px;
    font-size: 12px;
    color: #dc2626;
}

/* ---------- Footer / buttons ---------- */
.popup-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.popup-btn {
    padding: 6px 16px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
    cursor: pointer;
}

    .popup-btn:hover {
        background: #f3f4f6;
    }

    .popup-btn.primary {
        background: var(--accent);
        border-color: var(--accent);
        color: #fff;
    }

        .popup-btn.primary:hover {
            filter: brightness(.92);
        }

.popup [hidden] {
    display: none !important;
}

/* ---------- Type colours ---------- */
.popup-info {
    --accent: #2563eb;
}

.popup-warning {
    --accent: #d97706;
}

.popup-alert {
    --accent: #dc2626;
}

.popup-confirm {
    --accent: #059669;
}

.popup .popup-icon[hidden] {
    display: none;
}

/* Wide variant */
.popup.popup-wide {
    width: 760px;
}
