/* ARK Universal Modal - home_sitetask_tree/css/ark-modal.css
   Replaces AppGini modal_window() calls with consistent ARK-style iframe modals.
   z-index: 10500 — sits above all other page modals (covenant/delay/status at 10000). */

/* ─── Overlay ─────────────────────────────────────────────────────────────── */
.ark-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 10500;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.ark-modal-overlay.show {
    display: flex;
}

/* ─── Modal shell ─────────────────────────────────────────────────────────── */
.ark-modal {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.32), 0 2px 8px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
    max-height: calc(100vh - 32px);
    animation: arkModalSlideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes arkModalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ─── Size variants ───────────────────────────────────────────────────────── */
.ark-modal.ark-modal-sm {
    max-width: 500px;
    max-height: min(65vh, calc(100vh - 32px));
}

.ark-modal.ark-modal-md {
    max-width: 720px;
    max-height: min(78vh, calc(100vh - 32px));
}

.ark-modal.ark-modal-lg {
    max-width: 980px;
    max-height: min(88vh, calc(100vh - 32px));
}

.ark-modal.ark-modal-full {
    max-width: 96vw;
    width: 96vw;
    max-height: calc(100vh - 32px);
    height: calc(100vh - 32px);
}

/* ─── Header ──────────────────────────────────────────────────────────────── */
.ark-modal-header {
    background: #01273e;
    color: #fff;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.ark-modal-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
}

.ark-modal-title i {
    opacity: 0.8;
    font-size: 13px;
    flex-shrink: 0;
}

.ark-modal-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Open-in-new-tab button */
.ark-modal-newtab-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 2px 5px;
    font-size: 12px;
    line-height: 1;
    border-radius: 2px;
    transition: color 0.15s, background 0.15s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.ark-modal-newtab-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* Close button */
.ark-modal-close-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    transition: color 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 2px;
}

.ark-modal-close-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* ─── Body ────────────────────────────────────────────────────────────────── */
.ark-modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
}

/* ─── Loading state ───────────────────────────────────────────────────────── */
.ark-modal-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #fff;
    z-index: 2;
    color: #6c757d;
    font-size: 13px;
}

.ark-modal-loading i {
    font-size: 28px;
    color: #01273e;
    opacity: 0.6;
}

.ark-modal-loading.hidden {
    display: none;
}

/* ─── Iframe ──────────────────────────────────────────────────────────────── */
.ark-modal-iframe {
    width: 100%;
    flex: 1;
    border: none;
    display: block;
    background: #fff;
    /* For sm/md/lg sizes where the shell isn't 100vh, the iframe fills the body */
    min-height: 200px;
}

/* For full-size modals, fill the entire body */
.ark-modal.ark-modal-full .ark-modal-body {
    height: 0; /* flex child trick — lets iframe fill remaining space */
}

.ark-modal.ark-modal-full .ark-modal-iframe {
    height: 100%;
}

/* For constrained sizes, give the iframe a sensible height */
.ark-modal.ark-modal-sm .ark-modal-iframe {
    height: 400px;
}

.ark-modal.ark-modal-md .ark-modal-iframe {
    height: 560px;
}

.ark-modal.ark-modal-lg .ark-modal-iframe {
    height: 700px;
}

/* ─── Error state ─────────────────────────────────────────────────────────── */
.ark-modal-error {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px;
    color: #721c24;
    background: #fff;
    text-align: center;
    font-size: 13px;
}

.ark-modal-error.show {
    display: flex;
}

.ark-modal-error i {
    font-size: 32px;
    color: #dc3545;
    opacity: 0.7;
}

/* ─── Mobile adjustments ──────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .ark-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .ark-modal {
        border-radius: 8px 8px 0 0;
        max-width: 100%;
        width: 100%;
        max-height: 92vh;
        animation: arkModalSlideUp 0.22s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    }

    .ark-modal.ark-modal-full {
        height: 92vh;
        max-height: 92vh;
    }

    @keyframes arkModalSlideUp {
        from { transform: translateY(30px); opacity: 0; }
        to   { transform: translateY(0);    opacity: 1; }
    }
}
