/* ═══════════════════════════════════════════════════════════════
   Cyclone ERP — Unified Error Dialog
   Pure HTML/CSS error overlay used by all front-end hosts
   (Web, WinForms WebView, MAUI WebView).
   Independent of Blazor — survives Blazor crashes.
═══════════════════════════════════════════════════════════════ */

/* ── Overlay ─────────────────────────────────────────────── */
#cyclone-error-ui {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999500;
}

#cyclone-error-ui .ceu-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* ── Card ────────────────────────────────────────────────── */
#cyclone-error-ui .ceu-card {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #1c0d0d;
    border: 1px solid rgba(220, 38, 38, 0.4);
    border-radius: 1rem;
    padding: 2rem 2rem 1.5rem;
    width: calc(100% - 2.5rem);
    max-width: 30rem;
    max-height: 85vh;
    overflow-y: auto;
    color: #f5f0f0;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.7);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ── Dismiss (×) ─────────────────────────────────────────── */
#cyclone-error-ui .ceu-dismiss {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    line-height: 1;
    transition: color 0.15s;
}

#cyclone-error-ui .ceu-dismiss:hover {
    color: rgba(255, 255, 255, 0.85);
}

/* ── Header ──────────────────────────────────────────────── */
#cyclone-error-ui .ceu-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

#cyclone-error-ui .ceu-icon {
    font-size: 1.6rem;
    color: #f87171;
    line-height: 1;
    flex-shrink: 0;
}

#cyclone-error-ui .ceu-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fca5a5;
    letter-spacing: 0.01em;
    margin: 0;
}

/* ── Message ─────────────────────────────────────────────── */
#cyclone-error-ui .ceu-message {
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 1.25rem;
    line-height: 1.5;
    word-break: break-word;
}

/* ── Action buttons ──────────────────────────────────────── */
#cyclone-error-ui .ceu-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

#cyclone-error-ui .ceu-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.45rem 0.9rem;
    border-radius: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: filter 0.15s, transform 0.1s;
    white-space: nowrap;
    font-family: inherit;
    background: rgba(255, 255, 255, 0.1);
    color: #e5e5e5;
}

#cyclone-error-ui .ceu-btn:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

#cyclone-error-ui .ceu-btn:active {
    transform: translateY(0);
    filter: brightness(0.95);
}

#cyclone-error-ui .ceu-btn-primary {
    background: #dc2626;
    color: #fff;
}

#cyclone-error-ui .ceu-btn-ghost {
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 500;
}

#cyclone-error-ui .ceu-btn-ghost:hover {
    color: rgba(255, 255, 255, 0.85);
}

/* ── Detail panel ────────────────────────────────────────── */
#cyclone-error-ui .ceu-detail-panel {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 0.75rem;
    padding-top: 0.75rem;
}

#cyclone-error-ui .ceu-stacktrace {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.5rem;
    color: #fca5a5;
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
    font-size: 0.72rem;
    line-height: 1.5;
    margin: 0;
    max-height: 14rem;
    overflow: auto;
    padding: 0.75rem 1rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Copy toast ──────────────────────────────────────────── */
#cyclone-error-ui .ceu-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(1rem);
    background: #22c55e;
    color: #fff;
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    z-index: 9999600;
}

#cyclone-error-ui .ceu-toast.ceu-toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Mobile responsive ───────────────────────────────────── */
@media (max-width: 480px) {
    #cyclone-error-ui .ceu-card {
        padding: 1.25rem 1rem 1rem;
        border-radius: 0.75rem;
    }

    #cyclone-error-ui .ceu-actions {
        gap: 0.35rem;
    }

    #cyclone-error-ui .ceu-btn {
        padding: 0.4rem 0.65rem;
        font-size: 0.76rem;
    }
}
