/*
 * Dialogs of the whole site, in the look first made for "Nowa galeria":
 * .zp-modal (dimmed backdrop) > .zp-modal-box (white card).
 * Built by inc/zp_dialog.js (zpDialog.confirm / alert, the article mailing in inc/send_article.js)
 * or written in a template (templates/gallery/create_folder_form.php, admin password dialogs in
 * templates/admin/layout.php). Loaded by templates/layout.php, layout_szkola.php, admin/layout.php
 * and admin/editor.php.
 * Every rule is scoped to .zp-modal: css/admin.css has its own .zp-btn / .zp-field.
 * Buttons everywhere: "Anuluj" first, the main action last (on the right); .zp-edit-* below gives
 * the editors (article, Kalendarz, Jadłospis, Kontakt) the same pair.
 */
html.zp-modal-open,
html.zp-modal-open body { overflow: hidden; }

.zp-modal
{
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 16px;
    background: rgba(20, 24, 20, .45);
    overscroll-behavior: contain;
    animation: zp-modal-in .15s ease-out;
}
.zp-modal[hidden] { display: none; }
@keyframes zp-modal-in { from { opacity: 0; } }

.zp-modal .zp-modal-box
{
    position: relative;
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    box-sizing: border-box;
    margin: 0;
    padding: 22px 24px 20px;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
    text-align: left;
    font: 14px/1.5 helvetica, arial, sans-serif;
    color: #444;
}
.zp-modal .zp-modal-box.zp-modal-wide { max-width: 640px; }
.zp-modal .zp-modal-title { margin: 0 0 16px; padding: 0; font: 700 24px/1.2 Dosis, sans-serif; color: #3d6b25; text-align: left; overflow-wrap: anywhere; }
.zp-modal .zp-modal-box:has(> .zp-modal-x) .zp-modal-title { padding-right: 34px; }
.zp-modal .zp-modal-text { margin: 0; font-size: 15px; color: #444; white-space: pre-line; overflow-wrap: anywhere; }
.zp-modal .zp-modal-text + .zp-modal-text { margin-top: 10px; }

/* the "×" in the corner */
.zp-modal .zp-modal-x
{
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #888;
    font: 26px/36px helvetica, arial, sans-serif;
    text-align: center;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.zp-modal .zp-modal-x:hover,
.zp-modal .zp-modal-x:focus-visible { background: #eef0ec; color: #444; outline: none; }

/* form fields */
.zp-modal .zp-field { display: block; margin: 0; }
.zp-modal .zp-field + .zp-field { margin-top: 14px; }
.zp-modal .zp-field-label { display: block; margin-bottom: 6px; font-weight: 700; font-size: 13px; color: #555; }
.zp-modal .zp-field input
{
    display: block;
    width: 100%;
    box-sizing: border-box;
    height: 42px;
    margin: 0;
    padding: 0 12px;
    border: 1px solid #d6dbd2;
    border-radius: 8px;
    /* 16px: iOS zooms the page in on inputs with smaller text */
    font: 16px helvetica, arial, sans-serif;
    color: #333;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.zp-modal .zp-field input:focus { outline: none; border-color: #5a8f3c; box-shadow: 0 0 0 3px rgba(90, 143, 60, .18); }
.zp-modal .zp-field-hint { margin: 8px 0 0; font-size: 12.5px; color: #888; }

/* messages inside a dialog: error (also .zp-modal-error), success, info */
.zp-modal .zp-modal-error,
.zp-modal .zp-modal-note { margin: 12px 0 0; padding: 8px 12px; border-radius: 8px; font-size: 13.5px; overflow-wrap: anywhere; }
.zp-modal .zp-modal-error,
.zp-modal .zp-modal-note-err { background: #fdecee; color: #b4232f; }
.zp-modal .zp-modal-note-ok { background: #eef6e8; color: #2f5a1c; }
.zp-modal .zp-modal-note-info { background: #eef3f8; color: #24527a; }
.zp-modal .zp-modal-error[hidden],
.zp-modal .zp-modal-note[hidden] { display: none; }

/* progress (article mailing) */
.zp-modal .zp-modal-progress { height: 10px; margin: 4px 0 0; border-radius: 5px; background: #eef0ec; overflow: hidden; }
.zp-modal .zp-modal-progress > span { display: block; width: 0; height: 100%; border-radius: 5px; background: #5a8f3c; transition: width .3s ease; }
.zp-modal .zp-modal-status { margin: 8px 0 0; font-size: 13px; color: #777; }
.zp-modal .zp-modal-log
{
    margin: 12px 0 0;
    max-height: 180px;
    overflow-y: auto;
    padding: 6px 10px;
    border: 1px solid #e3e7df;
    border-radius: 8px;
    background: #fafbf9;
    font: 12px/1.6 monospace;
    color: #555;
    overflow-wrap: anywhere;
}
.zp-modal .zp-modal-log[hidden] { display: none; }

/* waiting (gallery ZIP, inc/gallery_download.js): a spinner above the title */
.zp-modal .zp-modal-wait { text-align: center; }
.zp-modal .zp-modal-wait .zp-modal-title,
.zp-modal .zp-modal-wait .zp-modal-text { text-align: center; }
.zp-modal .zp-modal-wait .zp-modal-actions { justify-content: center; }
.zp-modal .zp-modal-spinner
{
    display: block;
    width: 44px;
    height: 44px;
    margin: 4px auto 16px;
    border: 4px solid #e3ebdd;
    border-top-color: #5a8f3c;
    border-radius: 50%;
    animation: zp-modal-spin .8s linear infinite;
}
@keyframes zp-modal-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .zp-modal .zp-modal-spinner { animation-duration: 2.4s; } }

/* buttons: a row at the bottom (.zp-modal-actions) or a stack of choices (.zp-modal-choices) */
.zp-modal .zp-modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.zp-modal .zp-modal-actions[hidden] { display: none; }
.zp-modal .zp-modal-choices { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.zp-modal .zp-modal-choices .zp-modal-btn { width: 100%; height: 44px; }
.zp-modal .zp-modal-btn
{
    height: 38px;
    margin: 0;
    padding: 0 18px;
    border: none;
    border-radius: 8px;
    font: 600 14px helvetica, arial, sans-serif;
    text-transform: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .15s ease;
}
/* a link that looks like a button (Kalendarz: "Kalendarz Google", plik .ics) */
.zp-modal a.zp-modal-btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.zp-modal .zp-modal-btn:focus-visible { outline: 3px solid rgba(90, 143, 60, .35); outline-offset: 1px; }
.zp-modal .zp-modal-btn-cancel { background: #eef0ec; color: #444; }
.zp-modal .zp-modal-btn-cancel:hover { background: #e2e5df; }
.zp-modal .zp-modal-btn-ok { background: #5a8f3c; color: #fff; }
.zp-modal .zp-modal-btn-ok:hover { background: #4b7a31; }
.zp-modal .zp-modal-btn-del { background: #c62828; color: #fff; }
.zp-modal .zp-modal-btn-del:hover { background: #a91f1f; }
.zp-modal .zp-modal-btn:disabled { opacity: .6; cursor: default; }

/* phone: a bit less padding, full-width finger-sized buttons, the main one on top */
@media (max-width: 480px)
{
    .zp-modal { padding: 12px; }
    .zp-modal .zp-modal-box { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); padding: 20px 18px 16px; }
    .zp-modal .zp-modal-title { font-size: 22px; }
    .zp-modal .zp-modal-actions { flex-direction: column-reverse; gap: 8px; }
    .zp-modal .zp-modal-actions .zp-modal-btn { width: 100%; height: 44px; }
}

/* Article editor dialogs (Trumbowyg: link, image…; templates/admin/editor.php) in the same look.
   Trumbowyg sizes .trumbowyg-modal from the box after building it and keeps its buttons absolute,
   so the box keeps room for them at the bottom (padding-bottom). */
.trumbowyg-modal { max-width: 560px; }
.trumbowyg-modal .trumbowyg-modal-box
{
    max-width: 540px;
    width: calc(100% - 24px);
    padding: 0 0 72px;
    border-radius: 0 0 14px 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
    text-align: left;
    font: 14px/1.5 helvetica, arial, sans-serif;
    color: #444;
}
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-modal-title { margin: 0 0 4px; padding: 20px 24px 0; border: none; font: 700 24px/1.2 Dosis, sans-serif; color: #3d6b25; text-align: left; }
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-progress { top: 0; }
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-progress .trumbowyg-progress-bar { background: #5a8f3c; }
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-row { margin: 14px 24px 0; border: none; overflow: visible; }
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-infos { position: static; width: auto; margin: 0 0 6px; padding: 0; border: none; background: none; }
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-infos label,
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-infos label span { height: 20px; line-height: 20px; font-weight: 700; font-size: 13px; color: #555; }
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-infos .trumbowyg-msg-error { color: #b4232f; }
/* on an error Trumbowyg slides the label up to show the message under it */
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-error .trumbowyg-input-infos label span:first-child { margin-top: -20px; }
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-html { padding: 0; }
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-html input,
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-html select,
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-html textarea
{
    height: 42px;
    line-height: normal;
    padding: 0 12px;
    border: 1px solid #d6dbd2;
    border-radius: 8px;
    background: #fff;
    font: 16px helvetica, arial, sans-serif;
    color: #333;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-html textarea { height: auto; min-height: 84px; padding: 8px 12px; }
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-html input[type=checkbox] { width: 18px; height: 18px; padding: 0; accent-color: #5a8f3c; }
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-html-with-checkbox { padding: 0; }
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-html input:hover,
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-html select:hover,
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-html textarea:hover { outline: none; border-color: #b9c4b1; }
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-html input:focus,
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-html select:focus,
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-html textarea:focus { outline: none; border-color: #5a8f3c; box-shadow: 0 0 0 3px rgba(90, 143, 60, .18); background: #fff; }
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-error input,
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-error select,
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-error textarea { outline: none; border-color: #b4232f; }
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-modal-button
{
    bottom: 20px;
    width: 110px;
    height: 38px;
    margin: 0;
    padding: 0 12px;
    border-radius: 8px;
    font: 600 14px/38px helvetica, arial, sans-serif;
}
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-modal-button.trumbowyg-modal-reset { right: 144px; background: #eef0ec; color: #444; }
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-modal-button.trumbowyg-modal-reset:hover,
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-modal-button.trumbowyg-modal-reset:focus { background: #e2e5df; }
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-modal-button.trumbowyg-modal-submit { right: 24px; background: #5a8f3c; color: #fff; }
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-modal-button.trumbowyg-modal-submit:hover,
.trumbowyg-modal .trumbowyg-modal-box .trumbowyg-modal-button.trumbowyg-modal-submit:focus { background: #4b7a31; }
@media (max-width: 480px)
{
    .trumbowyg-modal .trumbowyg-modal-box { padding-bottom: 78px; }
    .trumbowyg-modal .trumbowyg-modal-box .trumbowyg-modal-title { padding: 18px 18px 0; font-size: 22px; }
    .trumbowyg-modal .trumbowyg-modal-box .trumbowyg-input-row { margin: 14px 18px 0; }
    /* two finger-sized buttons sharing the width */
    .trumbowyg-modal .trumbowyg-modal-box .trumbowyg-modal-button { bottom: 18px; width: calc((100% - 46px) / 2); height: 44px; line-height: 44px; }
    .trumbowyg-modal .trumbowyg-modal-box .trumbowyg-modal-button.trumbowyg-modal-reset { right: calc(18px + (100% - 46px) / 2 + 10px); }
    .trumbowyg-modal .trumbowyg-modal-box .trumbowyg-modal-button.trumbowyg-modal-submit { right: 18px; }
}

/* Editors' Anuluj / Zapisz (templates/admin/editor.php, inc/kontakt_editor.js): the dialog buttons
   in a toolbar size, on the right, "ID=…" (admins) just before them */
.zp-edit-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.zp-edit-id { padding: 0 6px; color: #888; font: 12px monospace; white-space: nowrap; }
.zp-edit-btn
{
    height: 30px;
    margin: 0;
    padding: 0 16px;
    border: none;
    border-radius: 6px;
    font: 600 13px helvetica, arial, sans-serif;
    text-transform: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .15s ease;
}
.zp-edit-btn:focus-visible { outline: 3px solid rgba(90, 143, 60, .35); outline-offset: 1px; }
.zp-edit-btn-cancel { background: #eef0ec; color: #444; }
.zp-edit-btn-cancel:hover { background: #e2e5df; }
.zp-edit-btn-save { background: #5a8f3c; color: #fff; }
.zp-edit-btn-save:hover { background: #4b7a31; }
.zp-edit-btn:disabled { opacity: .5; cursor: default; }
