/*
 * Formularies index (PD-29425) -- matches the design mockup's small, purple-accented
 * visual language rather than Bootstrap's defaults. Scoped under .formulary-index or
 * a dedicated `formulary-*` class; Bootstrap's `.badge`/`.btn`/`.card` are never
 * redefined globally. Colors are the mockup's literal hex, commented with its var name.
 */

/* The shared layout wraps every page in a white, padded .site-contents panel, which
 * would merge this page's own cards into that outer panel. Neutralize it and give
 * .main-content a grey ground instead, scoped via the bare controller-name body class
 * rather than `.formularies-index`, which would leave the show page in the panel. */
body.formularies .main-content {
  background-color: #f2f3f6; /* --bg */
}

/* `.main-content` is in the selector purely for specificity: application.css's
 * body > .main-content > .site-contents scores the same as a bare
 * `body.formularies .site-contents` and loads after this file, so the tie would
 * go to the white panel. Naming .main-content breaks the tie. */
body.formularies .main-content .site-contents {
  background-color: transparent;
  padding: 0;
  border-radius: 0;
  /* The table card owns horizontal scrolling; overflow:auto here doubled the scrollbar. */
  overflow-x: hidden;
}

.formulary-index select.formulary-select {
  appearance: none;
  font-size: 12px;
  font-weight: 600;
  color: #1c2130; /* --ink */
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b7183' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  border: 1px solid #cfd3de;
  border-radius: 8px;
  padding: 6px 28px 6px 13px;
}

/* One rule for text + date inputs, matching the segmented buttons' weight.
 *
 * Date inputs share the text input's ink colour, which also colours their empty
 * mm/dd/yyyy hint -- accepted deliberately. That hint lives in the webkit shadow DOM
 * with no "is empty" selector, so the only alternative is muting the whole control,
 * which mutes a CHOSEN date identically and makes an applied filter read as unset.
 * Of the two, a hint that looks slightly too solid beats a real filter that looks
 * like a placeholder. Text inputs need no such tradeoff: ::placeholder below mutes
 * only the empty state. */
.formulary-index input[type="text"].form-control,
.formulary-index input[type="date"].form-control {
  font-size: 12px;
  font-weight: 600;
  color: #1c2130; /* --ink */
  border: 1px solid #cfd3de;
  border-radius: 8px;
  padding: 6px 13px;
}

.formulary-index input[type="text"].form-control::placeholder {
  font-size: 12px;
  font-weight: 600;
  color: #6b7183; /* --muted, matching "Active only" */
  opacity: 1; /* Firefox dims placeholders by default */
}

.formulary-index select.formulary-select--year {
  min-width: 110px;
}

.formulary-index select.formulary-select--audit {
  min-width: 150px;
}

/* ---- Table: header + body typography ---- */
.formulary-index table {
  width: 100%;
  border-collapse: collapse;
}

.formulary-index th {
  font-size: 11px;
  font-weight: 700;
  color: #8b2fa8; /* --link */
  text-align: left;
  padding: 8px 9px;
  border-bottom: 2px solid #e3e5ec; /* --line */
  white-space: nowrap;
}

.formulary-index td {
  padding: 9px;
  border-bottom: 1px solid #e3e5ec; /* --line */
  vertical-align: middle;
  font-size: 12.3px;
}

/* ---- Page title (scoped -- do not restyle h1 globally) ---- */
.formulary-index h1 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 4px;
}

/* :not(.btn) excludes the segmented-control toggle labels, restyled separately below. */
.formulary-index .form-label,
.formulary-index label:not(.btn) {
  font-size: 11px;
  font-weight: 700;
  color: #1c2130; /* --ink */
}

/* ---- Segmented control (Mapped / Active radio-as-button groups) ---- */
.formulary-index .btn-group[role="group"] {
  display: inline-flex;
  border: 1px solid #cfd3de;
  border-radius: 8px;
  overflow: hidden;
}

.formulary-index .btn-group[role="group"] .btn-outline-secondary {
  font-size: 12px;
  font-weight: 600;
  color: #6b7183; /* --muted */
  background: #fff;
  border: none;
  border-left: 1px solid #e3e5ec; /* --line */
  border-radius: 0;
  padding: 6px 13px;
}

.formulary-index .btn-group[role="group"] .btn-outline-secondary:first-of-type {
  border-left: none;
}

.formulary-index .btn-check:checked + .btn-outline-secondary {
  background: #7d219c; /* --purple */
  color: #fff;
  font-weight: 700;
}

/* ---- Search submit button ---- */
.formulary-index .btn-primary {
  font-size: 12.5px;
  font-weight: 700;
  background: #7d219c; /* --purple */
  border-color: #7d219c; /* --purple */
  border-radius: 7px;
  padding: 8px 16px;
}

.formulary-index .btn-primary:hover {
  background: #651b7e; /* --purple-dk */
  border-color: #651b7e; /* --purple-dk */
}

/* ---- Muted count text ("27 plans") ---- */
.formulary-mini {
  font-size: 10.5px;
  color: #6b7183; /* --muted */
}

/* See FormularyDecorator for which state maps to which modifier. */
.formulary-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  border-radius: 5px;
  padding: 2px 7px;
  letter-spacing: .02em;
  white-space: nowrap;
}

.formulary-badge--ok {
  background: #e2f4e8; /* --ok-bg */
  color: #1c7c40; /* --ok */
}

.formulary-badge--bad {
  background: #fbe3e6; /* --bad-bg */
  color: #a41e34; /* --bad */
}

.formulary-badge--muted {
  background: #eceef3; /* mockup literal, not a root var (.badge.no / .badge.audnone) */
  color: #6b7183;
}

.formulary-badge--direct {
  background: #f3e6fb; /* --direct-bg */
  color: #7d219c; /* --direct-ink */
}

.formulary-badge--mmit {
  background: #eef0f5; /* --mmit */
  color: #4a5164; /* --mmit-ink */
}

/* Inert until PD-29426 ships Formulary Detail. */
.formulary-btn {
  font-size: 12.5px;
  font-weight: 700;
  background: #7d219c; /* --purple */
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
}

.formulary-btn:hover {
  background: #651b7e; /* --purple-dk */
}

.formulary-btn--sm {
  padding: 5px 11px;
  font-size: 11.5px;
}

.formulary-btn--ghost {
  background: #fff;
  color: #7d219c; /* --purple */
  border: 1.5px solid #7d219c; /* --purple */
}

.formulary-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

/* ---- Formulary detail: the design's literal values, annotated with its own var
 * names, exactly like the index palette above. ---- */

.formulary-index .sub {
  color: #6b7183; /* --muted */
  font-size: 12px;
  margin-bottom: 14px;
}

/* application.css sets a bare `h3 { font-size: 18px; font-weight: bold; }` --
 * this scoped selector is more specific (0,1,1 beats 0,0,1) so it wins regardless
 * of stylesheet load order, unlike the .main-content tie above. */
.formulary-index h3 {
  font-size: 13.5px;
  font-weight: 800;
  margin-bottom: 10px;
}

/* Card header row -- Plan mapping summary's badge and Drugs & coverage's panel
 * toggle both sit inline with their h3, not stacked below it. */
.formulary-index .cardhead {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.formulary-index .cardhead h3 {
  margin-bottom: 0;
}

/* ---- Metadata strip: seven fields, one wrapping row. ---- */
.formulary-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 34px;
  font-size: 12.5px;
}

.formulary-meta-field {
  display: flex;
  flex-direction: column;
}

.formulary-meta-label {
  display: block;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #6b7183; /* --muted */
  margin-bottom: 3px;
}

.formulary-note {
  font-size: 12.5px;
  color: #6b7183; /* --muted */
  padding: 12px 0;
}

/* Plan-mapping table section head. The `+div` rule rounds the table wrapper's bottom
 * corners and clips its top ones so head and table read as one block -- which relies
 * on the view rendering `.table-responsive` as `.secthead`'s immediate next sibling. */
.formulary-index .secthead {
  background: #f7f2fa; /* mockup literal, no root var name given */
  border: 1px solid #e3e5ec; /* --line */
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 12px;
  color: #7d219c; /* --purple */
  margin-top: 14px;
}

.formulary-index .secthead + div {
  border: 1px solid #e3e5ec; /* --line */
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}

/* The Overrides panel's empty state is centred and padded, unlike the other panels'
 * left-aligned notes above. */
.formulary-empty-state {
  padding: 26px 10px;
  text-align: center;
  color: #6b7183; /* --muted */
  font-size: 12.5px;
}

.formulary-warning {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #a41e34; /* --bad, matches .formulary-badge--bad */
  background: #fbe3e6; /* --bad-bg */
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

/* Coverage Tier's Not Listed state -- see FormularyDrugDecorator::BADGE_WARN. */
.formulary-badge--warn {
  background: #fdf1d6; /* --warn-bg */
  color: #8a6d00; /* --warn */
}

/* The grey `source: {value}` annotation beside an overridden effective value. */
.formulary-source {
  display: inline-block;
  font-size: 10px;
  color: #9aa1b5;
  margin-left: 5px;
  white-space: nowrap;
}

/* med_id column -- tabular figures. */
.formulary-num {
  font-variant-numeric: tabular-nums;
}

/* The three boolean columns (4-6 of med_id, Drug, Coverage Tier, PA, ST, QL). */
.formulary-drug-table th:nth-child(n+4),
.formulary-drug-table td:nth-child(n+4) {
  text-align: center;
}

/* Bootstrap's .form-control is width:100%, which stretched this across the whole card
 * and pinned the Search button to the far right; flex:0 1 auto stops it re-growing. */
.formulary-index .formulary-search-input {
  width: auto;
  min-width: 260px;
  flex: 0 1 auto;
}

/* One <table> per section, so without a fixed layout each sizes its columns from its
 * OWN content and stacked sections fail to line up (all-em-dash Issuer ID / Plan Type
 * columns render narrower than ones carrying "70893" / "EPO"). Percentages sum to 100;
 * Carrier takes the slack, its values being the longest here. */
.formulary-index .formulary-plan-mapping-table {
  table-layout: fixed;
  width: 100%;
}

.formulary-index .formulary-plan-mapping-table th:nth-child(1),
.formulary-index .formulary-plan-mapping-table th:nth-child(2) {
  width: 8%;
}

.formulary-index .formulary-plan-mapping-table th:nth-child(3) {
  width: 28%;
}

.formulary-index .formulary-plan-mapping-table th:nth-child(4),
.formulary-index .formulary-plan-mapping-table th:nth-child(5),
.formulary-index .formulary-plan-mapping-table th:nth-child(6) {
  width: 13%;
}

.formulary-index .formulary-plan-mapping-table th:nth-child(7) {
  width: 17%;
}
