/* ============================================================
   Admin layout/table fixes for review items #1, #3, #4, #6, #7.
   Loaded last (after the page-specific stylesheets) so these rules win.
   ============================================================ */

/* #4 — the page itself must not scroll; only the list area scrolls.
   The shell becomes a flex column that exactly fills #main-content, and the
   list body is the single scroll container. Replaces the old fixed
   height: calc(100vh - 170px) magic number on .page_body. */
#main-content
{
    display: flex;
    min-height: 0;
}

.page_main
{
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.page_body
{
    flex: 1;
    min-height: 0;
    height: auto;
}

/* The list table area scrolls internally instead of growing the page. */
.page_main_list_body
{
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

/* #3 — header (thead) and body (tbody) columns must share the same widths.
   Fixed layout makes the header cell widths drive every row, so columns line up. */
table.page_main_list
{
    table-layout: fixed;
    width: 100%;
}

table.page_main_list tbody td.page_main_list_item-col
{
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* #6 — reference tables (brands / models / groups / companies) span the full
   width like the Machines table, instead of the narrow short_body width. */
.page_body.short_body
{
    max-width: none;
}

/* #1 — empty-state caption centered across the whole list width. */
.emptyListText
{
    display: block;
    width: 100%;
    text-align: center;
}

/* #7 — template create/edit form: selects align with text inputs
   (label above, full-width control) so the grid no longer "walks".
   Scoped to single-page field wrappers so stage-builder selects are untouched. */
.single_page--field-wrap .select-field,
.single_page--field-wrap .select-field.d-flex
{
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
}

.single_page--field-wrap .select-field-label
{
    padding-left: 16px;
    margin-bottom: 4px;
    font-family: var(--font-family);
    font-weight: 400;
    font-size: 13px;
    line-height: 123%;
    color: var(--gray-medium);
}

.single_page--field-wrap .select-field > *:not(.select-field-label)
{
    width: 100%;
}

/* Dropdown control padding must equal the text-input padding so selects and inputs line up. */
.single_page--field-wrap .react-select__value-container
{
    padding: 4px 8px 4px 0px;
}

/* Two-column field row: even halves with a consistent gap. */
.single_page--field-wrap.single_page--field-2
{
    gap: 16px;
}

.single_page--field-wrap.single_page--field-2 > *
{
    width: 50%;
}

/* Column header titles left-aligned (th defaults to center, which looked off). */
table.page_main_list thead th,
table.page_main_list thead th .page_main_list_sort-col
{
    text-align: left;
    justify-content: flex-start;
}

/* Sort-direction arrow vertically centered with the column label
   (the label+svg sat at the top because the container was not a flex row). */
.page_main_list_sort-col
{
    display: inline-flex;
    align-items: center;
}

.page_main_list_sort-col svg
{
    flex-shrink: 0;
}

/* ZSelect: the selected value had no explicit colour/font, so it inherited and
   blended into the background. Give it the same look as text inputs/options. */
.react-select__single-value
{
    color: var(--gray-dark);
    font-family: var(--font-family);
    font-weight: 400;
    font-size: 14px;
    line-height: 171%;
}

.react-select__control
{
    padding: 4px 8px 4px 0px;
}

/* Align ZSelect controls with text inputs: identical box (border, padding,
   height, full width, no offset) so their left edges line up everywhere. */
.react-select-container
{
    width: 100%;
    margin: 0;
}

.react-select__control
{
    box-sizing: border-box;
    width: 100%;
    min-height: 42px;
    margin: 0;
    border: 1px solid var(--gray-border);
    padding: 4px 8px 4px 16px;
}

/* The dropdown arrow SVG is authored at 40x40, which made the control taller
   than text inputs. Constrain it so the control height matches the inputs (42px). */
.react-select__indicator svg
{
    width: 20px;
    height: 20px;
    display: block;
}

.react-select__indicators
{
    flex-shrink: 0;
}

/* Force inputs and selects to the exact same control height in form rows. */
.single_page--field-wrap .single_page_field-input,
.single_page--field-wrap .react-select__control,
.single_page--field-wrap .react-select-container
{
    height: 42px;
    min-height: 42px;
    box-sizing: border-box;
}

/* perpage.css sets `div.react-select__control` border to --gray-light, which (being
   more specific than `.react-select__control`) leaked to every select. Match inputs. */
div.react-select__control
{
    border: 1px solid var(--gray-border);
}

div.react-select__control:hover
{
    border-color: var(--gray-border);
}

/* Audit server-info row: the `padding-20` class matches no rule, so the block was
   flush against the edges. Give it real padding and roomier spacing between fields. */
.audit_server_info
{
    padding: 24px;
    gap: 20px 56px;
    margin-bottom: 4px;
}

.audit_server_info .show_field-label
{
    margin-bottom: 6px;
}

/* Search field height matches the 42px selects/inputs (was 40px). */
.search_form-field
{
    height: 42px;
}

/* Full audit message inside the detail modal: wrap instead of truncating. */
.audit_message_full
{
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 220px;
    overflow-y: auto;
}

/* "Missing in Cropio" badge for rotation-flagged entities. */
.cropio_badge
{
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 10px;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 11px;
    line-height: 16px;
    white-space: nowrap;
    vertical-align: middle;
}

.cropio_badge--missing
{
    background: rgba(185, 47, 28, 0.12);
    color: var(--red-alert);
}

.cropio_badge--active
{
    background: rgba(121, 172, 74, 0.15);
    color: var(--green-hover);
}

/* Login (and other forms): cap a long error message so it scrolls instead of
   blowing the modal off-screen; wrap unbreakable strings. */
.form_error_notify
{
    max-height: 160px;
    overflow-y: auto;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Settings page: save buttons should be compact (not full width) and have breathing room. */
.settings_page .single_page-data-bottom
{
    margin-top: 24px;
    margin-bottom: 8px;
}

.settings_page .single-page-button
{
    width: auto;
    min-width: 200px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Machines list: dedicated status column; trim the user column to make room. */
.machines_list_body .page_main_list_item-col-text.status
{
    width: 14%;
}

.machines_list_body .page_main_list_item-col-text.user
{
    width: 18%;
}

/* In a dedicated column the badge needs no left gap. */
.page_main_list_item-col-text.status .cropio_badge
{
    margin-left: 0;
}

/* Filter popups (machines + maintenance) can be taller than the viewport, hiding the
   "Применить" button. Cap the height with scroll and pin the buttons to the bottom. */
.filter_body
{
    max-height: min(650px, calc(100vh - 100px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Only the filter items scroll; the buttons sit outside the scroll area. */
.filter_body .filter_items
{
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.filter_body_buttons
{
    flex-shrink: 0;
    background: var(--white);
    padding-top: 8px;
    box-shadow: 0 -8px 8px -8px rgba(46, 46, 45, 0.12);
}

/* Users list: make room for the status column. */
.users_list_body .page_main_list_item-col-text.role
{
    width: 18%;
}

.users_list_body .page_main_list_item-col-text.status
{
    width: 14%;
}

/* Duplicates page: grouped cards. */
.duplicate_group
{
    background: var(--white);
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--gray-border);
}

.duplicate_group-title
{
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 15px;
    color: var(--green-dark);
    margin-bottom: 8px;
}

.duplicate_group-count
{
    margin-left: 8px;
    color: var(--gray);
    font-weight: 400;
    font-size: 13px;
}

.duplicate_item
{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-top: 1px solid var(--gray-background);
}

.duplicate_item-info
{
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 16px;
    min-width: 0;
}

.duplicate_item-title
{
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 14px;
    color: var(--gray-dark);
}

.duplicate_item-meta
{
    font-family: var(--font-family);
    font-size: 12px;
    color: var(--gray);
}

.duplicate_item-actions
{
    flex-shrink: 0;
}

/* Uniform header height (60px) for every list table. */
table.page_main_list thead th
{
    height: 60px;
    vertical-align: middle;
}

/* Settings hub: pages hosted inside the tabs render compactly — small subtitle, no second
   header bar and no double padding (the Settings page body already provides spacing). */
.tabs_panel .page_main
{
    padding: 0;
    height: auto;
}

.tabs_panel .page_main_top
{
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    min-height: 0;
}

/* Match the look of .content_title used by the inline "Пороги ТО" tab. */
.tabs_panel .page_title
{
    font-size: 16px;
    font-weight: 600;
    line-height: 150%;
    color: var(--green-dark);
}

.tabs_panel .page_body
{
    margin-top: 16px;
    padding: 0 !important;
    height: auto;
    overflow: visible;
}
