/**
 * Visual Inspection modal — mobile-first responsive layout.
 */

.vi-modal .modal-dialog {
    width: calc(100% - 12px);
    max-width: 1100px;
    margin: 6px auto;
}

.vi-modal .modal-content {
    border: none;
    border-radius: 0;
    overflow: hidden;
}

.vi-modal .modal-body {
    padding: 0 !important;
}

.vi-root {
    --vi-blue: #337ab7;
    --vi-blue-light: #5bc0de;
    --vi-border: #c8c8c8;
    --vi-tap: 44px;
    --vi-tile-h: 120px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 24px);
    background: #fff;
}

/* Header */
.vi-root .vi-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 10px 44px;
    background: var(--vi-blue);
    color: #fff;
    flex-shrink: 0;
}

.vi-root .vi-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
}

.vi-root .vi-close {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    padding: 4px 8px;
    cursor: pointer;
    opacity: 0.95;
}

.vi-root .vi-close:hover,
.vi-root .vi-close:focus {
    opacity: 1;
    outline: none;
}

/* Body */
.vi-root .vi-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 10px 12px 8px;
}

.vi-root .vi-toolbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.vi-root .vi-link {
    border: none;
    background: transparent;
    color: #333;
    font-size: 13px;
    padding: 6px 0;
    text-align: left;
    cursor: pointer;
    min-height: var(--vi-tap);
    line-height: 1.3;
}

.vi-root .vi-link--center {
    text-align: center;
    justify-self: center;
}

.vi-root .vi-help {
    border: none;
    background: transparent;
    color: var(--vi-blue);
    font-size: 26px;
    line-height: 1;
    padding: 4px;
    cursor: pointer;
    min-width: var(--vi-tap);
    min-height: var(--vi-tap);
    justify-self: end;
}

.vi-root .vi-instruct-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.vi-root .vi-instruct {
    flex: 1 1 220px;
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
    color: #333;
}

.vi-root .vi-clear {
    flex: 0 0 auto;
    border: none;
    border-radius: 0;
    background: var(--vi-blue-light);
    color: #fff;
    font-size: 14px;
    padding: 6px 14px;
    min-height: 36px;
    cursor: pointer;
    white-space: nowrap;
}

.vi-root .vi-clear i {
    margin-right: 4px;
}

/* Status legend */
.vi-root .vi-legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 10px;
}

.vi-root .vi-legend-btn {
    border: 1px solid var(--vi-border);
    border-radius: 0;
    font-size: 13px;
    font-weight: 600;
    min-height: 38px;
    padding: 6px 8px;
    cursor: default;
    text-align: center;
    line-height: 1.2;
}

.vi-root .vi-legend-btn--white {
    background: #fff;
    color: #111;
}

.vi-root .vi-legend-btn--green {
    background: #28a745;
    color: #fff;
    border-color: #28a745;
}

.vi-root .vi-legend-btn--yellow {
    background: #ffc107;
    color: #111;
    border-color: #e0a800;
}

.vi-root .vi-legend-btn--red {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
}

/* Inspection grid */
.vi-root .vi-grid-wrap {
    height: min(42vh, 380px);
    min-height: 180px;
    border: 1px solid var(--vi-border);
    overflow: hidden;
    background: #fff;
}

.vi-root .vi-grid {
    width: 100% !important;
    height: 100% !important;
}

.vi-root .ui-grid-header {
    display: none !important;
}

.vi-root .ui-grid-filter-container {
    display: none !important;
}

.vi-root .ui-grid-row,
.vi-root .ui-grid-cell,
.vi-root #visualInspectionGrid .ui-grid-row,
.vi-root #visualInspectionGrid .ui-grid-cell {
    height: var(--vi-tile-h) !important;
    min-height: var(--vi-tile-h) !important;
}

.vi-root .ui-grid-cell-contents {
    height: 100% !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    padding: 8px 10px !important;
    font-size: 14px !important;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
    box-sizing: border-box;
    white-space: normal;
    word-break: break-word;
}

.vi-root .ui-grid-cell.white,
.vi-root .ui-grid-cell.white .ui-grid-cell-contents {
    background: #fff !important;
    color: #111 !important;
    border: 1px solid #ddd;
}

.vi-root .ui-grid-cell.green,
.vi-root .ui-grid-cell.green .ui-grid-cell-contents {
    background: #28a745 !important;
    color: #fff !important;
    border: 1px solid #1e7e34;
}

.vi-root .ui-grid-cell.yellow,
.vi-root .ui-grid-cell.yellow .ui-grid-cell-contents {
    background: #ffc107 !important;
    color: #111 !important;
    border: 1px solid #e0a800;
}

.vi-root .ui-grid-cell.red,
.vi-root .ui-grid-cell.red .ui-grid-cell-contents {
    background: #dc3545 !important;
    color: #fff !important;
    border: 1px solid #bd2130;
}

.vi-root .ui-grid-viewport {
    overflow: auto !important;
}

/* Footer */
.vi-root .vi-footer {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: 1px solid #e5e5e5;
    background: #fafafa;
}

.vi-root .vi-action {
    border: none;
    border-radius: 0;
    background: var(--vi-blue-light);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    min-height: var(--vi-tap);
    padding: 8px 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.vi-root .vi-action i {
    font-size: 16px;
}

/* Tablet+ */
@media (min-width: 576px) {
    .vi-root .vi-legend {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .vi-root .vi-footer {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 768px) {
    .vi-modal .modal-dialog {
        width: 85%;
        margin: 20px auto;
    }

    .vi-root .vi-title {
        font-size: 25px;
    }

    .vi-root .vi-body {
        padding: 12px 16px 10px;
    }

    .vi-root {
        --vi-tile-h: 140px;
    }

    .vi-root .vi-grid-wrap {
        height: min(50vh, 440px);
        min-height: 280px;
    }

    .vi-root .vi-toolbar {
        grid-template-columns: minmax(60px, auto) 1fr minmax(44px, auto);
    }
}

@media (min-width: 992px) {
    .vi-root {
        --vi-tile-h: 150px;
    }

    .vi-root .vi-grid-wrap {
        height: min(52vh, 480px);
    }
}
