/*
 * The look of every dialog and toast in the project, in one file.
 *
 * It used to be spread over three places that disagreed:
 *
 *   - alertify.rtl.css, the vendor file, had been hand-edited with a red
 *     dialog (#bc2525), a purple footer (#913ce6) and a grey header. Those
 *     are not AlertifyJS colours and are not the site's; they are somebody's
 *     leftover experiment, and they are what the login page was showing,
 *     because the login page loads no other stylesheet that overrides them.
 *
 *   - base-style.css carried an override block that only applied on pages
 *     extending base/base.html. It set the dialog's text to #FFF on an var(--atlas-rule)
 *     background -- white on light grey -- and styled .ajs-ok / .ajs-cancel,
 *     which had stopped matching anything the moment the theme was pointed at
 *     bootstrap's .btn classes.
 *
 *   - bootstrap's .btn classes, which the account pages never load at all.
 *
 * So this file owns the whole appearance and nothing here depends on
 * bootstrap. It is loaded by base/base.html and by notifications_assets.html,
 * which between them cover every page.
 *
 * Colours are the site's own: the navy of the sidebar and the buttons
 * (var(--atlas-indigo), darkening to var(--atlas-navy) and var(--atlas-navy-dark)) against white and the same
 * light greys the tables use.
 */

:root {
    --atlas-dialog-surface: #ffffff;
    --atlas-dialog-heading: var(--atlas-navy-dark);
    --atlas-dialog-text: #33384d;
    --atlas-dialog-footer: #f6f7fa;
    --atlas-dialog-edge: #e2e5ef;

    --atlas-primary: var(--atlas-indigo);
    --atlas-primary-hover: var(--atlas-navy);
    --atlas-quiet-text: #495057;
    --atlas-quiet-edge: #b9bfcc;
    --atlas-quiet-hover: #eceef4;

    --atlas-success: #2e7d54;
    --atlas-danger: #c0392f;
    --atlas-warning: #b07d10;
}

/*  ====================  The dialog  ====================  */

/* Navy rather than black: the dimmer sits over a navy-and-white page, and a
   neutral black behind it reads as a different application. */
.alertify .ajs-dimmer {
    background-color: var(--atlas-navy-dark);
    opacity: 0.42;
}

.alertify .ajs-dialog {
    /* The one accent, the same on every dialog. The level is carried by the
       title -- «خطا», «هشدار» -- rather than by a wall of colour, which is
       what made the old red dialog hard to look at. */
    border-top: 5px solid var(--atlas-primary);
    border-radius: 12px;
    background-color: var(--atlas-dialog-surface);
    color: var(--atlas-dialog-text);
    /* Inherited, so the dialog uses whichever face the page around it uses:
       Sahel everywhere, and no @font-face has to be repeated here. */
    font-family: inherit;
    padding: 0;
    max-width: 520px;
    overflow: hidden;
    box-shadow: 0 18px 44px rgba(32, 43, 93, 0.3);
}

.alertify .ajs-header {
    margin: 0;
    padding: 18px 24px 14px;
    background-color: var(--atlas-dialog-surface);
    color: var(--atlas-dialog-heading);
    font-size: 1.15rem;
    font-weight: bold;
    text-align: center;
    border-bottom: 1px solid var(--atlas-dialog-edge);
}

/* Several existing callers raise a dialog with no title -- alertify.alert("",
   "محصول وارد شده تکراری است") and the like. Without this they get an empty
   bordered strip above the message. */
.alertify .ajs-header:empty {
    display: none;
}

.alertify .ajs-body {
    padding: 0;
    color: var(--atlas-dialog-text);
}

.alertify .ajs-body .ajs-content {
    padding: 24px;
    font-size: 1.05rem;
    line-height: 2;
    text-align: center;
}

/* A single message centres well. A list of them does not -- Persian is read
   from the right, and centred bullets leave the text ragged on the edge the
   eye starts from. */
.alertify .ajs-body .ajs-content ul {
    margin: 0;
    padding: 0 1.2rem 0 0;
    text-align: right;
}

.alertify .ajs-body .ajs-content ul li {
    margin-bottom: 0.35rem;
}

.alertify .ajs-body .ajs-content ul li:last-child {
    margin-bottom: 0;
}

.alertify .ajs-footer {
    margin: 0;
    padding: 14px 24px;
    min-height: 0;
    background-color: var(--atlas-dialog-footer);
    border-top: 1px solid var(--atlas-dialog-edge);
}

.alertify .ajs-footer .ajs-buttons.ajs-primary {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 12px;
    text-align: center;
}

/* Empty on every dialog the project raises; it would otherwise hold a
   flex slot open and push the buttons off centre. */
.alertify .ajs-footer .ajs-buttons.ajs-auxiliary:empty {
    display: none;
}

/*  ====================  Buttons  ====================  */

.alertify .ajs-footer .ajs-button {
    float: none;
    margin: 0;
    min-width: 116px;
    padding: 9px 22px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.alertify .ajs-footer .ajs-button.ajs-ok {
    background-color: var(--atlas-primary);
    color: #ffffff;
}

.alertify .ajs-footer .ajs-button.ajs-ok:hover,
.alertify .ajs-footer .ajs-button.ajs-ok:focus {
    background-color: var(--atlas-primary-hover);
}

/* Outlined, not red. A cancel is the way out of a question, not a second
   destructive choice -- the old red one read as the more dangerous of the
   two buttons when it was the safe one. */
.alertify .ajs-footer .ajs-button.ajs-cancel {
    background-color: transparent;
    border-color: var(--atlas-quiet-edge);
    color: var(--atlas-quiet-text);
}

.alertify .ajs-footer .ajs-button.ajs-cancel:hover,
.alertify .ajs-footer .ajs-button.ajs-cancel:focus {
    background-color: var(--atlas-quiet-hover);
}

.alertify .ajs-button:focus-visible {
    outline: 2px solid var(--atlas-primary);
    outline-offset: 2px;
}

/*  ====================  Prompt input  ====================  */
/* Matched to the app's form controls -- the arbitrary-weight prompt on the
   order form and the delete-reason prompt both use it. */

.alertify .ajs-input {
    display: block;
    width: 100%;
    margin: 0;
    padding: 10px 12px;
    background-color: #ffffff;
    border: 1px solid var(--atlas-quiet-edge);
    border-radius: 8px;
    color: var(--atlas-dialog-text);
    font-family: inherit;
    font-size: 1rem;
    text-align: center;
}

.alertify .ajs-input:focus {
    outline: none;
    border-color: var(--atlas-primary);
    box-shadow: 0 0 0 3px rgba(57, 73, 171, 0.18);
}

/*  ====================  Toasts  ====================  */
/*
 * These do keep a colour, because unlike a dialog a toast carries no title
 * and fades on its own -- the stripe down its edge is the only thing saying
 * whether it reports a success or a failure. It is a stripe rather than a
 * filled panel, which is the same restraint as above.
 */

.alertify-notifier .ajs-message {
    background: var(--atlas-dialog-surface);
    color: var(--atlas-dialog-text);
    border: 1px solid var(--atlas-dialog-edge);
    border-right: 5px solid var(--atlas-primary);
    border-radius: 8px;
    padding: 14px 18px;
    font-family: inherit;
    font-size: 1rem;
    text-align: center;
    text-shadow: none;
    box-shadow: 0 8px 22px rgba(32, 43, 93, 0.18);
}

.alertify-notifier .ajs-message.ajs-success {
    background: var(--atlas-dialog-surface);
    color: var(--atlas-dialog-text);
    border-right-color: var(--atlas-success);
    text-shadow: none;
}

.alertify-notifier .ajs-message.ajs-error {
    background: var(--atlas-dialog-surface);
    color: var(--atlas-dialog-text);
    border-right-color: var(--atlas-danger);
    text-shadow: none;
}

.alertify-notifier .ajs-message.ajs-warning {
    background: var(--atlas-dialog-surface);
    color: var(--atlas-dialog-text);
    border-color: var(--atlas-dialog-edge);
    border-right-color: var(--atlas-warning);
}

/*  ====================  Small screens  ====================  */
/*
 * The same breakpoint mobile.css uses. A dialog is the one piece of chrome
 * that has to stay readable on a phone -- it is what tells the user their
 * order did not save -- and alertify's own layout leaves it at a fixed
 * 500px-ish box with 5% margins, which on a 375px screen puts the text
 * against both edges.
 */
@media (max-width: 767.98px) {
    .alertify .ajs-dialog {
        max-width: none;
        width: auto;
        margin: 16px;
        border-radius: 10px;
    }

    .alertify .ajs-header {
        padding: 16px 18px 12px;
        font-size: 1.05rem;
    }

    .alertify .ajs-body .ajs-content {
        padding: 18px;
        font-size: 1rem;
        line-height: 1.9;
    }

    .alertify .ajs-footer {
        padding: 12px 18px;
    }

    /* Side by side, two Persian verbs and a 116px floor each, is wider than a
       small phone. Stacked, with the action the user came for on top. */
    .alertify .ajs-footer .ajs-buttons.ajs-primary {
        flex-direction: column;
        gap: 8px;
    }

    .alertify .ajs-footer .ajs-button {
        width: 100%;
        min-width: 0;
    }

    .alertify-notifier .ajs-message {
        max-width: calc(100vw - 32px);
    }
}
