/* =========================================================
   CDFK Read-Only Portal Ribbon + Read-Only UI overrides
   ========================================================= */

/* ---- Ribbon ---- */
.cdfk-readonly-ribbon {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    background-color: #9d7e2e;
    background-image: linear-gradient(90deg, #8a6c20 0%, #9d7e2e 50%, #b8943a 100%);
    color: #ffffff;
    text-align: center;
    padding: 10px 18px;
    font-size: 14px;
    line-height: 1.4;
    font-weight: 600;
    letter-spacing: 0.2px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    border-bottom: 2px solid #6f5618;
    font-family: "Open Sans", Arial, sans-serif;
}

.cdfk-readonly-ribbon .cdfk-readonly-ribbon-icon {
    margin-right: 8px;
}

.cdfk-readonly-ribbon .cdfk-readonly-ribbon-text {
    display: inline-block;
    max-width: 1100px;
    vertical-align: middle;
}

/* Push the rest of the site below the fixed ribbon. */
body {
    padding-top: 56px !important;
}

/* Make sure the fixed-position sidebar and navbar do not slip under the ribbon. */
body.fixed-sidebar .navbar-static-side,
body.canvas-menu .navbar-static-side,
.navbar-fixed-top,
.navbar-static-top {
    top: 56px !important;
}

/* Responsive tweaks */
@media (max-width: 992px) {
    .cdfk-readonly-ribbon {
        font-size: 13px;
        padding: 9px 14px;
    }
    body {
        padding-top: 72px !important;
    }
    body.fixed-sidebar .navbar-static-side,
    body.canvas-menu .navbar-static-side,
    .navbar-fixed-top,
    .navbar-static-top {
        top: 72px !important;
    }
}

@media (max-width: 600px) {
    .cdfk-readonly-ribbon {
        font-size: 12px;
        padding: 8px 12px;
        line-height: 1.35;
    }
    .cdfk-readonly-ribbon .cdfk-readonly-ribbon-icon {
        display: block;
        margin: 0 0 4px 0;
        font-size: 16px;
    }
    body {
        padding-top: 110px !important;
    }
    body.fixed-sidebar .navbar-static-side,
    body.canvas-menu .navbar-static-side,
    .navbar-fixed-top,
    .navbar-static-top {
        top: 110px !important;
    }
}

/* =========================================================
   Site-wide Read-Only mode
   - Login form stays usable (excluded via :not selectors).
   - Once authenticated, body gets .cdfk-readonly-mode and
     all data-entry / action controls become non-interactive.
   ========================================================= */

.cdfk-readonly-mode input:not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="checkbox"]):not([type="radio"]),
.cdfk-readonly-mode textarea,
.cdfk-readonly-mode select,
.cdfk-readonly-mode [contenteditable="true"] {
    pointer-events: none !important;
    background-color: #f5f5f5 !important;
    cursor: not-allowed !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

/* Visually disable file inputs and drop zones */
.cdfk-readonly-mode input[type="file"],
.cdfk-readonly-mode .nv-file-over,
.cdfk-readonly-mode [nv-file-drop],
.cdfk-readonly-mode [nv-file-select],
.cdfk-readonly-mode [ngf-drop],
.cdfk-readonly-mode [ngf-select] {
    pointer-events: none !important;
    opacity: 0.55 !important;
    cursor: not-allowed !important;
}

/* Disable checkboxes / radios used for bulk-actions */
.cdfk-readonly-mode input[type="checkbox"],
.cdfk-readonly-mode input[type="radio"] {
    pointer-events: none !important;
    opacity: 0.55 !important;
    cursor: not-allowed !important;
}

/* Disable every <button> and any anchor/element styled as a button,
   EXCEPT items explicitly allow-listed for navigation / logout / dropdowns. */
.cdfk-readonly-mode button:not(.cdfk-allow):not([uib-dropdown-toggle]):not([data-toggle]):not(.close):not(.navbar-toggle),
.cdfk-readonly-mode .btn:not(.cdfk-allow):not([uib-dropdown-toggle]):not([data-toggle]):not(.close) {
    pointer-events: none !important;
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    filter: grayscale(35%);
}

/* Hide ui-grid row-edit selection checkboxes (they trigger bulk actions) */
.cdfk-readonly-mode .ui-grid-selection-row-header-buttons,
.cdfk-readonly-mode .ui-grid-icon-ok {
    pointer-events: none !important;
    opacity: 0.45 !important;
}

/* Disable form submission visual cues */
.cdfk-readonly-mode form {
    position: relative;
}

/* Keep ui-router navigation links fully clickable */
.cdfk-readonly-mode a[ui-sref],
.cdfk-readonly-mode a[ng-click*="logOut"],
.cdfk-readonly-mode a[ng-click*="logout"],
.cdfk-readonly-mode a[uib-dropdown-toggle],
.cdfk-readonly-mode .navbar a,
.cdfk-readonly-mode #side-menu a {
    pointer-events: auto !important;
    opacity: 1 !important;
    cursor: pointer !important;
    filter: none !important;
}

/* =========================================================
   Full-page read-only override
   - Applied to entire ViewFiles and Notifications pages.
   - Defense in depth:
     1. Transparent overlay div catches ALL mouse events
        (bulletproof against AngularJS / uib-tab click handlers).
     2. pointer-events:none on every descendant as backup.
     3. Visual dimming so users see the page is inactive.
   - Navbar/sidebar remain clickable because they live
     outside the ui-view.
   ========================================================= */
.cdfk-page-disabled {
    position: relative;
}

.cdfk-page-disabled-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: transparent;
    cursor: not-allowed;
    pointer-events: auto !important;
}

.cdfk-page-disabled > *:not(.cdfk-page-disabled-overlay),
.cdfk-page-disabled > *:not(.cdfk-page-disabled-overlay) * {
    pointer-events: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

.cdfk-page-disabled input,
.cdfk-page-disabled textarea,
.cdfk-page-disabled select {
    background-color: #f5f5f5 !important;
    opacity: 0.7 !important;
}

.cdfk-page-disabled button,
.cdfk-page-disabled .btn,
.cdfk-page-disabled a {
    opacity: 0.55 !important;
    filter: grayscale(40%) !important;
    cursor: not-allowed !important;
}

/* =========================================================
   Explicit escape hatch — always wins.
   Logout was observed disabled during testing even though the sitewide rules
   above already target a[ng-click*="logOut"] / .navbar a. Rather than rely on
   selector-matching alone, controls that MUST stay interactive (Logout) now
   also carry class="cdfk-allow" directly in the markup, and this rule is kept
   LAST in the file with a selector specific enough to beat every disabling
   rule above it (including the .cdfk-page-disabled descendant rules), so it
   wins regardless of ancestor context.
   ========================================================= */
.cdfk-readonly-mode .cdfk-allow,
.cdfk-readonly-mode .cdfk-allow *,
.cdfk-page-disabled .cdfk-allow,
.cdfk-page-disabled .cdfk-allow * {
    pointer-events: auto !important;
    opacity: 1 !important;
    cursor: pointer !important;
    filter: none !important;
}
