/* =================================================================
   components/app-dialog.css — .app-dialog component
   -----------------------------------------------------------------
   Modal dialog with backdrop, header, body, and footer zones.
   Size axis: sm | md (default) | lg | xl | full.

   Usage:
     <div class="app-dialog-root">
       <div class="app-dialog__backdrop app-dialog__backdrop--open">
         <div class="app-dialog app-dialog--md" role="dialog" aria-modal="true" aria-labelledby="dialog-title">
           <div class="app-dialog__header">
             <h2 class="app-dialog__title" id="dialog-title">Title</h2>
             <button class="app-btn app-btn--secondary app-btn--ghost app-btn--icon-only app-btn--md app-dialog__close" aria-label="Close">
               <span class="sym">close</span>
             </button>
           </div>
           <div class="app-dialog__body"> ... </div>
           <div class="app-dialog__footer"> ... </div>
         </div>
       </div>
     </div>
   ================================================================= */

/* ========== 1. ROOT CONTAINER ========== */

.app-dialog-root {
    position: fixed;
    inset: 0;
    z-index: 999;
    pointer-events: none;
}

.app-dialog-root:has(.app-dialog__backdrop--open) {
    pointer-events: auto;
}

/* ========== 2. BACKDROP ========== */

.app-dialog__backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    align-items: center;
    justify-content: center;
    padding: var(--spacing-3xl);
    box-sizing: border-box;
	z-index: 999;
}

.app-dialog__backdrop--open {
    display: flex;
    animation: app-dialog-backdrop-in var(--transition-base) both;
}

@keyframes app-dialog-backdrop-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ========== 3. DIALOG PANEL ========== */

.app-dialog {
    display: flex;
    flex-direction: column;
    width: var(--dialog-w);
    min-width: 400px;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    overflow: hidden;
    /* backwards, not both: a lingering transform would make the dialog clip fixed Briox.Select lists. */
    animation: app-dialog-in var(--transition-base) backwards;
}

@keyframes app-dialog-in {
    from { opacity: 0; transform: translateY(-12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* ========== 4. SIZE VARIANTS ========== */

.app-dialog--sm  { --dialog-w: 400px; }
.app-dialog--md  { --dialog-w: 560px; }
.app-dialog--lg  { --dialog-w: 760px; }
.app-dialog--xl  { --dialog-w: 1000px; }

.app-dialog--full {
    --dialog-w: 100%;
    --dialog-max-h: 100vh;
    max-width: calc(100vw - var(--spacing-3xl) * 2);
    max-height: calc(100vh - var(--spacing-3xl) * 2);
    border-radius: var(--radius-lg);
}

/* ========== 5. HEADER ========== */

.app-dialog__header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-secondary);
    flex-shrink: 0;
}

.app-dialog__title {
    flex: 1;
    margin: 0;
    font-family: var(--font-family-primary);
    font-size: var(--font-body-lg-size);
    font-weight: var(--font-weight-semibold);
    line-height: var(--font-body-lg-line-height);
    color: var(--text-primary);
}

.app-dialog__close {
    flex-shrink: 0;
    margin-left: auto;
}

/* Buttons a Modalbox body hands to its header (modalbox.js moves the group in), between the title and the close button */
.app-dialog__header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-shrink: 0;
}

/* ========== 6. BODY ========== */

.app-dialog__body {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-lg);
    font-size: var(--font-body-md-size);
    line-height: var(--font-body-md-line-height);
    color: var(--text-primary);
}

.app-dialog__body p{
	max-width: 600px;
}

/* Opt-in for short dialogs whose dropdown lists must extend past the body instead of being clipped.
   Never on a body that can outgrow the dialog's height cap: it would spill over the page, unscrollable. */
.app-dialog:has(> .app-dialog__body--overflow-visible),
.app-dialog__body--overflow-visible {
    overflow: visible;
}

/* ========== 7. FOOTER ========== */

.app-dialog__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--spacing-md);
    padding: var(--spacing-lg) ;
    border-top: 1px solid var(--border-secondary);
    flex-shrink: 0;
}

.app-dialog__footer--start {
    justify-content: flex-start;
}

.app-dialog__footer--between {
    justify-content: space-between;
}

/* Three buttons: the first (e.g. Delete) stays left and the rest group on the right. */
.app-dialog__footer--between > :first-child {
    margin-right: auto;
}

/* ========== 8. RESPONSIVE FULL-SCREEN ========== */
/* Add .app-dialog--responsive-full to make any dialog fill the
   viewport on tablet and mobile (no border-radius, edge-to-edge). */

@media (max-width: 1024px) {
    .app-dialog--responsive-full {
        --dialog-w: 100%;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    .app-dialog__backdrop:has(.app-dialog--responsive-full) {
        padding: 0;
    }
}

/* ========== 9. REDUCED MOTION ========== */

@media (prefers-reduced-motion: reduce) {
    .app-dialog__backdrop--open,
    .app-dialog {
        animation: none;
    }
}

/* ========== EMBEDDED PAGE ==========
   An iframe inside a dialog body (the salary specification PDF). */

/* The frame carries the size: a percentage would collapse, since the popup shrinks to its content */
.app-dialog__frame {
    display: block;
    width: min(1100px, 88vw);
    height: min(760px, 78vh);
    border: 0;
}
