/* ============================================================
 * Flat Theme Alerts — global flash-message upgrade
 * Matches the Flat theme aesthetic:
 *   - borderless, rounded cards (Flat client theme: 10px radius)
 *   - soft layered shadows, clean white surfaces
 *   - accent bar per severity (flat palette: #84c529 green,
 *     #fc2d42 red, #f0ad4e amber, #28b8da cyan)
 * Works in the admin core (Inter font) and the Flat clients theme
 * (Open Sans), Bootstrap 3.4, LTR and RTL.
 * ============================================================ */

:root {
    --fa-radius: 10px;
    --fa-shadow: 0 8px 24px rgba(15, 23, 42, 0.16), 0 2px 6px rgba(15, 23, 42, 0.08);
    --fa-danger: #fc2d42;
    --fa-warning: #f0ad4e;
    --fa-success: #84c529;
    --fa-info: #28b8da;
}

/* ------------------------------------------------------------
 * Floating alerts (shared markup with core .float-alert)
 * All alerts anchor TOP-CENTER so they are impossible to miss,
 * regardless of scroll position. !important beats any stock
 * theme / module CSS (core uses top:20px/right:20px).
 * ------------------------------------------------------------ */

.float-alert.alert {
    position: fixed !important;
    top: 16px !important;
    bottom: auto !important;
    right: auto !important;
    left: 50% !important;
    transform: translate(var(--fa-shift, -50%), 0);
    border: none;
    border-radius: var(--fa-radius);
    box-shadow: var(--fa-shadow);
    background-color: #ffffff;
    color: #1f2937;
    font-weight: 500;
    padding: 14px 44px 14px 46px;
    min-height: 52px;
    width: 420px !important;
    max-width: calc(100vw - 30px);
    overflow: hidden;
    cursor: default;
    z-index: 9999;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

/* Entrance: slides down + fades in from the top viewport edge */
.float-alert.fa-alert-in {
    animation: fa-slide-down 0.35s cubic-bezier(0.23, 1, 0.32, 1) both;
}

@keyframes fa-slide-down {
    from {
        opacity: 0;
        transform: translate(var(--fa-shift, -50%), -28px);
    }
    to {
        opacity: 1;
        transform: translate(var(--fa-shift, -50%), 0);
    }
}

.float-alert .alert-title {
    display: block;
    line-height: 1.45;
    word-wrap: break-word;
}

/* Core sets .alert.float-alert .alert-title { margin-left: 30px } — our
   icon chip + padding already account for the space */
.float-alert.alert .alert-title {
    margin-left: 0;
}

.float-alert .fa-alert-close,
.float-alert button.close {
    position: absolute;
    right: 10px;
    top: 50%;
    margin-top: -13px;
    z-index: 1033;
    background-color: rgba(15, 23, 42, 0.06);
    display: block;
    border-radius: 50%;
    opacity: 0.55;
    line-height: 12px;
    width: 26px;
    height: 26px;
    outline: 0 !important;
    text-align: center;
    padding: 3px;
    font-weight: 400;
    color: #1f2937;
    text-shadow: none;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.float-alert .fa-alert-close:hover,
.float-alert .fa-alert-close:focus {
    opacity: 1;
    background-color: rgba(15, 23, 42, 0.12);
}

/* Left accent bar */

.float-alert::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    border-radius: var(--fa-radius) 0 0 var(--fa-radius);
}

.alert-success.float-alert::before { background-color: var(--fa-success); }
.alert-info.float-alert::before    { background-color: var(--fa-info); }
.alert-warning.float-alert::before { background-color: var(--fa-warning); }
.alert-danger.float-alert::before  { background-color: var(--fa-danger); }

/* Icon chip */

.float-alert span[data-notify="icon"] {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 19px;
    display: block;
    margin: 0;
}

.alert-success.float-alert span[data-notify="icon"] { color: var(--fa-success); }
.alert-info.float-alert span[data-notify="icon"]    { color: var(--fa-info); }
.alert-warning.float-alert span[data-notify="icon"] { color: var(--fa-warning); }
.alert-danger.float-alert span[data-notify="icon"]  { color: var(--fa-danger); }

/* ------------------------------------------------------------
 * Transient alerts: countdown progress bar at the bottom
 * ------------------------------------------------------------ */

.float-alert.fa-alert-transient .fa-alert-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    opacity: 0.55;
    animation-name: fa-countdown;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

.alert-success.float-alert .fa-alert-progress { background-color: var(--fa-success); }
.alert-info.float-alert .fa-alert-progress    { background-color: var(--fa-info); }

@keyframes fa-countdown {
    from { width: 100%; }
    to   { width: 0; }
}

/* ------------------------------------------------------------
 * Sticky alerts (danger / warning) — never auto-hide
 * ------------------------------------------------------------ */

.float-alert.fa-alert-sticky {
    font-weight: 600;
}

.float-alert.fa-alert-sticky .alert-title {
    color: #1f2937;
}

/* Pulsing accent for critical attention (overlays the left accent bar) */

.float-alert.fa-alert-sticky .fa-sticky-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    animation: fa-pulse-bar 1.8s ease-in-out infinite;
}

.alert-danger.float-alert .fa-sticky-bar  { background-color: var(--fa-danger); }
.alert-warning.float-alert .fa-sticky-bar { background-color: var(--fa-warning); }

@keyframes fa-pulse-bar {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

/* "Action required" chip */

.float-alert .fa-sticky-hint {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: #ffffff;
}

.alert-danger.float-alert .fa-sticky-hint  { background-color: var(--fa-danger); }
.alert-warning.float-alert .fa-sticky-hint { background-color: var(--fa-warning); color: #4a3200; }

/* Exit animation (fade up + out) */

.float-alert.fa-alert-out {
    opacity: 0;
    transform: translate(var(--fa-shift, -50%), -14px);
}

/* ------------------------------------------------------------
 * "Dismiss all" pill
 * ------------------------------------------------------------ */

#fa-alerts-dismiss-all {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    z-index: 9999;
    border: none;
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
    background-color: rgba(15, 23, 42, 0.82);
    box-shadow: var(--fa-shadow);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, top 0.2s ease;
}

#fa-alerts-dismiss-all.fa-visible {
    opacity: 1;
    pointer-events: auto;
}

#fa-alerts-dismiss-all:hover {
    background-color: rgba(15, 23, 42, 1);
}

/* ------------------------------------------------------------
 * Critical error modal (Bootstrap 3)
 * ------------------------------------------------------------ */

.fa-critical-modal .fa-critical-dialog {
    width: 480px;
    max-width: calc(100% - 30px);
    margin: 0 auto;
    top: 50%;
    transform: translateY(-50%);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.fa-critical-modal .modal-content {
    border: none;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.35);
    overflow: hidden;
}

.fa-critical-modal .modal-body {
    padding: 28px 28px 10px 28px;
    text-align: center;
}

.fa-critical-modal .fa-critical-x {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 10;
    border: none;
    background: rgba(15, 23, 42, 0.06);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    line-height: 28px;
    text-align: center;
    padding: 0;
    color: #1f2937;
    text-shadow: none;
    opacity: 0.55;
    outline: 0 !important;
}

.fa-critical-modal .fa-critical-x:hover {
    opacity: 1;
    background: rgba(15, 23, 42, 0.12);
}

.fa-critical-modal .fa-critical-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 14px auto;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    color: #ffffff;
}

.fa-critical-modal .fa-critical-icon-danger {
    background: linear-gradient(135deg, #ff5d6e, var(--fa-danger));
    box-shadow: 0 8px 20px rgba(252, 45, 66, 0.35);
}

.fa-critical-modal .fa-critical-icon-warning {
    background: linear-gradient(135deg, #ffc069, var(--fa-warning));
    box-shadow: 0 8px 20px rgba(240, 173, 78, 0.35);
}

.fa-critical-modal .fa-critical-title {
    margin: 0 0 6px 0;
    font-weight: 700;
    color: #0f172a;
    font-size: 20px;
}

.fa-critical-modal .fa-critical-subtitle {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 14px;
}

.fa-critical-modal .fa-critical-message {
    background-color: #fff1f3;
    border: 1px solid rgba(252, 45, 66, 0.18);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 13.5px;
    line-height: 1.55;
    color: #7f1d2b;
    text-align: left;
    word-wrap: break-word;
    max-height: 260px;
    overflow-y: auto;
}

.fa-critical-modal .fa-critical-details-wrap {
    margin-top: 8px;
    text-align: left;
}

.fa-critical-modal .fa-critical-toggle-details {
    padding: 0;
    font-size: 12.5px;
    color: #2563eb;
    box-shadow: none !important;
    outline: 0 !important;
}

.fa-critical-modal .fa-critical-details {
    margin-top: 6px;
    background-color: #0f172a;
    color: #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    max-height: 200px;
    overflow: auto;
    font-size: 11.5px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    border: none;
}

.fa-critical-modal .fa-critical-footer {
    padding: 10px 28px 24px 28px;
    border-top: none;
    text-align: center;
}

.fa-critical-modal .fa-critical-ack {
    border-radius: 10px;
    font-weight: 600;
    padding: 10px 18px;
    border: none;
}

/* Modal must beat every stacked element, incl. dataTables and headers */
.fa-critical-modal,
.modal-backdrop.fa-critical-backdrop {
    z-index: 99999;
}

/* ------------------------------------------------------------
 * RTL + mobile
 * ------------------------------------------------------------ */

/* Alerts anchor top-CENTER for both LTR and RTL (identical physical
   layout: icon left, close right — matching stock Perfex behavior). */

@media (max-width: 768px) {
    .float-alert.alert {
        --fa-shift: 0px;
        left: 15px !important;
        right: 15px !important;
        width: auto !important;
    }

    .fa-critical-modal .fa-critical-dialog {
        width: calc(100% - 30px);
        max-width: 480px;
    }
}
