/*
 * GNH GravityView front-end display styling.
 * Added 2026-08-09, same night as the Astra mobile-header fixes: Teffany
 * found the "View/Edit My Availability" and "Team Availability" pages
 * (both GravityView List View layouts, one entry per staff member) render
 * badly on mobile - the whole list barely uses half the screen width, and
 * the "Update" edit-entry link overlapped the entry's own heading text.
 *
 * WIDENED 2026-08-09 to cover both confirmed pages: My/Edit Availability
 * (.gv-container-6463) and Team Availability (.gv-container-6656, ID
 * confirmed via live Inspect Element earlier this session). Uses the
 * :is() selector so both containers share one rule set instead of
 * duplicating every line. Still deliberately NOT widened to Case Notes,
 * Housing, ISRS, or Temp Lodging - those pages/Views haven't been
 * inspected yet, and per Teffany's own concern, may have different field
 * layouts (more fields, an actual photo, different custom content) that
 * this styling wasn't built around. Audit those individually before
 * adding their container IDs to the :is() list below.
 *
 * Does NOT touch the separate [gnh_scheduler_dashboard] front-end
 * scheduler page - that's built entirely differently (PHP-rendered
 * tables + scheduler.css, no GravityView involved), so none of these
 * selectors can match anything there either way.
 *
 * REWRITTEN once already (as part of 1.7.24) after the first version
 * (1.7.23) loaded correctly but did nothing visually. Real root cause,
 * found by Teffany live-inspecting the actual DOM tree rather than
 * guessing further:
 * 1. The original version hid `.gv-list-view-content-image`, assuming it
 *    was an empty, unused profile-photo column. It's actually GravityView's
 *    real content wrapper for this template - the Update link and the
 *    day/hours table are nested INSIDE it. Hiding it would have blanked
 *    the whole entry; it only didn't because a separate, MORE SPECIFIC
 *    rule in this same file (the `[class*="gv-grid-col-"]` rule) was
 *    fighting it and winning, which is also why the width fixes weren't
 *    landing cleanly - the two rules were canceling each other out.
 * 2. The actual day/hours table has its own specific class,
 *    `.gnh-avail-table` (built directly in GravityView's View editor as
 *    a Custom Content field - not part of this plugin's code, confirmed
 *    via a full codebase search), with a `<colgroup>` that can pin exact
 *    column widths. The original CSS only targeted the generic `table`
 *    tag, which has far lower specificity than a real class name and a
 *    colgroup's own width control - so it never had a chance of winning.
 *
 * Written without being able to preview it live (per the standing rule:
 * no browser automation on the GNH portal, ever - Teffany does all the
 * clicking). Send a screenshot after deploying and I'll true up anything
 * that doesn't look right.
 */

/* ---------------------------------------------------------------------
   Force every grid column (the one GravityView labels "content-image"
   is actually the real content wrapper on this template, not an unused
   photo slot - do not hide it) to stack full-width instead of relying on
   GravityView's percentage-based side-by-side columns.
--------------------------------------------------------------------- */
:is(.gv-container-6463, .gv-container-6656) .gv-grid.gv-list-view-content {
    display: block !important;
    width: 100% !important;
}

:is(.gv-container-6463, .gv-container-6656) .gv-grid.gv-list-view-content [class*="gv-grid-col-"] {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
    box-sizing: border-box !important;
}

/* ---------------------------------------------------------------------
   Each staff member's entry - clear card styling so entries don't run
   into each other, and so nothing can visually overlap.
--------------------------------------------------------------------- */
:is(.gv-container-6463, .gv-container-6656) .gv-list-view {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 10px;
    margin: 0 0 16px;
    border: 1px solid #e2e4e7;
    border-radius: 8px;
    background: #fafbfc;
    overflow: hidden; /* clearfix - prevents floated/absolute children from spilling into the next entry */
}

/* ---------------------------------------------------------------------
   "Update" edit-entry link - force normal in-flow placement so it can't
   overlap the heading above it, regardless of what GravityView's default
   template positioned it with.
--------------------------------------------------------------------- */
:is(.gv-container-6463, .gv-container-6656) [id*="edit_link"],
:is(.gv-container-6463, .gv-container-6656) [class*="edit_link"] {
    position: static !important;
    display: inline-block !important;
    float: none !important;
    margin: 8px 0 12px !important;
}

:is(.gv-container-6463, .gv-container-6656) [id*="edit_link"] a,
:is(.gv-container-6463, .gv-container-6656) [class*="edit_link"] a {
    display: inline-block;
    padding: 8px 18px;
    background: #2271b1;
    border: 1px solid #2271b1;
    border-radius: 6px;
    color: #fff !important;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

:is(.gv-container-6463, .gv-container-6656) [id*="edit_link"] a:hover,
:is(.gv-container-6463, .gv-container-6656) [class*="edit_link"] a:hover {
    background: #135e96;
    border-color: #135e96;
}

/* ---------------------------------------------------------------------
   The actual day/hours table - target its real class directly (not the
   generic `table` tag, which lost to the colgroup/class-based sizing
   that was actually controlling its width) and strip any fixed column
   widths the colgroup may be enforcing.
--------------------------------------------------------------------- */
:is(.gv-container-6463, .gv-container-6656) .gnh-avail-table {
    display: table !important;
    width: 100% !important;
    max-width: 100% !important;
    table-layout: auto !important;
    border-collapse: collapse;
    font-size: 14px;
    box-sizing: border-box !important;
}

:is(.gv-container-6463, .gv-container-6656) .gnh-avail-table colgroup,
:is(.gv-container-6463, .gv-container-6656) .gnh-avail-table col {
    width: auto !important;
}

:is(.gv-container-6463, .gv-container-6656) .gnh-avail-table th,
:is(.gv-container-6463, .gv-container-6656) .gnh-avail-table td {
    padding: 6px 8px;
    text-align: left;
    white-space: normal !important; /* release anything forcing the "Day" header etc. to truncate/abbreviate */
}

:is(.gv-container-6463, .gv-container-6656) .gnh-avail-notes-wrap {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin-top: 12px;
}

/* ---------------------------------------------------------------------
   Mobile - tighter padding, smaller table text, full-width Update button
--------------------------------------------------------------------- */
@media (max-width: 600px) {
    :is(.gv-container-6463, .gv-container-6656) .gv-list-view {
        padding: 8px;
    }

    :is(.gv-container-6463, .gv-container-6656) [id*="edit_link"] a,
    :is(.gv-container-6463, .gv-container-6656) [class*="edit_link"] a {
        display: block;
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }

    :is(.gv-container-6463, .gv-container-6656) .gnh-avail-table {
        font-size: 13px;
    }
}
