﻿/* =====================================================================
   Admin Modal Variant: simple-exemption (FULL FILE) — FLAT / VALID CSS
   ---------------------------------------------------------------------
   Goals:
     - Fullscreen / kiosk-friendly modal
     - Big, readable typography + controls
     - Keep Bootstrap close (X) behaviour (top-right), but improve contrast
     - Centre the title without interfering with X
     - Show logged-in username (from TS) top-left in the header
     - Fix field row layout so labels don't collide/overflow
     - Keep action row stable + make Add fill the available row
     - Avoid :has() so BuildBundlerMinifier doesn't choke
   ---------------------------------------------------------------------
   Requirements:
     1) #adminModalChildContent must have class: "admin-modal--simple-exemption"
     2) After injecting modal HTML, TS adds class "field-row-2col" to each
        normal field row (.row.mb-1) that contains BOTH:
           > .col-md-2 AND > .col-md-10
        Do NOT add it to the final action row (buttons).
     3) TS sets:
          #adminModalChildContent.style.setProperty("--modal-username", "\"user@x.com\"")
        (quotes included) and optionally data-modal-user for debugging.
   ===================================================================== */


/* =====================================================================
   0) GLOBAL SCOPING FOR THIS VARIANT ONLY
   ===================================================================== */

#adminModalChildContent.admin-modal--simple-exemption,
#adminModalChildContent.admin-modal--simple-exemption * {
    box-sizing: border-box;
}

#adminModalChildContent.admin-modal--simple-exemption {
    /* Theme tokens */
    --m-bg: #0b1424;
    --m-surface: #0f1a2e;
    --m-text: #ffffff;
    --m-muted: rgba(255,255,255,.88);
    --m-border: rgba(255,255,255,.14);
    --m-primary: #0d7bff;
    --m-primary-hover: #0b6de0;
    /* Sizing */
    --m-title: 54px;
    --m-label: 32px;
    --m-font: 32px;
    --m-help: 26px; /* slightly smaller than controls */
    --m-control-h: 76px;
    color: var(--m-text);
    background: var(--m-surface) !important;
}


/* =====================================================================
   1) KIOSK / FULL-VIEWPORT (VISUAL ONLY)
   - Makes the Bootstrap modal fill the viewport
   - No Fullscreen API here; just CSS layout
   ===================================================================== */

#adminModal {
    padding-right: 0 !important; /* Bootstrap adds padding for scrollbar; remove */
}

    /* The modal-dialog wrapper (parent of #adminModalChildContent) */
    #adminModal #adminModalContainer.modal-dialog {
        max-width: 100vw !important;
        width: 100vw !important;
        height: 100vh !important;
        margin: 0 !important;
    }

    /* Make the modal content fill height; remove rounding for kiosk */
    #adminModal #adminModalChildContent.modal-content.admin-modal--simple-exemption {
        height: 100vh !important;
        border-radius: 0 !important;
    }


/* =====================================================================
   2) MODAL SHELL (BACKGROUND + BORDER)
   ===================================================================== */

#adminModalContainer.modal-dialog,
#adminModalChildContent.admin-modal--simple-exemption.modal-content,
#adminModalChildContent.admin-modal--simple-exemption {
    background: var(--m-surface) !important;
    color: var(--m-text) !important;
}

    #adminModalChildContent.admin-modal--simple-exemption.modal-content {
        border: 1px solid var(--m-border) !important;
        box-shadow: 0 14px 40px rgba(0,0,0,.45) !important;
        overflow: hidden !important;
    }


    /* =====================================================================
   3) HEADER
   - Sticky header
   - Title centred WITHOUT affecting the close (X)
   - Username (from TS CSS var) top-left
   - Improve X contrast (white, not faded)
   - IMPORTANT: we do not reposition the close button; Bootstrap keeps it
   ===================================================================== */

    #adminModalChildContent.admin-modal--simple-exemption #AdminEditModalHeader {
        position: sticky !important;
        top: 0 !important;
        z-index: 50 !important;
        background: linear-gradient(180deg, var(--m-surface) 0%, var(--m-bg) 100%) !important;
        border-bottom: 1px solid var(--m-border) !important;
        /* Give the header real height so absolute title doesn't overlap body */
        min-height: 160px !important;
        /* Padding tuned for username + big title + close button */
        padding: 52px 28px 28px 28px !important;
        /* Anchor ::before + absolute title */
        position: relative !important;
    }

        /* Username rendered from TS: --modal-username: "Gary.Bell@apcoa.com" */
        #adminModalChildContent.admin-modal--simple-exemption #AdminEditModalHeader::before {
            content: var(--modal-username, "");
            position: absolute;
            left: 28px; /* align with header horizontal padding */
            top: 16px; /* sit above title */

            font-size: 18px;
            font-weight: 700;
            color: rgba(255,255,255,.9);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 40%;
            pointer-events: none; /* never blocks clicks */
        }

        /* Title: centred, big, doesn't block X */
        #adminModalChildContent.admin-modal--simple-exemption #AdminEditModalHeader .modal-title {
            position: absolute !important;
            left: 50% !important;
            top: 50% !important;
            transform: translate(-50%, -50%) !important;
            margin: 0 !important;
            text-align: center !important;
            font-size: var(--m-title) !important;
            font-weight: 900 !important;
            line-height: 1.05 !important;
            letter-spacing: .4px !important;
            color: var(--m-text) !important;
            pointer-events: none !important; /* prevents blocking the X */
        }

        /* Close (X): keep Bootstrap positioning, just improve contrast */
        #adminModalChildContent.admin-modal--simple-exemption #AdminEditModalHeader .close {
            opacity: 1 !important;
            color: #ffffff !important;
            text-shadow: none !important;
        }

            #adminModalChildContent.admin-modal--simple-exemption #AdminEditModalHeader .close span {
                color: #ffffff !important;
            }


    /* =====================================================================
   4) BODY / SCROLL REGION
   - Body scrolls, not the whole page
   ===================================================================== */

    #adminModalChildContent.admin-modal--simple-exemption .AdminEditModalFormWrapper.modal-body {
        background: var(--m-surface) !important;
        padding: 34px 30px !important;
        /* Header height is now ~160px; give remaining height to form */
        max-height: calc(100vh - 170px) !important;
        overflow-y: auto !important;
    }


    /* =====================================================================
   5) ROW BASELINE STYLING
   ===================================================================== */

    #adminModalChildContent.admin-modal--simple-exemption .row.mb-1 {
        padding: 22px 0 !important;
        border-bottom: 1px solid rgba(255,255,255,.06) !important;
        align-items: flex-start !important;
    }


/* =====================================================================
   6) FIELD ROW LAYOUT (NO BOOTSTRAP BREAKAGE)
   - Only applies to rows TS marks as .field-row-2col
   - Uses CSS grid to create a stable label column + flexible control column
   - Fixes label/control overlap and "ExemptionNone" collision
   ===================================================================== */

@media (min-width: 768px) {
    /* Turn the field row into a 2-col grid */
    #adminModalChildContent.admin-modal--simple-exemption .row.mb-1.field-row-2col {
        display: grid !important;
        grid-template-columns: 280px 1fr !important; /* label width, then input */
        column-gap: 24px !important;
        align-items: start !important;
    }

        /* Remove bootstrap column width constraints INSIDE these grid rows */
        #adminModalChildContent.admin-modal--simple-exemption .row.mb-1.field-row-2col > .col-md-2,
        #adminModalChildContent.admin-modal--simple-exemption .row.mb-1.field-row-2col > .col-md-10 {
            max-width: none !important;
            width: auto !important;
            padding-left: 0 !important;
            padding-right: 0 !important;
            min-width: 0 !important; /* critical: allow shrink to avoid overlap */
        }
}

/* Label alignment: your markup uses d-flex + align-items-center + h-100; override */
#adminModalChildContent.admin-modal--simple-exemption .row.mb-1 > .col-md-2 label {
    height: auto !important;
    align-items: flex-start !important;
    padding-top: 12px !important;
}

    #adminModalChildContent.admin-modal--simple-exemption .row.mb-1 > .col-md-2 label.d-flex {
        align-items: flex-start !important;
    }

/* Labels: big + bold, and WRAP to avoid spilling into the control column */
#adminModalChildContent.admin-modal--simple-exemption label,
#adminModalChildContent.admin-modal--simple-exemption label strong {
    font-size: var(--m-label) !important;
    font-weight: 900 !important;
    color: var(--m-muted) !important;
    display: block !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    line-height: 1.1 !important;
}


/* =====================================================================
   7) CONTROLS (INPUTS / SELECTS)
   ===================================================================== */

#adminModalChildContent.admin-modal--simple-exemption .form-control,
#adminModalChildContent.admin-modal--simple-exemption .form-select,
#adminModalChildContent.admin-modal--simple-exemption input[type="text"],
#adminModalChildContent.admin-modal--simple-exemption select {
    min-height: var(--m-control-h) !important;
    font-size: var(--m-font) !important;
    padding: 16px 22px !important;
    border-radius: 18px !important;
    background: rgba(255,255,255,.06) !important;
    color: var(--m-text) !important;
    border: 1px solid var(--m-border) !important;
}

    #adminModalChildContent.admin-modal--simple-exemption .form-control:focus,
    #adminModalChildContent.admin-modal--simple-exemption .form-select:focus {
        outline: none !important;
        border-color: var(--m-primary) !important;
        box-shadow: 0 0 0 6px rgba(13,123,255,.25) !important;
    }

/* Validation text: slightly smaller, clearly separated */
#adminModalChildContent.admin-modal--simple-exemption .text-danger,
#adminModalChildContent.admin-modal--simple-exemption .field-validation-error {
    font-size: var(--m-help) !important;
    margin-top: 10px !important;
    color: #ff6b6b !important;
}


/* =====================================================================
   8) SELECT + OPTION VISUAL IMPROVEMENTS (CSS-ONLY LIMIT)
   ===================================================================== */

#adminModalChildContent.admin-modal--simple-exemption select {
    appearance: none !important;
    padding-right: 76px !important;
    background-color: rgba(255,255,255,.06) !important;
    color: #ffffff !important;
    font-size: var(--m-font) !important;
    font-weight: 700 !important;
    background-image: linear-gradient(45deg, transparent 50%, rgba(255,255,255,.9) 50%), linear-gradient(135deg, rgba(255,255,255,.9) 50%, transparent 50%);
    background-position: calc(100% - 38px) 50%, calc(100% - 28px) 50%;
    background-size: 12px 12px, 12px 12px;
    background-repeat: no-repeat;
    /* Scrollbar — Firefox */
    scrollbar-width: thin;
    scrollbar-color: #0d7bff #0f1a2e;
}

    #adminModalChildContent.admin-modal--simple-exemption select option {
        background-color: #0f1a2e !important;
        color: #ffffff !important;
        font-size: 28px !important;
        padding: 12px 16px !important;
    }

        #adminModalChildContent.admin-modal--simple-exemption select option:checked,
        #adminModalChildContent.admin-modal--simple-exemption select option:hover {
            background-color: #0d7bff !important;
            color: #ffffff !important;
        }

    /* Scrollbar — WebKit */
    #adminModalChildContent.admin-modal--simple-exemption select::-webkit-scrollbar {
        width: 10px;
    }

    #adminModalChildContent.admin-modal--simple-exemption select::-webkit-scrollbar-track {
        background: #0f1a2e;
    }

    #adminModalChildContent.admin-modal--simple-exemption select::-webkit-scrollbar-thumb {
        background-color: #0d7bff;
        border-radius: 10px;
        border: 2px solid #0f1a2e;
    }


/* =====================================================================
   9) ACTION ROW (ADD BUTTON)
   ---------------------------------------------------------------------
   Key change vs previous version:
     - Remove reliance on :last-of-type
     - Match the working console fix:
         * force ALL direct .row.mb-1 children columns (.col-sm-3) to 100%
           (field rows use .col-md-* so they’re unaffected)
         * hide the offset-sm-3 Close column
         * make #btnSubmit fill width
   ===================================================================== */

/* 9.1 Hide the bottom Close button (NOT the header X) */
#adminModalChildContent.admin-modal--simple-exemption #AdminEditFormModal button.btn-default,
#adminModalChildContent.admin-modal--simple-exemption #AdminEditFormModal button[data-dismiss="modal"],
#adminModalChildContent.admin-modal--simple-exemption #AdminEditFormModal button[data-bs-dismiss="modal"] {
    display: none !important;
}

/* 9.2 Hide its column (offset-sm-3 column that held Close) */
#adminModalChildContent.admin-modal--simple-exemption
#AdminEditFormModal > .row.mb-1 > .col-sm-3.offset-sm-3 {
    display: none !important;
}

/* 9.3 Force ONLY the direct action-row columns (.col-sm-3) to full width
       - Field rows are .col-md-2/.col-md-10 and do not match this selector
       - This mirrors the working injection fix exactly */
#adminModalChildContent.admin-modal--simple-exemption
#AdminEditFormModal > .row.mb-1 > .col-sm-3 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin: 0 !important;
}

/* 9.4 Clean up the direct action rows so they sit flush */
#adminModalChildContent.admin-modal--simple-exemption
#AdminEditFormModal > .row.mb-1 {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* 9.5 Add/Submit button: fill the available row */
#adminModalChildContent.admin-modal--simple-exemption #btnSubmit {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    min-height: 96px !important;
    font-size: var(--m-font) !important;
    font-weight: 900 !important;
    border-radius: 18px !important;
    background: var(--m-primary) !important;
    border: 1px solid var(--m-primary) !important;
    color: #fff !important;
}

    #adminModalChildContent.admin-modal--simple-exemption #btnSubmit:hover {
        background: var(--m-primary-hover) !important;
        border-color: var(--m-primary-hover) !important;
    }


/* =====================================================================
   10) MOBILE TWEAKS
   ===================================================================== */

@media (max-width: 768px) {
    /* Let the header breathe on smaller screens */
    #adminModalChildContent.admin-modal--simple-exemption #AdminEditModalHeader {
        min-height: 170px !important;
        padding-top: 54px !important;
    }

        /* Username can take more width on mobile */
        #adminModalChildContent.admin-modal--simple-exemption #AdminEditModalHeader::before {
            max-width: 60%;
        }
}
