/* Keep controls readable and dialogs usable across phone and tablet screens. */
@supports (overflow: clip) {
    html, body {
        overflow-x: clip;
        overflow-y: visible;
    }
}

.workflow-rule-toggle {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 8px 0;
    cursor: pointer;
}

.workflow-rule-toggle .form-check-input {
    float: none;
    width: 20px;
    height: 20px;
    min-height: 20px;
    margin: 0;
}

.workflow-status-card {
    margin-block: 12px;
    border: 1px solid var(--stroke);
    border-radius: 14px;
    background: rgba(6, 31, 42, .35);
}

.workflow-status-card > summary,
.workflow-rule-group > summary {
    min-height: 48px;
    padding: 12px;
    cursor: pointer;
    overflow-wrap: anywhere;
}

.workflow-status-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-inline: 6px 8px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .4);
}

.workflow-status-caption {
    display: block;
    margin: 4px 0 0 32px;
    color: var(--text-soft);
    font-size: .85rem;
}

.workflow-status-body {
    padding: 16px;
    border-top: 1px solid var(--stroke);
}

.workflow-rule-options {
    padding: 0 12px 8px;
}

.issue-status-picker {
    display: grid;
    gap: 12px;
}

.device-location-value {
    overflow-wrap: anywhere;
    line-height: 1.5;
}

.device-location-value a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding-block: 8px;
}

.modal .btn-close {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    margin: 0;
    background-size: 14px;
}

.modal .modal-title {
    min-width: 0;
    overflow-wrap: anywhere;
}

@media screen and (max-width: 767.98px) {
    html {
        scroll-padding-top: 88px;
        scroll-padding-bottom: 124px;
    }

    input[type="checkbox"],
    input[type="radio"] {
        min-height: 0;
    }

    input[type="checkbox"].form-check-input,
    input[type="radio"].form-check-input {
        width: 20px;
        height: 20px;
    }

    .form-switch .form-check-input {
        width: 40px !important;
    }

    .form-check {
        min-height: 44px;
        padding-block: 8px;
    }

    .form-check-label,
    label.section-card {
        cursor: pointer;
    }

    .app-navbar .app-notification-btn,
    .btn.btn-sm,
    .settings-tab,
    .table-menu-option {
        min-height: 44px;
    }

    .modal-dialog {
        margin: 8px;
    }

    .modal-content {
        display: flex;
        flex-direction: column;
        max-height: calc(100dvh - 16px);
        overflow: hidden;
        padding: 0 !important;
    }

    .modal-header,
    .modal-footer {
        flex: 0 0 auto;
        padding: 12px 16px;
    }

    .modal-body {
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding: 16px;
    }

    .modal-footer {
        display: grid;
        grid-template-columns: 1fr 1fr;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .modal-footer > .btn {
        width: 100%;
        margin: 0;
    }

    .workflow-save-bar {
        position: sticky;
        bottom: max(8px, env(safe-area-inset-bottom));
        margin-inline: 0;
    }

    .workflow-save-actions {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        width: 100%;
    }

    .workflow-save-actions .btn {
        min-width: 0;
        padding-inline: 12px !important;
        white-space: normal;
    }

    .issue-detail-actions {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        width: 100%;
    }

    .issue-detail-actions .btn {
        min-width: 0;
        white-space: normal;
    }

    .issue-detail-actions .btn:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .create-hero-actions {
        flex-wrap: wrap;
    }

    .create-hero-actions .btn {
        width: auto;
    }

    .workflow-status-body {
        padding: 12px;
    }

    .workflow-status-body .row {
        --bs-gutter-y: .5rem;
    }

    .workflow-status-body label {
        margin-bottom: 8px !important;
    }

    .workflow-field-header {
        flex-direction: column;
        align-items: stretch;
    }

    .workflow-field-summary {
        flex: 0 0 auto;
        width: 100%;
        min-height: 44px;
        grid-template-columns: 28px minmax(0, 1fr) 16px;
    }

    .workflow-field-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .workflow-field-actions .btn,
    .sortable-th-button {
        min-width: 44px;
        min-height: 44px;
    }

    .workflow-field-heading strong {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }

    .workflow-save-bar::before {
        display: none;
    }

    a.mobile-card {
        display: block;
        text-decoration: none;
        color: inherit;
    }
}

@media screen and (min-width: 360px) and (max-width: 767.98px) {
    .stats-grid,
    .workflow-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media print {
    html, body {
        overflow: visible !important;
    }
    body {
        position: static !important;
        top: auto !important;
        width: auto !important;
    }
}
