/* ==========================================================================
   Platform CSS — CommunityPay shared UI components
   Loaded by base.html. Available on every page.
   ========================================================================== */

/* --- Buttons --- */

/* The platform blue lives in these two variables and nowhere else.
   It is the institutional blue (#0066cc, white text at 5.6:1) on every
   page, signed in or not: the same blue as links, Save buttons and the
   field focus border. */
:root {
    --cp-blue: #0066cc;
    --cp-blue-hover: #0052a3;
}

/* Bootstrap's primary is the institutional blue: its buttons, outline
   buttons, links and the text/background/border utilities all follow. */
:root {
    --bs-primary: #0066cc;
    --bs-primary-rgb: 0, 102, 204;
    --bs-link-color: #0066cc;
    --bs-link-color-rgb: 0, 102, 204;
    --bs-link-hover-color: #0052a3;
    --bs-link-hover-color-rgb: 0, 82, 163;
}
.btn-primary {
    --bs-btn-bg: #0066cc;
    --bs-btn-border-color: #0066cc;
    --bs-btn-hover-bg: #0052a3;
    --bs-btn-hover-border-color: #0052a3;
    --bs-btn-active-bg: #004a94;
    --bs-btn-active-border-color: #004a94;
    --bs-btn-disabled-bg: #0066cc;
    --bs-btn-disabled-border-color: #0066cc;
    --bs-btn-focus-shadow-rgb: 0, 102, 204;
}
.btn-outline-primary {
    --bs-btn-color: #0066cc;
    --bs-btn-border-color: #0066cc;
    --bs-btn-hover-bg: #0066cc;
    --bs-btn-hover-border-color: #0066cc;
    --bs-btn-active-bg: #0066cc;
    --bs-btn-active-border-color: #0066cc;
    --bs-btn-disabled-color: #0066cc;
    --bs-btn-disabled-border-color: #0066cc;
    --bs-btn-focus-shadow-rgb: 0, 102, 204;
}

/* The house corner is 2px on everything Bootstrap draws: fields, buttons,
   cards, alerts, menus and dialogs. Pills and circles are left to their own
   classes. */
:root {
    --bs-border-radius: 2px;
    --bs-border-radius-sm: 2px;
    --bs-border-radius-lg: 2px;
    --bs-border-radius-xl: 2px;
    --bs-border-radius-xxl: 2px;
}

/* Primary platform button — white text on the platform blue */
.btn-platform {
    display: inline-flex;
    align-items: center;
    background: var(--cp-blue);
    color: #fff;
    border: none;
    border-radius: 2px;
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.375rem 1rem;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    transition: background 0.15s;
}

.btn-platform:hover {
    background: var(--cp-blue-hover);
    color: #fff;
}

/* --- Institutional-blue primary button ---
   Same treatment as the Save Changes button on Edit Profile: sharp
   (2px radius), no shadow, darker on hover/active. Shared here since new
   pages (Create Unit, etc.) need it too — not a copy of the inline version
   in edit_user_profile.html. */
.btn-institutional-primary {
    background: #0066cc;
    border: 1px solid #0066cc;
    border-radius: 2px;
    color: #fff;
    box-shadow: none;
}

.btn-institutional-primary:hover,
.btn-institutional-primary:focus {
    background: #0052a3;
    border-color: #0052a3;
    color: #fff;
    box-shadow: none;
}

.btn-institutional-primary:active {
    background: #003d7a;
    border-color: #003d7a;
}

/* --- Institutional-blue focus ring ---
   Thin border + a subtle 2px halo, replacing Bootstrap's default bulky
   0.25rem/25%-opacity ring. Institutional blue (#0066cc), not the platform
   button blue above — this is the color already established on account/
   dashboard/content pages (edit_user_profile.html's Save button, etc). */
.form-control:focus,
.form-select:focus {
    border-color: #0066cc;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
}

/* --- Text link buttons (no background, no border) --- */

/* Blue text link — view/navigate actions */
.btn-text-blue {
    background: none;
    border: none;
    padding: 0;
    color: #0066cc;
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s;
}

.btn-text-blue:hover {
    color: #0052a3;
}

/* Muted text link — cancel, secondary actions */
.btn-text-muted {
    background: none;
    border: none;
    padding: 0;
    color: #999;
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s;
}

.btn-text-muted:hover {
    color: #212529;
}

/* Red text link — destructive actions */
.btn-text-red {
    background: none;
    border: none;
    padding: 0;
    color: #dc3545;
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s;
}

.btn-text-red:hover {
    color: #a71d2a;
}

/* --- Segmented pill toggle (tabs or in-place mode switches) --- */
/* One shared component instead of a per-page variant — first used by
   manage_units.html's Add Unit/Bulk Import/Allocations tabs, reused
   wherever a page needs a small segmented switch. Works with <a> (real
   navigation, e.g. ?tab=) or <button> (JS-driven, no navigation) children;
   whichever is selected gets the .active class. */
.pill-toggle {
    display: inline-flex;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 2px;
    overflow: hidden;
}

.pill-toggle > a,
.pill-toggle > button {
    border: none;
    background: transparent;
    padding: 0.35rem 1.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1.4;
    letter-spacing: 0.01em;
}

.pill-toggle > a:hover:not(.active),
.pill-toggle > button:hover:not(.active) {
    color: #212529;
    background: #fff;
}

.pill-toggle > a.active,
.pill-toggle > button.active {
    color: #0066cc;
    background: rgba(0, 102, 204, 0.04);
    border: 1px solid #0066cc;
    border-radius: 2px;
    font-weight: 600;
}


/* --- Checkboxes and radios ---
   One standard everywhere: a thin grey outline, the house 2px corner on a
   box, charcoal with a white mark when chosen. No glow: keyboard focus draws
   a plain charcoal outline. Switches are left to Bootstrap's shape and take
   the same charcoal. */
.form-check-input {
    border: 1px solid #adb5bd;
    background-color: #fff;
    box-shadow: none;
    transition: border-color 0.12s, background-color 0.12s;
}
.form-check-input[type="checkbox"] { border-radius: 2px; }
.form-switch .form-check-input[type="checkbox"] { border-radius: 2em; }
.form-check-input:hover { border-color: #495057; }
.form-check-input:checked,
.form-check-input[type="checkbox"]:indeterminate {
    background-color: #1a1a1a;
    border-color: #1a1a1a;
}
/* The mark is a thin tick whose long stroke runs out to the top right corner.
   Both strokes sit at 45 degrees, so the pixels step evenly and the line is smooth. */
.form-check-input:checked[type="checkbox"] {
    --bs-form-check-bg-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 8.5 L4.5 11.5 L16 0' stroke='%23fff' stroke-width='1.3' fill='none' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: 100% 100%;
    background-position: center;
}
.form-switch .form-check-input:checked[type="checkbox"] {
    --bs-form-check-bg-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3E%3Ccircle r='3' fill='%23fff'/%3E%3C/svg%3E");
    background-size: contain;
    background-position: right center;
}
.form-check-input:focus {
    border-color: #495057;
    box-shadow: none;
    outline: none;
}
.form-check-input:focus-visible {
    outline: 2px solid #1a1a1a;
    outline-offset: 2px;
}
.form-check-input:disabled { opacity: 0.45; }

/* The blue version: the same box and mark in the institutional blue. Add
   class="form-check-input check-blue" where the choice sits among blue
   controls; charcoal is the default everywhere else. */
.form-check-input.check-blue:hover { border-color: #0066cc; }
.form-check-input.check-blue:checked,
.form-check-input.check-blue[type="checkbox"]:indeterminate {
    background-color: #0066cc;
    border-color: #0066cc;
}
.form-check-input.check-blue:focus { border-color: #0066cc; }
.form-check-input.check-blue:focus-visible { outline-color: #0066cc; }


/* The same checkbox for a plain <input type="checkbox"> that is not a
   Bootstrap .form-check-input (a Django widget, a hand-written row): put
   cp-checks on any wrapper, and cp-checks-blue beside it for the blue version. */
.cp-checks input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    vertical-align: -3px;
    border: 1px solid #adb5bd;
    border-radius: 2px;
    background: #fff no-repeat center / 100% 100%;
    cursor: pointer;
    transition: border-color 0.12s, background-color 0.12s;
}
.cp-checks input[type="checkbox"]:hover { border-color: #495057; }
.cp-checks input[type="checkbox"]:checked {
    background-color: #1a1a1a;
    border-color: #1a1a1a;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 8.5 L4.5 11.5 L16 0' stroke='%23fff' stroke-width='1.3' fill='none' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.cp-checks input[type="checkbox"]:focus { outline: none; }
.cp-checks input[type="checkbox"]:focus-visible { outline: 2px solid #1a1a1a; outline-offset: 2px; }
.cp-checks input[type="checkbox"]:disabled { opacity: 0.45; cursor: default; }
.cp-checks-blue input[type="checkbox"]:hover { border-color: #0066cc; }
.cp-checks-blue input[type="checkbox"]:checked { background-color: #0066cc; border-color: #0066cc; }
.cp-checks-blue input[type="checkbox"]:focus-visible { outline-color: #0066cc; }


/* --- Link blocks ---
   A block that links to a page: a post in a list, a tool, a Trust Center
   page, a related card. The whole block is the link. At rest a thin light
   corner closes its bottom right. On hover or keyboard focus the title goes
   to ink and the corner darkens. Nothing fills, lifts, shifts or casts a
   shadow, and no arrow appears.

   Use: class="cp-link-block" on the <a>, class="cp-link-block-title" on its title.
   A page sets where the corner sits with --corner-bottom (the block's own
   bottom padding) and never restyles the hover. The ruled cards of the blog
   (.ruled-card, base_content.html) are link blocks and take the same rules.

   A boxed card (an outlined box, like a state on the Laws index) takes no
   corner: on hover its outline darkens and nothing else changes. */
.cp-link-block {
    position: relative;
    display: block;
    text-decoration: none;
    color: inherit;
}

.cp-link-block:hover,
.cp-link-block:focus-visible {
    text-decoration: none;
    color: inherit;
}

.cp-link-block::after,
.ruled-card::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: var(--corner-bottom, 1.1rem);
    width: 18px;
    height: 18px;
    border-right: 1px solid #c4c4c4;
    border-bottom: 1px solid #c4c4c4;
    transition: border-color 0.15s ease;
    pointer-events: none;
}

.cp-link-block:hover::after,
.cp-link-block:focus-visible::after,
.ruled-card:hover::after,
.ruled-card:focus-visible::after {
    border-color: #555;
}

.cp-link-block .cp-link-block-title,
.ruled-card .ruled-title {
    color: #666;
    transition: color 0.15s ease;
}

.cp-link-block:hover .cp-link-block-title,
.cp-link-block:focus-visible .cp-link-block-title,
.ruled-card:hover .ruled-title,
.ruled-card:focus-visible .ruled-title {
    color: #000;
}


/* --- The arrow at the end of a link ---
   The thin line arrow of the platform page (.pillar-arrow there), drawn from
   the icon font: <i class="bi bi-arrow-right cp-arrow" aria-hidden="true"></i>.
   The glyph "→" takes the weight of the text around it and reads heavy in a
   bold label. The arrow takes its link's ink and does not move on hover; a
   card may darken it. An arrow that leads a link ("back to") takes
   cp-arrow-lead as well. */
.cp-arrow {
    display: inline-block;
    margin-left: 0.4em;
    font-size: 0.85em;
    font-weight: 400;
    vertical-align: -0.05em;
}

.cp-arrow-lead {
    margin-left: 0;
    margin-right: 0.4em;
}

/* --- A filter: plain words, and the chosen one is bold over a rule ---
   An option is a word with no box. Under the pointer it goes to ink over the house
   rule in grey. The chosen one is bold and black over the rule in ink. Every label
   keeps the room its bold form needs (the hidden twin under it) and the rule is
   there in every state, clear at rest, so choosing one moves nothing beside it.

   Corners were tried on the chosen one (two, four, then one at the bottom right) and
   dropped: the corner belongs to a block that links to a page, not to a filter.

   Markup: <button class="cp-filter"><span class="cp-filter-label" data-label="All">All</span></button>
   The chosen state is .is-active, .active, aria-pressed="true" or aria-current. */
.cp-filter {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    margin: 0;
    padding: 0.3rem 0.7rem;
    border: 0;
    border-radius: 0;
    background: none;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.5;
    letter-spacing: 0;
    text-transform: none;
    text-decoration: none;
    white-space: nowrap;
    color: #6c757d;
    cursor: pointer;
    transition: color 0.15s ease;
}

.cp-filter:hover {
    color: #1a1a1a;
    text-decoration: none;
}

.cp-filter.is-active,
.cp-filter.active,
.cp-filter[aria-pressed="true"],
.cp-filter[aria-current] {
    color: #000;
}

.cp-filter-label {
    display: inline-flex;
    flex-direction: column;
    padding-bottom: 0.15em;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s ease;
}

.cp-filter:hover .cp-filter-label {
    border-bottom-color: #ced4da;
}

.cp-filter-label::after {
    content: attr(data-label);
    height: 0;
    overflow: hidden;
    visibility: hidden;
    font-weight: 700;
    pointer-events: none;
    user-select: none;
}

.cp-filter.is-active .cp-filter-label,
.cp-filter.active .cp-filter-label,
.cp-filter[aria-pressed="true"] .cp-filter-label,
.cp-filter[aria-current] .cp-filter-label {
    font-weight: 700;
    border-bottom-color: #1a1a1a;
}

.cp-filter:focus-visible {
    outline: 2px solid #1a1a1a;
    outline-offset: 2px;
}

/* --- A black button under the pointer goes to charcoal ---
   The house pair is #1a1a1a at rest and #3a3a3a on hover (the nav's Signup).
   It never goes blacker, and nothing in it moves. */
