/*
 * Sleep radar quality report modal (scoped)
 * Reuses the comprehensive report structure with a cooler moonlight palette.
 */

.modal:has(table.sleep-quality-report-grid) {
    --scr-border: #d9def7;
    --scr-border-strong: #b9c2ef;
    --scr-bg: #f7f8ff;
    --scr-surface: #ffffff;
    --scr-title: #26305c;
    --scr-text: #243052;
    --scr-muted: #7a84a8;
    --scr-accent: #6574e8;
    --scr-accent-dark: #3d4dc0;
    --scr-gold: #c7a45d;
    --scr-blue: #19a7bb;
    --scr-shadow: 0 18px 42px rgba(54, 74, 148, 0.16);
}

.modal:has(table.sleep-quality-report-grid) .modal-content {
    border-color: var(--scr-border);
    background:
        radial-gradient(circle at 10% 0%, rgba(101, 116, 232, 0.16), transparent 30%),
        radial-gradient(circle at 92% 6%, rgba(25, 167, 187, 0.12), transparent 28%),
        linear-gradient(180deg, #f6f8ff 0%, #ffffff 64%);
    box-shadow: var(--scr-shadow);
}

.modal:has(table.sleep-quality-report-grid) .modal-content::before {
    background: linear-gradient(90deg, #4756d8 0%, #19a7bb 58%, #c7a45d 100%);
}

.modal:has(table.sleep-quality-report-grid) .modal-header {
    border-bottom-color: var(--scr-border);
    background:
        radial-gradient(circle at top right, rgba(199, 164, 93, 0.12), transparent 28%),
        linear-gradient(120deg, rgba(101, 116, 232, 0.14), rgba(255, 255, 255, 0.92) 52%, #fbfdff 100%);
}

.modal:has(table.sleep-quality-report-grid) .modal-title {
    color: var(--scr-title);
}

.modal:has(table.sleep-quality-report-grid) .modal-title::after {
    content: "Sleep Insight \00b7  Quality Analysis";
    color: var(--scr-muted);
}

.modal:has(table.sleep-quality-report-grid) .modal-header .close {
    border-color: #c6d0f4;
    color: #7780a5;
}

.modal:has(table.sleep-quality-report-grid) .modal-header .close:hover {
    border-color: #9fabeb;
    color: var(--scr-accent-dark);
}

.modal:has(table.sleep-quality-report-grid) .modal-body {
    scrollbar-color: rgba(88, 105, 204, 0.30) transparent;
}

.modal:has(table.sleep-quality-report-grid) .modal-body::-webkit-scrollbar-thumb {
    background: rgba(88, 105, 204, 0.28);
}

table.sleep-quality-report-grid > tbody > tr {
    grid-template-columns: 58px minmax(124px, 0.78fr) minmax(190px, 1.06fr) minmax(190px, 1.06fr) minmax(190px, 1.06fr) minmax(136px, 0.78fr);
    border-color: rgba(190, 199, 241, 0.86);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 249, 255, 0.96) 100%),
        #ffffff;
    box-shadow:
        0 16px 30px rgba(58, 74, 151, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.88);
}

table.sleep-quality-report-grid > tbody > tr::before {
    background: linear-gradient(180deg, #6574e8 0%, #19a7bb 62%, #c7a45d 100%);
}

table.sleep-quality-report-grid > tbody > tr:hover {
    box-shadow:
        0 20px 34px rgba(58, 74, 151, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

table.sleep-quality-report-grid > tbody > tr > td,
table.sleep-quality-report-grid > tbody > tr > td:first-child,
table.sleep-quality-report-grid > tbody > tr > td:last-child {
    background:
        radial-gradient(circle at 16% 0%, rgba(255, 255, 255, 0.95), transparent 42%),
        linear-gradient(145deg, rgba(255, 255, 255, 0.76), rgba(243, 246, 255, 0.66)) !important;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.84),
        inset 0 0 0 1px rgba(220, 225, 248, 0.78),
        0 10px 18px rgba(58, 74, 151, 0.06);
}

table.sleep-quality-report-grid > tbody > tr > td.sleep-report-col-time {
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.76), transparent 44%),
        linear-gradient(145deg, rgba(245, 247, 255, 0.94), rgba(255, 255, 255, 0.80)) !important;
}

table.sleep-quality-report-grid .sleep-report-index {
    border-color: #bdc7f3;
    background:
        radial-gradient(circle at 28% 20%, rgba(255, 255, 255, 0.54), transparent 32%),
        linear-gradient(180deg, #f3f5ff 0%, #e5e9ff 100%);
}

table.sleep-quality-report-grid .sleep-report-index strong {
    color: var(--scr-accent-dark);
}

table.sleep-quality-report-grid .sleep-report-pill {
    border-color: #c9d0f6;
    background: #f0f3ff;
    color: var(--scr-accent-dark);
}

table.sleep-quality-report-grid .sleep-quality-summary strong {
    color: #2f3fba;
    font-size: 24px;
    line-height: 1;
}

table.sleep-quality-report-grid .sleep-quality-summary strong:not(.sleep-quality-score-empty)::after {
    content: " 分";
    color: #8790b3;
    font-size: 11px;
    font-weight: 800;
}

table.sleep-quality-report-grid .sleep-report-metric {
    background:
        linear-gradient(115deg, rgba(255, 255, 255, 0.00) 0%, rgba(255, 255, 255, 0.62) 36%, rgba(255, 255, 255, 0.00) 62%),
        radial-gradient(circle at 92% 4%, rgba(101, 116, 232, 0.15), transparent 38%),
        linear-gradient(145deg, rgba(255, 255, 255, 0.84), rgba(243, 246, 255, 0.64));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.90),
        inset 0 -18px 32px rgba(255, 255, 255, 0.36),
        inset 0 0 0 1px rgba(210, 217, 247, 0.88),
        0 12px 22px rgba(58, 74, 151, 0.08);
}

table.sleep-quality-report-grid .sleep-report-metric::before {
    background: var(--scr-accent);
}

table.sleep-quality-report-grid .sleep-report-metric--awake::before {
    background: #f08a6a;
}

table.sleep-quality-report-grid .sleep-report-metric--light::before {
    background: #8b96ef;
}

table.sleep-quality-report-grid .sleep-report-metric--deep::before {
    background: #3954c9;
}

table.sleep-quality-report-grid .sleep-report-metric--outbed::before,
table.sleep-quality-report-grid .sleep-report-metric--outcount::before {
    background: #c7a45d;
}

table.sleep-quality-report-grid .sleep-report-metric--breath::before {
    background: #19a7bb;
}

table.sleep-quality-report-grid .sleep-report-metric--heart::before {
    background: #dd6e8c;
}

table.sleep-quality-report-grid .sleep-report-metric--apnea::before {
    background: #6574e8;
}

table.sleep-quality-report-grid .sleep-report-time {
    color: #3140a6;
}

.modal:has(table.sleep-quality-report-grid) .filter-box::before,
.modal:has(table.sleep-quality-report-grid) .grid-selector .select-label {
    border-left-color: var(--scr-accent);
    background: linear-gradient(90deg, rgba(101, 116, 232, 0.12), rgba(101, 116, 232, 0.00) 86%);
    color: var(--scr-accent-dark);
}

.modal:has(table.sleep-quality-report-grid) .grid-filter-form .input-group.input-group-sm {
    border-color: #c6d0f4;
    box-shadow: 0 10px 20px rgba(58, 74, 151, 0.07);
}

.modal:has(table.sleep-quality-report-grid) .grid-filter-form .input-group-text,
.modal:has(table.sleep-quality-report-grid) .grid-filter-form .input-group-addon {
    background: #f0f3ff !important;
    color: #6670a3 !important;
}

.modal:has(table.sleep-quality-report-grid) .grid-filter-form .input-group > .form-control {
    border-left-color: #dde3fb !important;
    color: var(--scr-text);
}

.modal:has(table.sleep-quality-report-grid) .grid-filter-form .input-group > .form-control:focus {
    box-shadow: inset 0 0 0 2px rgba(101, 116, 232, 0.13) !important;
}

.modal:has(table.sleep-quality-report-grid) .grid-filter-form .btn-group .btn.submit {
    border-color: var(--scr-accent) !important;
    background: linear-gradient(180deg, #7686ff 0%, #6574e8 58%, #4658cf 100%) !important;
    box-shadow: 0 12px 22px rgba(101, 116, 232, 0.22);
}

.modal:has(table.sleep-quality-report-grid) .grid-filter-form .btn-group .btn.reset {
    border-color: #c6d0f4 !important;
    color: #566292 !important;
}

.modal:has(table.sleep-quality-report-grid) .pagination > .active > a,
.modal:has(table.sleep-quality-report-grid) .pagination > .active > span {
    border-color: #5363d9 !important;
    background:
        radial-gradient(circle at 30% 22%, rgba(255, 255, 255, 0.38), transparent 36%),
        linear-gradient(180deg, #7686ff 0%, #6574e8 58%, #4658cf 100%) !important;
    box-shadow:
        0 13px 24px rgba(101, 116, 232, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.30),
        inset 0 -7px 14px rgba(41, 52, 142, 0.18);
}

.modal:has(table.sleep-quality-report-grid) .pagination > li:first-child > a:hover,
.modal:has(table.sleep-quality-report-grid) .pagination > li:last-child > a:hover,
.modal:has(table.sleep-quality-report-grid) .pagination > li:first-child > a:focus-visible,
.modal:has(table.sleep-quality-report-grid) .pagination > li:last-child > a:focus-visible {
    border-color: #6574e8 !important;
    color: var(--scr-accent-dark);
    box-shadow:
        0 14px 24px rgba(101, 116, 232, 0.20),
        0 0 0 4px rgba(101, 116, 232, 0.10),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

@media (max-width: 980px) {
    table.sleep-quality-report-grid > tbody > tr {
        grid-template-columns: 64px 1fr;
    }

    table.sleep-quality-report-grid > tbody > tr > td.sleep-report-col-vitals,
    table.sleep-quality-report-grid > tbody > tr > td.sleep-report-col-motion,
    table.sleep-quality-report-grid > tbody > tr > td.sleep-quality-col-vitals,
    table.sleep-quality-report-grid > tbody > tr > td.sleep-report-col-time {
        grid-column: 1 / -1;
    }
}
