/* Calwriters Functions front-end styles */
.gv-diy-view {
    display: flex;
    gap: 1rem;
    align-items: center;
    font-size: 80%;
    padding-left: 1rem;

    div {
        a {
            font-size: 90%;
            opacity: 0;
            transition: opacity .3 ease;
        }
    }

    &:hover {
        div {
            a {
                font-size: 90%;
                opacity: 1;
            }
        }
    }

}

/* Branch Signup settings page (Settings > Branch Signup) */
.calwriters-branch-signup-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0.25rem 1rem 0.25rem 0;
}

.calwriters-branch-signup-warning {
    color: #b32d2e;
    font-size: 85%;
    margin-left: 0.5rem;
}

/* Branch Roster settings page (Branch Signup > Branch Roster).
   Reuses .calwriters-branch-signup-checkbox for its checkbox lists. */
.calwriters-branch-roster-locked {
    margin: 0.25rem 0 1rem;
    color: #646970;

    li {
        margin: 0.15rem 0;
        list-style: disc inside;
    }
}

/* GravityView's SUCCESS notices carry the WordPress admin class `updated`, and
   the active theme hides post meta with the stock Underscores rule
   `.byline, .updated:not(.published) { display: none }` (inn8ly-builder
   style.css). So on the Branch Roster the "N entries exported as CSV —
   Download CSV" notice is rendered, with a working link, and never shown:
   the export looks like the page merely reloading. Error notices are class
   `gv-error error`, carry no `updated`, and were visible throughout — which is
   what made this look like an export failure rather than a CSS one.

   `.gv-notice.updated:not(.published)` is 0,3,0 against the theme's 0,2,0, so
   it wins on specificity and needs no !important. Scoped to `.gv-notice` so it
   restores GravityView notices only and leaves real post meta hidden. */
.gv-notice.updated:not(.published) {
    display: block;
}

/* Branch Payouts — Connected Accounts screen (CWC Membership > Branch Payouts) */
.calwriters-payouts-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.calwriters-payouts-mode {
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;

    &.calwriters-payouts-mode--test {
        background: #f0f6fc;
        color: #0a4b78;
    }

    /* Live mode moves real money — it should not look like test mode. */
    &.calwriters-payouts-mode--live {
        background: #fcf0f1;
        color: #8a2424;
    }
}

.calwriters-payouts-table {
    margin-top: 1rem;

    td {
        vertical-align: top;
    }

    code {
        font-size: 92%;
    }
}

.calwriters-payouts-flags {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 1rem;

    li {
        margin: 0;
        white-space: nowrap;
    }
}

.calwriters-payouts-yes {
    color: #007017;
    font-weight: 600;
}

.calwriters-payouts-no {
    color: #b32d2e;
}

.calwriters-payouts-due-wrap {
    margin-top: 0.35rem;

    summary {
        cursor: pointer;
        color: #b32d2e;
    }
}

.calwriters-payouts-muted {
    color: #646970;
}

.calwriters-payouts-due {
    margin: 0.35rem 0 0;
    max-height: 12rem;
    overflow-y: auto;

    li {
        margin: 0.1rem 0;
        list-style: disc inside;
    }
}

.calwriters-payouts-result {
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.calwriters-payouts-url {
    width: 100%;
    max-width: 32rem;
    font-family: monospace;
    font-size: 92%;

    &.is-expired {
        color: #b32d2e;
        text-decoration: line-through;
    }
}

.calwriters-payouts-status {
    color: #646970;
    font-size: 92%;
}

.calwriters-payouts-error {
    color: #b32d2e;
    margin: 0;
}

.calwriters-payouts-notes {
    max-width: 46rem;

    li {
        margin: 0.4rem 0;
        list-style: disc outside;
        margin-left: 1.2rem;
    }
}

.calwriters-payouts-help {
    max-width: 46rem;
    margin: 0.5rem 0 0.75rem 1.2rem;

    li {
        margin: 0.35rem 0;
        list-style: decimal outside;
    }
}

.calwriters-payouts-unmapped {
    columns: 3 14rem;
    max-width: 52rem;

    li {
        margin: 0.1rem 0;
        list-style: disc inside;
        break-inside: avoid;
    }
}

.calwriters-payouts-splits {
    max-width: 62rem;

    input[type="text"] {
        text-align: right;
    }
}

.calwriters-payouts-branch {
    max-width: 14rem;
}

.calwriters-payouts-source {
    max-width: 62rem;
    padding: 0.5rem 0.75rem;
    border-left: 4px solid #72aee6;
    background: #f6f7f7;
}

/* Membership Levels — statuses that do not mean the money has cleared */
.calwriters-membership-unsettled {
    color: #b32d2e;
    font-size: 90%;
    display: block;
    margin-left: 1.6rem;
    max-width: 44rem;
}

/* ---------------------------------------------------------------------------
   Membership renewal notice (front end)

   Fixed to the bottom of the viewport on purpose. The notice is printed from
   whichever of wp_body_open / wp_footer fires — the active theme has no
   wp_body_open, so in practice it lands at the very end of the document — and
   taking it out of the flow makes both hooks look identical and keeps it clear
   of the site's sticky header.
   --------------------------------------------------------------------------- */
.calwriters-renewal-notice {
    position: fixed;
    z-index: 9999;
    right: 1rem;
    bottom: 1rem;
    left: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    align-items: center;
    justify-content: center;
    max-width: 46rem;
    margin-inline: auto;
    padding: 0.85rem 1.15rem;
    border-radius: 6px;
    box-shadow: 0 2px 14px rgb(0 0 0 / 22%);
    background: #1d2327;
    color: #fff;
    font-size: 0.95rem;
    line-height: 1.4;

    p {
        margin: 0;
    }

    &.calwriters-renewal-notice--expired {
        background: #8a1f1f;
    }

    .calwriters-renewal-notice__text {
        flex: 1 1 16rem;
    }

    .calwriters-renewal-notice__action {
        flex: 0 0 auto;
        padding: 0.45rem 1rem;
        border-radius: 4px;
        background: #fff;
        color: #1d2327;
        font-weight: 600;
        text-decoration: none;

        &:hover,
        &:focus {
            background: #f0f0f1;
            text-decoration: none;
        }
    }

    .calwriters-renewal-notice__dismiss {
        flex: 0 0 auto;
        color: inherit;
        font-size: 0.85em;
        opacity: 0.8;
        text-decoration: underline;

        &:hover,
        &:focus {
            opacity: 1;
        }
    }
}

/* [calwriters_membership_status] — the same state, in the page rather than over it */
/* The member's membership panel. Deliberately NOT a notice: it is where a
   member reads their status and changes a setting, so it is a quiet card that
   sits with the rest of the page. The grey fill and coloured left bar it used
   to carry are the WordPress admin-notice idiom, and made a settings panel
   read as an alert. Expiring and expired keep a tint, because those two ARE
   warnings — the floating notice is a separate element and still looks like
   one. */
.calwriters-membership-status {
    max-width: 34rem;
    margin: 1rem 0 1.5rem;
    /* No box at all. The left inset matches the Stripe subscription panel that
       follows it on /my-profile/, which is a <ul> and so sits on a 1.5em list
       indent — 27px at that page's 18px. Expressed in em rather than the
       measured pixels so the two keep step if the font size changes. */
    padding: 0 0 0 1.5em;
    border: 0;
    background: none;

    p {
        margin: 0 0 0.5rem;
    }

    p:last-child {
        margin-bottom: 0;
    }

    /* Expiring and expired ARE warnings, so they keep a tint — and the padding
       the tint needs in order not to look clipped. Active stays plain. */
    &.calwriters-membership-status--expiring,
    &.calwriters-membership-status--expired {
        padding: 0.9rem 1.1rem 0.9rem 1.5em;
        border-radius: 4px;
    }

    &.calwriters-membership-status--expiring {
        background: #fcf9e8;
    }

    &.calwriters-membership-status--expired {
        background: #fcf0f1;
    }

    .calwriters-membership-status__state {
        margin-bottom: 0.6rem;
    }

    /* The sentence that says what happens next. */
    .calwriters-membership-status__auto,
    .calwriters-membership-status__cancelled,
    .calwriters-membership-status__manual {
        margin-bottom: 0;
        font-weight: 600;
    }

    /* One row for everything the member can DO, so Renew and the auto-renew
       switch line up instead of stacking as a paragraph then a form. */
    .calwriters-membership-status__actions {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.6rem;
        margin: 0.9rem 0 0;
    }

    /* Renew is a link, because it navigates somewhere; the auto-renew switch is
       a button, because it acts. They sit side by side and must look identical,
       so the link copies what the theme gives a bare <button> — measured on
       /my-profile/: #002676, white, 15px/700, uppercase, 8px 20px, square.
       The theme styles links from #content a, an ID selector no class rule can
       outrank, so every property it also sets needs !important. Without the
       colour the text rendered navy on navy and the button looked empty.
       If the theme's buttons change, this block is the one place to follow. */
    .calwriters-membership-status__action {
        display: inline-block;
        padding: 8px 20px;
        border-radius: 0;
        background: #002676;
        color: #fff !important;
        font-size: 15px !important;
        font-weight: 700 !important;
        line-height: 1.5;
        text-transform: uppercase !important;
        text-decoration: none;

        &:hover,
        &:focus {
            background: #001a52;
            color: #fff !important;
            text-decoration: none;
        }
    }

    /* The auto-renew switch. A button, because it POSTs — a link here could be
       followed by a browser prefetch and change what a member is charged
       without them touching it. The button itself is left unstyled: the theme
       already gives a bare <button> the site's own look. */
    .calwriters-membership-status__auto-renew {
        display: inline-block;
        margin: 0;

        /* The theme blankets every form with a white panel:
             #content form { background-color: #fff; padding: 20px; }
           emitted inline by inn8ly-builder. That is an ID selector, so no
           class rule here can outrank it and !important is the only honest
           tool — matching a wrapper like #content would tie this file to the
           theme's markup and stop working outside it. This is one button, not
           a form the member fills in, so it gets no panel. */
        padding: 0 !important;
        border: 0;
        background: none !important;
        box-shadow: none;
    }

    /* What just happened, after the toggle redirects back. A plain sentence,
       not a coloured panel. */
    .calwriters-membership-status__result {
        margin: 0 0 0.6rem;
        font-weight: 600;
    }
}

/* Renewal mode — what a renewing member is carrying over, above the card field */
.calwriters-renewal-summary {
    /* Full width: this sits directly above the membership form, which is full
       width itself, so a narrower panel reads as a stray box beside the form
       rather than as its heading. */
    width: 100%;
    margin: 0 0 1.5rem;
    box-sizing: border-box;
    padding: 1rem 1.15rem;
    border-left: 4px solid #2271b1;
    border-radius: 3px;
    background: #f6f7f7;

    .calwriters-renewal-summary__title {
        margin: 0 0 0.6rem;
        font-size: 1.05rem;
        font-weight: 700;
    }

    .calwriters-renewal-summary__details {
        display: grid;
        /* The label column sizes to the longest label and stops there, so the
           two rows line up without either being given a fixed width. */
        grid-template-columns: max-content 1fr;
        gap: 0.3rem 1rem;
        margin: 0 0 0.75rem;

        dt {
            margin: 0;
            font-weight: 600;
        }

        dd {
            margin: 0;
        }
    }

    .calwriters-renewal-summary__note {
        margin: 0 0 0.5rem;
        color: #50575e;
        font-size: 0.9rem;
        line-height: 1.45;

        /* Two notes now: what carries over, and what cannot be changed here. */
        &:last-child {
            margin-bottom: 0;
        }
    }

    /* What the member is about to be charged, and when their year already runs
       to. Darker and heavier than the notes above it: this is the one thing on
       the panel they could be surprised by afterwards. */
    .calwriters-renewal-summary__charge {
        margin: 0.75rem 0 0;
        padding-top: 0.75rem;
        border-top: 1px solid #dcdcde;
        color: #1d2327;
        font-size: 0.9rem;
        font-weight: 600;
        line-height: 1.45;
    }
}

/* Renewal mode — the member Stripe already bills, shown instead of the form */
.calwriters-renewal-subscribed {
    /* Replaces the form entirely, so it takes the width the form would have. */
    width: 100%;
    margin: 0 0 1.5rem;
    box-sizing: border-box;
    padding: 1rem 1.15rem;
    border-left: 4px solid #007017;
    border-radius: 3px;
    background: #f6f7f7;

    p {
        margin: 0;
    }

    .calwriters-renewal-subscribed__portal {
        margin-top: 0.8rem;
    }
}

/* Membership status shortcode — the member with no payment method saved. */
.calwriters-membership-status__manual {
    margin: 0 0 0.75rem;
    color: #50575e;
    font-size: 0.9rem;
    line-height: 1.45;
}

/* Cancelled in Stripe and still paid up. Darker than the note above, because a
   member reading this needs the end date to register. */
.calwriters-membership-status__cancelled {
    margin: 0 0 0.75rem;
    color: #1d2327;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.45;
}

/* The "you are the exception" note an administrator sees on RCP's /register/ */
.calwriters-register-admin-note {
    max-width: 46rem;
    margin: 0 0 1.25rem;
    padding: 0.75rem 1rem;
    border-left: 4px solid #dba617;
    background: #fcf9e8;
}

/* Import Members — the four-step screen. Admin-only, but this stylesheet is
   enqueued there by Import\Screen rather than a second file being added. */
.calwriters-import {

    .calwriters-import-required {
        color: #d63638;
        font-weight: 700;
    }

    .calwriters-import-map th[scope="row"] {
        width: 12rem;
    }

    /* Wide content scrolls in its own box: the preview is as wide as the
       export, which is 17 columns, and the page must not scroll sideways. */
    .calwriters-import-scroll {
        max-width: 100%;
        max-height: 32rem;
        overflow: auto;
        margin: 0 0 1rem;
        border: 1px solid #c3c4c7;
    }

    .calwriters-import-scroll table {
        border: 0;
        white-space: nowrap;
    }

    .calwriters-import-unresolved {
        max-width: 28rem;
        margin: 0 0 0.5rem;
    }

    .calwriters-import-actions {
        margin: 1rem 0 1.5rem;

        .button {
            margin-right: 0.5rem;
        }
    }

    /* The live run and the finished report sit above step 1, so they are lifted
       off the page rather than reading as one more block of the form. */
    .calwriters-import-panel {
        margin: 1.5rem 0;
        padding: 1rem 1.25rem;
        border-radius: 6px;
        background: #fff;
        box-shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 2px 8px rgb(0 0 0 / 8%);

        > :first-child {
            margin-top: 0;
        }

        > :last-child {
            margin-bottom: 0;
        }
    }

    .calwriters-import-run {
        max-width: 40rem;
        border-left: 4px solid #2271b1;
    }

    .calwriters-import-bar {
        height: 1.25rem;
        margin: 0.5rem 0;
        border-radius: 3px;
        background: #dcdcde;
        overflow: hidden;

        span {
            display: block;
            height: 100%;
            width: 0;
            background: #2271b1;
            transition: width 0.2s linear;
        }
    }

    .calwriters-import-count {
        margin: 0.25rem 0;
        font-weight: 600;
    }

    .calwriters-import-tally {
        margin: 0.25rem 0 0.75rem;
        color: #50575e;
    }

    .calwriters-import-summary {
        margin: 0 0 0.5rem;
    }

    .calwriters-import-counts {
        margin: 0 0 1rem;

        li {
            margin: 0 0 0.2rem;
        }
    }

    .calwriters-import-filters {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
        margin: 0 0 0.75rem;

        &[hidden] {
            display: none;
        }

        .button[aria-pressed="true"] {
            background: #2271b1;
            border-color: #2271b1;
            color: #fff;
        }
    }

    .calwriters-import-report tr[hidden] {
        display: none;
    }

    .calwriters-import-report {

        td {
            white-space: normal;
            vertical-align: top;
        }

        .calwriters-import-refused {
            color: #d63638;
            font-weight: 600;
        }

        .calwriters-import-matched,
        .calwriters-import-skipped {
            color: #996800;
        }

        .calwriters-import-created {
            color: #007017;
        }
    }

    .calwriters-import-warning {
        margin-top: 0.25rem;
        color: #996800;
    }
}

/*
 * Show-password (eye) button on Gravity Forms password fields.
 *
 * The theme styles every <button> as a primary button — navy background, white
 * text, 20px side padding, a 13px margin and uppercase — so Gravity Forms' eye
 * icon rendered as a navy block that dropped below the field. Reset it to a bare
 * icon inside the input. The theme's rule is #content form[data-r8-class=
 * "r8_primary_form"] button — it carries an ID, so no selector made of classes
 * can outrank it. :not(#cwc-no-id) always matches but counts as an ID, which
 * wins without !important. Gravity Forms' own positioning (absolute, right
 * edge, full height) is kept.
 *
 * Also styles the eye that Login\PasswordToggle adds to the User Registration
 * login form, which uses the same markup.
 */
.gform_wrapper .password_input_container {
    input:not(#cwc-no-id) {
        /* Room for the icon, inside the width the theme gives the box rather
           than added to it. */
        box-sizing: border-box;
        padding-right: 2.75rem;
    }

    button.gform_show_password:not(#cwc-no-id) {
        display: flex;
        align-items: center;
        justify-content: center;
        width: auto;
        min-width: 0;
        height: 100%;
        margin: 0;
        padding: 0 0.5rem;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        text-shadow: none;
        color: #555;
        line-height: 1;
        text-transform: none;
        right: 0;

        &:hover,
        &:focus-visible {
            background: transparent;
            color: var(--color-primary, #002676);
        }

        &:focus-visible {
            outline: 2px solid var(--color-primary, #002676);
            outline-offset: -2px;
        }

        .dashicons {
            color: inherit;
            font-size: 20px;
            width: 20px;
            height: 20px;
        }
    }
}

/*
 * The login form's password is a text field (Login\PasswordToggle wraps it), and
 * its input is narrower than the row, so a full-width wrapper put the eye far to
 * the right of the box. Hug the input instead. Only the wrapped text field —
 * a real Password field sits in .ginput_container_password and is full width.
 */
/* :not(#cwc-no-id) again: Gravity Forms' own display:block on this wrapper is
   equally specific and loads after this file. */
.gform_wrapper .ginput_container_text>.password_input_container:not(#cwc-no-id) {
    display: inline-block;
    max-width: 100%;
}

/*
 * The login form's boxes take the browser's default width (no stylesheet sets
 * one), so the room made for the eye widened Password past Username. Pin both
 * to the same 12rem — the 192px they already rendered at — within the screen.
 */
.gf_login_form .ginput_container_text input:not(#cwc-no-id) {
    box-sizing: border-box;
    width: 12rem;
    max-width: 100%;
}

/* The lost-password page (Login\PasswordReset). Buttons are left to the theme. */
.cwc-reset {
    max-width: 28rem;

    & label {
        display: block;
        margin-bottom: 0.25rem;
    }

    & input[type="text"],
    & input[type="password"] {
        box-sizing: border-box;
        width: 100%;
    }

    & input[readonly] {
        opacity: 0.7;
    }
}

.cwc-reset-message {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-left: 4px solid #2e7d32;
    background: #f1f8f2;
    color: #1b1b1b;

    &.cwc-reset-message--error {
        border-left-color: #b3261e;
        background: #fdf1f0;
    }
}
