/* ModalComponent.css */

:root {
    /* the theme's colours (css/app-theme.css:root, Light and Soft blocks) */
    --modal-bg: var(--vd-surface);
    --modal-text: var(--vd-text);
    --modal-border: var(--vd-border);
    --modal-shadow: 0 12px 40px rgba(0,0,0,0.22);
    --modal-radius: 12px;
    --modal-header-bg: var(--vd-surface-2);
    --modal-footer-bg: var(--vd-surface-2);
    --modal-status-icon-size: 18px;
    --modal-icon-success: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.2l-3.5-3.5-1.4 1.4L9 19 20.3 7.7l-1.4-1.4z'/%3E%3C/svg%3E");
    --modal-icon-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 10h2v7h-2zm0-4h2v2h-2z'/%3E%3Cpath d='M12 2a10 10 0 100 20 10 10 0 000-20zm0 18a8 8 0 110-16 8 8 0 010 16z'/%3E%3C/svg%3E");
    --modal-icon-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z'/%3E%3C/svg%3E");
    --modal-icon-danger: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 100 20 10 10 0 000-20zm4.3 13.9l-1.4 1.4L12 13.4l-2.9 2.9-1.4-1.4 2.9-2.9-2.9-2.9 1.4-1.4 2.9 2.9 2.9-2.9 1.4 1.4-2.9 2.9 2.9 2.9z'/%3E%3C/svg%3E");
}

.modal-container {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
}

.modal-container.is-hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.modal-overlay.is-hidden {
    display: none;
}

.modal-shell {
    position: relative;
    width: 100%;
    max-width: 560px;
    margin: 0 16px;
    z-index: 1;
}

.modal-sm { max-width: 360px; }
.modal-md { max-width: 560px; }
.modal-lg { max-width: 820px; }
.modal-xl { max-width: 1100px; }
.modal-full {
    max-width: none;
    width: calc(100% - 32px);
    height: calc(100% - 32px);
}

.modal-content {
    background: var(--modal-bg);
    color: var(--modal-text);
    border-radius: var(--modal-radius);
    box-shadow: var(--modal-shadow);
    border: 1px solid var(--modal-border);
    overflow: hidden;
    position: relative;
}

.modal-content.no-header .modal-body {
    padding-top: 24px;
}

.modal-header,
.modal-footer {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header {
    background: var(--modal-header-bg);
    justify-content: space-between;
}

/* Title and close: as light as the page section headers */
.modal-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.modal-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.modal-close:hover { background: var(--hover); color: var(--text); }
.modal-close:focus { outline: none; }
/* The dialog focuses × when it opens: show keyboard focus as a soft background, not a frame */
.modal-close:focus-visible { outline: none; background: var(--hover); color: var(--text); }

.modal-close.modal-close-floating {
    position: absolute;
    top: 10px;
    right: 12px;
}

.modal-body {
    padding: 16px;
    max-height: 70vh;
    overflow: auto;
}

.modal-body-content {
    display: block;
}

.modal-footer {
    background: var(--modal-footer-bg);
    justify-content: flex-end;
}

.modal-footer.align-start { justify-content: flex-start; }
.modal-footer.align-center { justify-content: center; }
.modal-footer.align-end { justify-content: flex-end; }

.modal-footer.is-hidden {
    display: none;
}

/* Buttons: the page buttons (.ts-btn). modal-btn = the main action (blue),
   modal-btn-secondary = Cancel / Close (grey), modal-btn-danger = destructive (red) */
.modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid var(--primary);
    background: var(--primary);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.4;
    font-family: inherit;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, filter 0.15s;
}

.modal-btn:hover { filter: brightness(1.1); }
.modal-btn:focus { outline: none; }
.modal-btn:focus-visible { outline: 2px solid var(--vd-accent); outline-offset: 2px; }
.modal-btn:disabled { background: var(--button-disabled-bg); color: var(--button-disabled-text); border-color: var(--border-color); box-shadow: none; cursor: not-allowed; filter: none; }

.modal-btn.secondary,
.modal-btn.modal-btn-secondary {
    background: var(--button-bg);
    border-color: var(--border-color);
    color: var(--text);
}

.modal-btn.secondary:hover,
.modal-btn.modal-btn-secondary:hover { background: var(--hover); filter: none; }

.modal-btn.modal-btn-danger {
    background: var(--alert);
    border-color: var(--alert);
    color: var(--text);
}

/* Status icon: a small icon in a tinted circle beside the message (not a big icon above it) */
.modal-body:has(> .modal-status) {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.modal-body:has(> .modal-status) > .modal-body-content {
    flex: 1;
    min-width: 0;
    padding-top: 6px;
}

.modal-body-content > p:last-child { margin-bottom: 0; }

.modal-status {
    --modal-status-icon-size: 18px;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    color: var(--text-muted);
    background: var(--sec-soft);
}

.modal-status svg {
    width: var(--modal-status-icon-size);
    height: var(--modal-status-icon-size);
    display: block;
    fill: currentColor;
}

.modal-status > .bi {
    display: block;
    font-size: var(--modal-status-icon-size);
    line-height: 1;
}
.modal-status > .bi::before { display: block; vertical-align: 0; }

.modal-status.status-success { color: var(--success); }
.modal-status.status-info { color: var(--primary); }
.modal-status.status-alert { color: var(--warning); }
.modal-status.status-danger { color: var(--alert); }

.anim-fade { opacity: 1; transition: opacity 0.2s ease; }
.anim-fade.is-entering { opacity: 0; }
.anim-fade.is-leaving { opacity: 0; }

.anim-slide { transform: translateY(0); transition: transform 0.2s ease, opacity 0.2s ease; opacity: 1; }
.anim-slide.is-entering { transform: translateY(20px); opacity: 0; }
.anim-slide.is-leaving { transform: translateY(20px); opacity: 0; }

.anim-zoom { transform: scale(1); transition: transform 0.2s ease, opacity 0.2s ease; opacity: 1; }
.anim-zoom.is-entering { transform: scale(0.95); opacity: 0; }
.anim-zoom.is-leaving { transform: scale(0.95); opacity: 0; }

@media (max-width: 600px) {
    .modal-shell {
        max-width: 100%;
        margin: 0 8px;
    }
    .modal-body {
        max-height: 60vh;
    }
}
