/* ═══════════════════════════════════════════════════════════════════
   Technical Groups - Refined Industrial Design
   ═══════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────
   Container
   ───────────────────────────────────────────────────────────────────── */
.technical-groups-container {
    background-color: var(--steel-950);
    color: var(--steel-100);
}

/* ─────────────────────────────────────────────────────────────────────
   Technical Group Card
   ───────────────────────────────────────────────────────────────────── */
.technical-group-card {
    background-color: var(--steel-850);
    border: 1px solid var(--steel-700);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    position: relative;
    overflow: hidden;
}

/* Subtle top accent line */
.technical-group-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent,
        var(--brass-500) 30%,
        var(--brass-400) 50%,
        var(--brass-500) 70%,
        transparent
    );
    opacity: 0;
    transition: opacity var(--transition-base);
}

.technical-group-card:hover {
    border-color: var(--steel-600);
    box-shadow: var(--shadow-lg);
}

.technical-group-card:hover::before {
    opacity: 0.6;
}

/* ─────────────────────────────────────────────────────────────────────
   Technical Group Name (Header)
   ───────────────────────────────────────────────────────────────────── */
.technical-group-name {
    font-family: var(--font-display);
    color: var(--brass-400);
    font-size: 1.125rem;
    margin-bottom: 1.25rem;
    text-align: center;
    letter-spacing: 0.02em;
    position: relative;
    padding-bottom: 0.75rem;
}

.technical-group-name::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40%;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        var(--steel-600),
        transparent
    );
}

/* ─────────────────────────────────────────────────────────────────────
   Labels & Values
   ───────────────────────────────────────────────────────────────────── */
.technical-group-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--steel-400);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.technical-group-text {
    color: var(--steel-200);
    font-size: 0.9375rem;
}

.technical-group-value {
    font-family: var(--font-mono);
    color: var(--steel-100);
    font-size: 0.9375rem;
    display: block;
    text-align: right;
}

/* Highlight important values */
.technical-group-value--highlight {
    color: var(--brass-400);
    font-weight: 500;
}

/* ─────────────────────────────────────────────────────────────────────
   Empty State
   ───────────────────────────────────────────────────────────────────── */
.technical-groups-empty {
    color: var(--steel-500);
    text-align: center;
    padding: 3rem 1.5rem;
    font-size: 1rem;
    font-style: italic;
}

/* ─────────────────────────────────────────────────────────────────────
   Technical Group Form Fields
   ───────────────────────────────────────────────────────────────────── */
.technical-group-field {
    background-color: var(--steel-850);
    border: 1px solid var(--steel-700);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: border-color var(--transition-fast);
}

.technical-group-field:hover {
    border-color: var(--steel-600);
}

.technical-group-field:focus-within {
    border-color: var(--brass-500);
}

/* ─────────────────────────────────────────────────────────────────────
   Technical Groups Grid Layout
   ───────────────────────────────────────────────────────────────────── */
.technical-groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

/* ─────────────────────────────────────────────────────────────────────
   State Indicators
   ───────────────────────────────────────────────────────────────────── */
.group-state-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.group-state-indicator--good {
    background-color: rgba(45, 125, 70, 0.15);
    color: #4CAF50;
    border: 1px solid rgba(45, 125, 70, 0.3);
}

.group-state-indicator--average {
    background-color: rgba(184, 134, 11, 0.15);
    color: var(--brass-400);
    border: 1px solid rgba(184, 134, 11, 0.3);
}

.group-state-indicator--poor {
    background-color: rgba(184, 59, 59, 0.15);
    color: #EF5350;
    border: 1px solid rgba(184, 59, 59, 0.3);
}

/* ─────────────────────────────────────────────────────────────────────
   Configuration Select - Optgroup Styling
   ───────────────────────────────────────────────────────────────────── */
.form-control optgroup {
    color: var(--brass-400);
    font-weight: 600;
    font-style: normal;
    padding-top: 0.5rem;
    background-color: var(--steel-900);
}

.form-control optgroup option {
    color: var(--steel-200);
    font-weight: 400;
    padding-left: 0.75rem;
    background-color: var(--steel-850);
}

/* ─────────────────────────────────────────────────────────────────────
   Technical Groups Edit Form
   ───────────────────────────────────────────────────────────────────── */
.repair-technical-groups-form-layout {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.repair-technical-groups-form {
    display: contents;
}

.repair-technical-groups-sync-action {
    display: inline-grid;
    justify-items: start;
    gap: 0.25rem;
}

.repair-technical-groups-coefficient-field {
    margin-left: auto;
    width: 6rem;
}

.repair-technical-groups-form-body {
    flex-basis: 100%;
    min-width: 0;
}

/* Small screens: stacked card layout */
.technical-groups-form-header {
    display: none;
}

.technical-groups-form-row {
    background-color: var(--steel-850);
    border: 1px solid var(--steel-700);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.technical-groups-form-row .tg-cell {
    margin-bottom: 0.75rem;
}

.technical-groups-form-row .tg-cell:last-child {
    margin-bottom: 0;
}

.technical-groups-add-action {
    margin-bottom: 1.5rem;
}

.repair-technical-groups-add-action {
    margin-bottom: 2rem;
}

.tire-inactive-input {
    background-color: var(--steel-900) !important;
    border-color: var(--steel-700) !important;
    color: var(--steel-400) !important;
    cursor: not-allowed;
}

.repair-scope-stack {
    display: grid;
    gap: 0.375rem;
}

.repair-scope-inline-label {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 0.25rem;
    margin: 0;
}

.repair-scope-inline-label > span {
    display: block;
    color: var(--steel-300);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

.repair-derived-value,
.repair-derived-inline-value {
    color: var(--steel-100);
    font-family: var(--font-mono);
    font-size: 0.9375rem;
    min-height: calc(1.5em + 0.75rem + 2px);
    display: flex;
    align-items: center;
}

.repair-derived-inline-value {
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

.repair-derived-inline-value > span {
    color: var(--steel-300);
    font-size: 0.75rem;
    font-weight: 600;
}

.repair-derived-inline-value > strong {
    font-weight: 500;
}

.repair-derived-inline-value-total {
    border-top: 1px solid var(--steel-700);
    color: var(--steel-300);
    margin-top: 0.25rem;
    min-height: auto;
    padding-top: 0.375rem;
}

.repair-derived-inline-value-total > strong {
    color: var(--steel-200);
}

/* Large screens: table layout */
@media (min-width: 992px) {
    /* The note is the field that needs space; the percentage stays compact. */
    .tg-expert-panel-fields {
        grid-template-columns: minmax(10rem, 16%) 1fr;
        align-items: start;
    }
}

@media (min-width: 992px) {
    .technical-groups-form-header .tg-header-cell {
        padding: 0.375rem 0.25rem;
        font-family: var(--font-mono);
        font-weight: 600;
        font-size: 0.75rem;
        color: var(--steel-400);
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    [data-nested-fields-target="list"] {
        display: table-row-group;
    }

    .technical-groups-form-row {
        background-color: transparent;
        border: none;
        border-radius: 0;
        padding: 0;
        margin-bottom: 0;
    }

    .tg-cell-actions {
        text-align: center;
    }

    .repair-technical-groups-form-table .repair-scope-inline-label {
        display: block;
        position: relative;
    }

    .repair-technical-groups-form-table .repair-scope-inline-label + .repair-scope-inline-label {
        margin-top: 0.75rem;
    }

    .repair-technical-groups-form-table .repair-scope-inline-label > span {
        position: absolute;
        bottom: calc(100% + 0.125rem);
        left: 0;
        pointer-events: none;
    }
}

/* ─────────────────────────────────────────────────────────────────────
   Tire assessment detail (Pneumatiky)
   ───────────────────────────────────────────────────────────────────── */
.tire-detail {
    display: block;
    width: 100%;
    background-color: var(--steel-850);
    border: 1px solid var(--steel-700);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 0 0 1rem;
}

.tire-detail-title {
    align-items: center;
    display: flex;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--steel-300);
    margin-bottom: 0.75rem;
}

.tire-detail-mode {
    align-items: baseline;
    border-bottom: 1px solid var(--steel-700);
    color: var(--steel-400);
    display: flex;
    font-size: 0.8125rem;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
}

.tire-detail-mode strong {
    color: var(--steel-100);
    font-weight: 600;
}

.tire-detail-fields {
    align-items: end;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

.tire-detail-field {
    display: grid;
    align-content: end;
}

.tire-detail-field .form-label {
    font-size: 0.8125rem;
    color: var(--steel-300);
    margin-bottom: 0.25rem;
}

.tire-assessment-mode {
    color: var(--steel-400);
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}

/* ─────────────────────────────────────────────────────────────────────
   Responsive
   ───────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .technical-groups-grid {
        grid-template-columns: 1fr;
    }

    .technical-group-card {
        padding: 1rem;
    }
}

/* ─── B.12 expert-determined technical state ─────────────────────
   A row whose ZA exceeds 100 % carries a percentage plus a free-text
   evidence note, which do not fit the compact column model. On desktop
   the row switches from a table-row to a grid using the SAME column
   proportions, so it stays aligned with the header, and the panel spans
   the full width beneath it — giving the note room to write in. */
.tg-expert-panels {
    margin-top: 1rem;
    display: grid;
    gap: 0.75rem;
}

.tg-expert-panel-title {
    color: var(--text-primary);
}

.tg-expert-panel {
    border: 1px solid rgba(212, 160, 23, 0.28);
    border-radius: var(--radius-md);
    background: rgba(212, 160, 23, 0.06);
    padding: 0.75rem 0.875rem;
    margin-top: 0.5rem;
}

.tg-expert-panel-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.625rem;
}

.tg-expert-panel-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.tg-expert-panel .form-label {
    margin-bottom: 0.25rem;
}

.tg-expert-panel textarea.form-control,
.modal textarea[name$="[expert_state_justification]"] {
    min-height: 0;
    resize: vertical;
}

[data-theme="light"] .tg-expert-panel {
    border-color: rgba(180, 134, 11, 0.30);
    background: rgba(212, 160, 23, 0.08);
}


/* A group owns its input row, optional note, and tire details at every breakpoint. */
.technical-groups-form-table > [data-nested-fields-target="list"] {
    display: block;
}

.technical-group-fields {
    margin-bottom: 1rem;
}

.technical-group-fields > .technical-groups-form-row {
    margin-bottom: 0;
}

/* The B.12 evidence note lives in a per-row modal; the row only carries a toggle tucked into the
   right edge of the manual-state input, so the column keeps its full width at every breakpoint.
   Outlined = note empty, filled = note written: the appraiser sees which rows carry evidence. */
.tg-expert-input {
    position: relative;
}

.tg-expert-input .form-control {
    padding-right: 2.25rem;
}

.tg-expert-note-toggle {
    position: absolute;
    top: 50%;
    right: 0.375rem;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.625rem;
    height: 1.625rem;
    padding: 0;
    border: 1px solid var(--brass-400);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--brass-300);
    font-size: 0.8125rem;
    line-height: 1;
    cursor: pointer;
}

.tg-expert-note-toggle:hover,
.tg-expert-note-toggle:focus-visible {
    background: rgba(212, 160, 23, 0.18);
    outline: none;
}

.tg-expert-note-toggle.has-note {
    background: var(--brass-400);
    color: var(--steel-950);
}

.tg-expert-note-toggle.has-note:hover,
.tg-expert-note-toggle.has-note:focus-visible {
    background: var(--brass-300);
}

.tg-expert-note-toggle[hidden] {
    display: none;
}

.tg-expert-note-group {
    color: var(--brass-300);
}

[data-theme="light"] .tg-expert-note-toggle {
    border-color: var(--brass-500);
    color: #8a6708;
}

[data-theme="light"] .tg-expert-note-toggle.has-note {
    background: var(--brass-500);
    color: #fff;
}

[data-theme="light"] .tg-expert-note-toggle.has-note:hover,
[data-theme="light"] .tg-expert-note-toggle.has-note:focus-visible {
    background: var(--brass-600);
}

[data-theme="light"] .tg-expert-note-group {
    color: #8a6708;
}

.technical-group-fields > .tire-detail {
    margin-top: 0.75rem;
}

.expert-state-note {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 0.875rem;
    color: var(--steel-400);
}

@media (min-width: 992px) {
    .technical-groups-form-table {
        display: block;
        --tg-columns: minmax(7rem, 1.8fr) repeat(3, minmax(3.5rem, 0.65fr))
            minmax(4.5rem, 0.9fr) minmax(8rem, 1.2fr) minmax(5rem, 1fr) 3.5rem;
    }

    .repair-technical-groups-form-table {
        --tg-columns: minmax(7rem, 1.5fr) repeat(3, minmax(3rem, 0.65fr))
            minmax(4rem, 0.85fr) minmax(8rem, 1.2fr) minmax(5rem, 1fr)
            repeat(2, minmax(3rem, 0.65fr)) 3.5rem;
    }

    .technical-groups-form-table > .technical-groups-form-header,
    .technical-group-fields > .technical-groups-form-row {
        display: grid;
        grid-template-columns: var(--tg-columns);
        gap: 0.5rem;
        align-items: start;
    }

    .technical-groups-form-table .tg-cell,
    .technical-groups-form-table .tg-header-cell {
        display: block;
        width: auto;
        min-width: 0;
        padding: 0.25rem 0;
        overflow-wrap: anywhere;
    }

    .technical-groups-form-table .form-control {
        min-width: 0;
        width: 100%;
    }
}

/* ─── Page notices (ZAVmax_n / PRKMmax_n caps, ZA above 100 %) ─────────
   Louder than .readiness-advisory on purpose: the appraiser has to notice these before editing
   the rows below, so the block takes the brass warning accent, a heavy left rule and a glow. */
.tg-notices {
    border: 1px solid rgba(212, 160, 23, 0.55);
    border-left: 5px solid var(--brass-400);
    border-radius: var(--radius-lg);
    background:
        linear-gradient(135deg, rgba(212, 160, 23, 0.20), rgba(184, 134, 11, 0.08)),
        rgba(24, 28, 34, 0.96);
    box-shadow: var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    padding: 1.125rem 1.375rem;
}

.tg-notices .readiness-notice-header {
    color: var(--brass-300);
    font-size: 1.0625rem;
    letter-spacing: 0.01em;
    margin-bottom: 0.75rem;
}

.tg-notices .readiness-notice-header .bi {
    font-size: 1.25rem;
}

.tg-notices .readiness-notice-list {
    font-size: 1rem;
    line-height: 1.65;
}

.tg-notices .readiness-notice-list li + li {
    margin-top: 0.5rem;
}

[data-theme="light"] .tg-notices {
    background:
        linear-gradient(135deg, rgba(212, 160, 23, 0.18), rgba(184, 134, 11, 0.06)),
        rgba(255, 251, 240, 0.96);
    border-color: rgba(184, 134, 11, 0.55);
    border-left-color: var(--brass-500);
    box-shadow: var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

[data-theme="light"] .tg-notices .readiness-notice-header {
    color: #7a5608;
}

/* Compact stand-in for the notice block while it is scrolled out of view (see
   technical_groups_preview_controller.js); fixed under the section action bar. */
.tg-notices-bar {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1019;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    max-width: calc(100vw - 2rem);
    padding: 0.5rem 1rem;
    border: 1px solid rgba(212, 160, 23, 0.7);
    border-left: 4px solid var(--brass-400);
    border-radius: var(--radius-md);
    background: rgba(40, 34, 18, 0.97);
    color: var(--brass-300);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    cursor: pointer;
}

.tg-notices-bar[hidden] {
    display: none;
}

.tg-notices-bar-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tg-notices-bar-action {
    text-decoration: underline;
    text-underline-offset: 0.15em;
    white-space: nowrap;
}

.tg-notices-bar:hover,
.tg-notices-bar:focus-visible {
    background: rgba(56, 47, 22, 0.98);
    outline: 2px solid var(--brass-300);
    outline-offset: 2px;
}

.tg-notices-bar.is-new {
    animation: tg-notices-bar-pulse 1.2s ease-out 2;
}

@keyframes tg-notices-bar-pulse {
    0%   { box-shadow: var(--shadow-lg), 0 0 0 0 rgba(212, 160, 23, 0.6); }
    100% { box-shadow: var(--shadow-lg), 0 0 0 14px rgba(212, 160, 23, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .tg-notices-bar.is-new {
        animation: none;
    }
}

[data-theme="light"] .tg-notices-bar {
    background: rgba(255, 248, 225, 0.98);
    color: #7a5608;
    border-color: rgba(184, 134, 11, 0.6);
    border-left-color: var(--brass-500);
}

[data-theme="light"] .tg-notices-bar:hover,
[data-theme="light"] .tg-notices-bar:focus-visible {
    background: rgba(255, 243, 205, 1);
}

/* Row marker: the group named by a notice gets a brass rule and a badge next to its name. */
.technical-group-fields.tg-row-flagged > .technical-groups-form-row {
    box-shadow: inset 4px 0 0 var(--brass-400);
    padding-left: 0.5rem;
}

.tg-row-flag {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    margin-left: 0.5rem;
    color: var(--brass-300);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: help;
}

.tg-row-flag[hidden] {
    display: none;
}

[data-theme="light"] .tg-row-flag {
    color: #7a5608;
}
