/* Adapters for legacy pages. Load after huolto-ui.css.
 * Preserve input names, IDs and workflow state colours in page templates.
 */
body.huolto-ui.huolto-legacy {
    /* header.inc sets the body background inline. */
    background-color: var(--huolto-background) !important;
}

/* Common surface used throughout the older PHP pages. */
.huolto-legacy.huolto-ui .box-shadow {
    border: 1px solid var(--huolto-border);
    box-shadow: var(--huolto-shadow);
}
.huolto-legacy.huolto-ui .box-shadow.rounded {
    /* Bootstrap's .rounded utility also uses !important. */
    border-radius: var(--huolto-radius) !important;
}

/* Older forms also contain native fields without Bootstrap classes.
 * Leave their width/size and inline state colours under page control.
 */
.huolto-legacy.huolto-ui input:is([type="text"], [type="search"], [type="password"], [type="email"], [type="tel"], [type="url"], [type="number"], [type="date"], [type="time"]):not(.form-control),
.huolto-legacy.huolto-ui select:not(.form-control):not(.form-select),
.huolto-legacy.huolto-ui textarea:not(.form-control) {
    box-sizing: border-box;
    max-width: 100%;
    min-width: 0;
    min-height: 2rem;
    padding: .3rem .5rem;
    border: 1px solid var(--huolto-border);
    border-radius: var(--huolto-radius);
    background-color: var(--huolto-surface);
    color: var(--huolto-text);
    font-family: var(--huolto-font);
}

.huolto-legacy.huolto-ui input:is([type="button"], [type="submit"], [type="reset"]):not(.btn),
.huolto-legacy.huolto-ui button:not([class]) {
    box-sizing: border-box;
    max-width: 100%;
    min-height: 2rem;
    padding: .3rem .625rem;
    border: 1px solid var(--huolto-border);
    border-radius: var(--huolto-radius);
    background-color: var(--huolto-surface);
    color: var(--huolto-text);
    font: 600 .875rem/1.4 var(--huolto-font);
    cursor: pointer;
}

.huolto-legacy.huolto-ui .media-body { min-width: 0; overflow-wrap: anywhere; }
.huolto-legacy.huolto-ui .varasto-tile { min-width: 0; overflow-wrap: anywhere; }

.huolto-legacy.huolto-ui .huolto-page.huolto-order,
.huolto-legacy.huolto-ui .huolto-page.huolto-cleaning-list {
    width: calc(100% - 2.5rem);
    padding: 1.5rem;
    border: 1px solid var(--huolto-border);
    border-radius: var(--huolto-radius);
    background: var(--huolto-surface);
    box-shadow: var(--huolto-shadow);
}

.huolto-legacy.huolto-ui .huolto-order-header {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--huolto-border);
}

.huolto-legacy.huolto-ui .huolto-order-kind {
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.huolto-legacy.huolto-ui .huolto-code-access {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}
.huolto-legacy.huolto-ui .huolto-code-access .huolto-label { width: 100%; margin: 0; }
.huolto-legacy.huolto-ui .huolto-code-field { width: 6.25rem; }

.huolto-legacy.huolto-ui .huolto-order .row > :is(.col-5, .col-7) {
    margin-bottom: .625rem;
    overflow-wrap: anywhere;
}

.huolto-legacy.huolto-ui .huolto-order .row > .col-5 { color: var(--huolto-muted); }

/* Long cabin names must shrink inside the legacy media layout on phones. */
.huolto-legacy.huolto-ui .huolto-cleaning-list .media-body {
    min-width: 0;
    overflow-wrap: anywhere;
}

.huolto-legacy.huolto-ui .huolto-checklist {
    width: 100%;
    margin-bottom: 1.5rem;
}

.huolto-legacy.huolto-ui .huolto-checklist .checkbox-wrapper-34 {
    padding: .75rem;
    border: 1px solid var(--huolto-border);
    border-radius: var(--huolto-radius);
    background: var(--huolto-surface-soft);
    overflow-wrap: anywhere;
}

.huolto-legacy.huolto-ui .huolto-checklist .checkbox-wrapper-34 + .checkbox-wrapper-34 {
    margin-top: .5rem;
}

.huolto-legacy.huolto-ui .huolto-task-clock {
    min-height: 2rem;
    padding: .3rem .625rem;
    border: 0;
    border-radius: var(--huolto-radius);
    color: #fff;
    font: 600 .8125rem/1.4 var(--huolto-font);
    cursor: pointer;
}

.huolto-legacy.huolto-ui .huolto-order-clock {
    min-height: 3.5rem;
    width: 100%;
}

.huolto-legacy.huolto-ui .huolto-comments { width: 100%; margin-bottom: 1.5rem; }
.huolto-legacy.huolto-ui .huolto-comments > .huolto-comment { margin-bottom: .75rem; }
.huolto-legacy.huolto-ui .huolto-comments .huolto-comment-meta { font-size: .8125rem; }

.huolto-legacy.huolto-ui .huolto-form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem;
    margin: 1.5rem 0;
    padding-top: 1rem;
    border-top: 1px solid var(--huolto-border);
}

/* Chosen and jQuery UI dialogs remain on their existing JavaScript plugins. */
.huolto-legacy.huolto-ui .chosen-container { max-width: 100%; }
.huolto-legacy.huolto-ui .chosen-container-single .chosen-single {
    height: auto;
    min-height: 2.5rem;
    padding: .5rem .75rem;
    border-color: var(--huolto-border);
    border-radius: var(--huolto-radius);
    background: var(--huolto-surface);
    box-shadow: none;
    color: var(--huolto-text);
    line-height: 1.4;
}
.huolto-legacy.huolto-ui .chosen-container-single .chosen-single div b { background-position-y: 10px; }
.huolto-legacy.huolto-ui .chosen-container-active .chosen-single {
    outline: 3px solid #2872c3;
    outline-offset: 2px;
}
.huolto-legacy.huolto-ui .ui-dialog {
    box-sizing: border-box;
    max-width: calc(100vw - 1.5rem);
    border: 1px solid var(--huolto-border);
    border-radius: var(--huolto-radius);
    box-shadow: var(--huolto-shadow);
    font-family: var(--huolto-font);
}
.huolto-legacy.huolto-ui .ui-dialog .ui-dialog-titlebar {
    border: 0;
    background: var(--huolto-surface-soft);
    color: var(--huolto-text);
}
.huolto-legacy.huolto-ui .ui-dialog .ui-dialog-content { overflow: auto; }

@media (max-width: 575.98px) {
    .huolto-legacy.huolto-ui .huolto-page.huolto-order,
    .huolto-legacy.huolto-ui .huolto-page.huolto-cleaning-list {
        width: calc(100% - 1.5rem);
        padding: 1rem;
    }
    .huolto-legacy.huolto-ui .huolto-form-actions > .btn { flex: 1 1 auto; }
}

@media print {
    body.huolto-legacy.huolto-ui { background-color: #fff !important; }
    .huolto-legacy.huolto-ui .huolto-page.huolto-order,
    .huolto-legacy.huolto-ui .huolto-page.huolto-cleaning-list {
        width: 100%;
        padding: 0;
        border: 0;
        box-shadow: none;
    }
    .huolto-legacy.huolto-ui :is(.huolto-order-clock, .huolto-task-clock, .huolto-form-actions) { display: none; }
}
