/* Results Styles */

.extraction-feedback {
    /* Bring the row closer to the preceding result block's mb-3 spacing. */
    margin-top: -0.75rem;
    /* Match the quiet typography of .onboarding-trigger. */
    color: #94a3b8;
    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: right;
    opacity: 1;
    transition: opacity 250ms ease;
}

.extraction-feedback.is-fading {
    opacity: 0;
    pointer-events: none;
}

.extraction-feedback-row[hidden] {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .extraction-feedback {
        transition: none;
    }
}

.extraction-feedback-row,
.extraction-feedback-ratings {
    display: flex;
    align-items: center;
    gap: 0.125rem;
}

.extraction-feedback-row {
    flex-wrap: wrap;
    justify-content: flex-end;
    column-gap: 0.375rem;
}

.extraction-feedback-thumb,
.extraction-feedback-details {
    min-height: 28px;
    border: 0;
    background: none;
    box-shadow: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.extraction-feedback-thumb {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 4px;
    font-size: 0.75rem;
}

.extraction-feedback-thumb:hover:not(:disabled),
.extraction-feedback-thumb[aria-pressed="true"],
.extraction-feedback-details:hover {
    color: var(--color-primary-dark);
}

.extraction-feedback-thumb:disabled {
    cursor: default;
}

.extraction-feedback-thumb:disabled[aria-pressed="false"] {
    opacity: 0.45;
}

.extraction-feedback-thumb:focus-visible,
.extraction-feedback-details:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.extraction-feedback-details {
    padding: 0;
    text-decoration: none;
}

.extraction-feedback-details:hover {
    text-decoration: underline;
    text-underline-offset: 0.18rem;
}

.extraction-feedback-status {
    margin: 0.25rem 0 0;
}

.extraction-feedback.is-rated .extraction-feedback-status {
    margin: 0;
    line-height: 28px;
}

/* Compact info card (with icon integrated) - Enhanced */
.info-card-compact {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
    border-radius: var(--border-radius-md);
    padding: 0.875rem 1.25rem;
    border-left: 3px solid rgba(102, 126, 234, 0.25);
    border-right: 3px solid rgba(118, 75, 162, 0.25);
    display: flex;
    align-items: center;
    gap: 0.875rem;
    box-shadow: var(--shadow-sm);
}

.info-card-icon {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.info-card-content {
    flex: 1;
    min-width: 0;
}

.report-details-btn {
    align-items: center;
    background: var(--control-surface);
    border: 1px solid var(--control-border);
    border-radius: 50%;
    box-shadow: var(--control-shadow);
    color: var(--color-text-muted);
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 40px;
    font-size: 1rem;
    height: 40px;
    justify-content: center;
    margin-left: auto;
    padding: 0;
    transition: var(--control-transition);
    transform: translateY(0);
    width: 40px;
}

.report-details-btn:active {
    box-shadow: var(--control-shadow-pressed);
    transform: translateY(1px);
}

.report-details-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
    .report-details-btn:hover {
        border-color: rgba(102, 126, 234, 0.3);
        box-shadow: var(--control-shadow-hover);
        color: var(--color-primary);
        transform: translateY(-1px);
    }
}

.info-value {
    font-size: 0.95rem;
    line-height: 1.6;
}

.info-value:first-child {
    font-weight: 600;
    color: var(--color-text-dark);
}

.info-value.text-muted {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

/* Patient info - enhanced typography */
.patient-name {
    font-weight: 600;
    letter-spacing: 0.3px;
}

.patient-field {
    font-weight: 400;
}

/* Patient separator - unselectable muted gray bullet with spacing */
.patient-separator {
    user-select: none;
    padding: 0 0.5em;
    color: var(--color-text-muted);
    opacity: 0.6;
}

/* Patient card two-line layout - enhanced */
.patient-primary-line {
    font-size: 1rem;
    line-height: 1.3;
    color: var(--color-text-dark);
}

.patient-primary-line .patient-name:first-child {
    font-weight: 600;
}

.patient-primary-line .patient-name:last-child {
    font-weight: 500;
}

.patient-secondary-line {
    font-size: 0.875rem;
    line-height: 1.3;
    margin-top: 0.1rem;
    color: var(--color-text-muted);
}

/* Biometry and PK tables with left and right border highlight - Enhanced */
#biometryDataTable,
#posteriorKeratometryTable {
    border-left: 3px solid rgba(102, 126, 234, 0.25);
    border-right: 3px solid rgba(118, 75, 162, 0.25);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
}

/* Notes card with border effect and fine outline - Enhanced (Secondary Content) */
#notesDataCard .notes-card-wrapper {
    border-left: 3px solid rgba(102, 126, 234, 0.25);
    border-right: 3px solid rgba(118, 75, 162, 0.25);
    border-top: 1px solid rgba(102, 126, 234, 0.1);
    border-bottom: 1px solid rgba(102, 126, 234, 0.1);
    border-radius: var(--border-radius-md);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.6) 0%, rgba(248, 249, 250, 0.8) 100%);
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#notesDataCard .notes-card-wrapper .notes-text {
    flex: 1;
    font-size: 0.85rem;
    color: var(--color-text-dark);
    line-height: 1.5;
    white-space: pre-wrap;
}

#notesDataCard .notes-card-wrapper i {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    opacity: 0.5;
    font-size: 1.35rem;
    flex-shrink: 0;
}

/* Table styling for both biometry and PK tables */
#biometryDataTable table,
#posteriorKeratometryTable table {
    margin-bottom: 0;
}

#biometryDataTable thead th,
#posteriorKeratometryTable thead th {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    border: none;
    padding: 0.65rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-text-dark);
}

#biometryDataTable tbody td,
#posteriorKeratometryTable tbody td {
    padding: 0.55rem 1.25rem;
    border-top: 1px solid rgba(102, 126, 234, 0.1);
}

/* Add padding to bottom of tables to fill curved corner */
#biometryDataTable::after,
#posteriorKeratometryTable::after {
    content: '';
    display: block;
    height: 0.5rem;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
}

/* Results action buttons - unified styling */
.result-action-btn {
    font-size: 0.95rem !important;
    padding: 0.5rem 1.25rem !important;
    border-radius: var(--control-radius);
    border-width: 1px !important;
    font-weight: 500;
}

/* Remove bottom padding from result content to reduce spacing above close button */
#resultsContent {
    padding-bottom: 0 !important;
}

/* Data tables */
.data-table {
    background: white;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
}

.data-table table {
    margin-bottom: 0;
}

.data-table th {
    background: rgba(102, 126, 234, 0.1);
    color: var(--color-text-dark);
    font-weight: 600;
    padding: 0.75rem 1rem;
    border: none;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-top: 1px solid #e5e7eb;
    color: var(--color-text-dark);
}

.data-table tbody tr:hover {
    background-color: rgba(102, 126, 234, 0.03);
}

/* Editable cells */
.editable-cell {
    position: relative;
    transition: all 0.2s ease;
}

.editable-cell.editable-active {
    cursor: pointer;
}

.editable-cell.editable-active:hover {
    background-color: rgba(255, 193, 7, 0.1);
}

.editable-cell.editing {
    background-color: rgba(255, 193, 7, 0.2);
    padding: 0;
}

.editable-cell input {
    width: 100%;
    border: 2px solid var(--color-primary);
    padding: 0.5rem;
    font-size: inherit;
    font-family: inherit;
}

.editable-cell.editable-active::after {
    content: '\f304';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s;
    color: var(--color-primary);
    font-size: 0.8rem;
}

.editable-cell.editable-active:hover::after {
    opacity: 0.5;
}

/* Edit mode controls */
#editModeIndicator {
    border-left: 4px solid #ffc107;
}

#toggleEditModeBtn.active {
    --button-shadow-color: 217, 119, 6;
    background: linear-gradient(180deg, #fbdc7f 0%, #f3ad18 100%) !important;
    border-color: #d97706 !important;
    color: #3f2b05 !important;
    font-weight: 600 !important;
    box-shadow:
        0 1px 2px rgba(120, 53, 15, 0.12),
        inset 0 2px 4px rgba(146, 64, 14, 0.12) !important;
}

@media (hover: hover) and (pointer: fine) {
    #toggleEditModeBtn.active:hover {
        background: linear-gradient(180deg, #fce5a1 0%, #f4b72b 100%) !important;
        border-color: #d97706 !important;
        box-shadow:
            0 2px 3px rgba(15, 23, 42, 0.08),
            0 3px 7px rgba(217, 119, 6, 0.12),
            var(--control-highlight) !important;
    }
}

/* JSON viewer */
.json-viewer {
    background: #f8f9fa;
    border-radius: var(--border-radius-sm);
    max-height: 600px;
    overflow-y: auto;
}

.json-viewer pre {
    margin: 0;
    padding: 1rem;
    background: transparent;
}

.json-viewer code {
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Metadata modal */
.report-details-modal-dialog {
    margin-left: auto;
    margin-right: auto;
    max-width: 540px;
    width: calc(100% - 2rem);
}

.report-details-modal-dialog .modal-body {
    padding: 0;
}

#metadataTable {
    border-radius: 0 0 15px 15px;
}

#metadataTable td {
    padding: 0.7rem 1.25rem;
    vertical-align: middle;
}

#metadataTable tbody tr:first-child td {
    border-top: 0;
}

@media (max-width: 575.98px) {
    .report-details-modal-dialog {
        margin-left: 1rem;
        margin-right: 1rem;
    }

    #metadataTable td:first-child {
        width: 42%;
    }
}

.metadata-request-id {
    align-items: center;
    display: inline-flex;
    gap: 0.25rem;
    max-width: 100%;
    vertical-align: middle;
}

.metadata-request-id-value {
    color: #6b7280;
    font-size: 0.72rem;
    max-width: min(100%, 18rem);
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-all;
}

.metadata-request-id-copy {
    align-items: center;
    background: var(--control-surface);
    border: 1px solid rgba(15, 23, 42, 0.13);
    border-radius: 50%;
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.08),
        var(--control-highlight);
    color: #6b7280;
    cursor: pointer;
    display: inline-flex;
    font-size: 0.72rem;
    height: 1.45rem;
    justify-content: center;
    margin-left: 0;
    padding: 0;
    vertical-align: baseline;
    transition: var(--control-transition);
    transform: translateY(0);
    width: 1.45rem;
}

.metadata-request-id-copy:active:not(:disabled) {
    box-shadow: var(--control-shadow-pressed);
    transform: translateY(1px);
}

@media (hover: hover) and (pointer: fine) {
    .metadata-request-id-copy:hover:not(:disabled) {
        border-color: rgba(102, 126, 234, 0.28);
        box-shadow: var(--control-shadow-hover);
        color: var(--color-primary);
        transform: translateY(-1px);
    }
}

/* Placeholder */
#resultsPlaceholder {
    opacity: 0.6;
    min-height: 200px;
}

/* Card height adjustments */
.results-card {
    height: auto;
    min-height: 250px;
}

.results-card .card-body {
    min-height: 200px;
    height: auto;
}

.biometry-device-name,
.biometry-exam-date {
    display: block;
}

.biometry-exam-date {
    margin-top: 0.15rem;
    color: var(--color-text-muted, #6b7280);
    font-size: 0.7rem;
    font-weight: 400;
}

.eye-column-keratometry {
    white-space: nowrap;
}

.derived-keratometry-row .parameter-label span {
    cursor: help;
}

.biometry-text-compact {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #resultsActions {
        flex-direction: column;
        width: 100%;
    }

    #resultsActions button {
        width: 100%;
    }

    /* Hide button text on mobile, keep icons only */
    .result-action-btn .btn-text {
        display: none;
    }

    .result-action-btn {
        padding: 0.5rem 0.75rem !important;
    }

    .result-action-btn i {
        margin: 0 !important;
        font-size: 1.1rem;
    }

    #editModeControls > div {
        flex-direction: column;
        gap: 0.5rem;
    }

    #editModeControls > div > div:last-child {
        width: 100%;
    }

    #editModeControls > div > div:last-child button {
        width: 100%;
    }

    /* Smaller font size for biometry measurements table to prevent wrapping */
    #biometryDataTable,
    #biometryDataTable th,
    #biometryDataTable td {
        font-size: 0.75rem;
    }

    #biometryDataTable thead th {
        padding: 0.75rem 0.875rem;
    }

    #biometryDataTable tbody td {
        padding: 0.625rem 0.875rem;
    }

    /* Smaller font for column headers on mobile */
    #biometryDataTable .right-eye,
    #biometryDataTable .left-eye {
        font-size: 0.7rem;
    }

    /* Smaller font for parameter labels on mobile */
    #biometryDataTable .parameter-label {
        font-size: 0.7rem;
    }

    .biometry-text-full {
        display: none;
    }

    .biometry-text-compact {
        display: inline;
    }

    /* Smaller font size for posterior keratometry table to match biometry table */
    #posteriorKeratometryTable,
    #posteriorKeratometryTable th,
    #posteriorKeratometryTable td {
        font-size: 0.75rem;
    }

    #posteriorKeratometryTable thead th {
        padding: 0.75rem 0.875rem;
    }

    #posteriorKeratometryTable tbody td {
        padding: 0.625rem 0.875rem;
    }

    /* Smaller font for column headers on mobile */
    #posteriorKeratometryTable .right-eye,
    #posteriorKeratometryTable .left-eye {
        font-size: 0.7rem;
    }

    /* Smaller font for parameter labels on mobile */
    #posteriorKeratometryTable .parameter-label {
        font-size: 0.7rem;
    }

    /* Smaller font size for metadata table */
    #metadataTable,
    #metadataTable th,
    #metadataTable td {
        font-size: 0.75rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem 0.75rem;
    }
}

@media (max-width: 420px) {
    .eye-column-keratometry .keratometry-axis {
        display: block;
    }
}

@media (hover: hover) and (pointer: fine) {
    /* Download button - hover green */
    #downloadJsonBtn:hover {
        --button-shadow-color: 5, 150, 105;
        background: linear-gradient(180deg, #2bca98 0%, #079b6e 100%) !important;
        border-color: #059669 !important;
        color: white !important;
        transform: translateY(-1px);
        box-shadow:
            0 2px 3px rgba(15, 23, 42, 0.08),
            0 3px 7px rgba(5, 150, 105, 0.12),
            var(--control-highlight);
    }

    /* Edit button - hover yellow */
    #toggleEditModeBtn:hover {
        --button-shadow-color: 217, 119, 6;
        background: linear-gradient(180deg, #fbdc7f 0%, #f3ad18 100%) !important;
        border-color: #d97706 !important;
        color: #3f2b05 !important;
        transform: translateY(-1px);
        box-shadow:
            0 2px 3px rgba(15, 23, 42, 0.08),
            0 3px 7px rgba(217, 119, 6, 0.12),
            var(--control-highlight);
    }
}

/* ===== CLEAR BIOMETRY BUTTON ===== */
.clear-biometry-btn {
    --button-shadow-color: 71, 85, 105;
    background: linear-gradient(180deg, #ffffff 0%, #f1f3f6 100%) !important;
    border: 1px solid #d5dae3 !important;
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.09),
        0 3px 7px rgba(71, 85, 105, 0.08),
        var(--control-highlight) !important;
    color: #5f6875 !important;
    transition: var(--control-transition) !important;
    padding: 0.5rem 0.75rem !important;
    border-radius: var(--control-radius) !important;
}

#clearBiometryBtn {
    width: 2.35rem;
    height: 2.35rem;
    padding: 0 !important;
    border-radius: 50% !important;
    border-color: rgba(255, 255, 255, 0.72) !important;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(245, 246, 250, 0.88) 100%) !important;
    box-shadow:
        0 1px 2px rgba(30, 27, 75, 0.12),
        0 2px 5px rgba(30, 27, 75, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.7) !important;
    color: #6b7280 !important;
}

#clearBiometryBtn:active {
    background: #f3f4f6 !important;
    box-shadow: inset 0 2px 4px rgba(30, 27, 75, 0.14) !important;
}

.clear-biometry-btn:active {
    box-shadow: var(--control-shadow-pressed) !important;
    transform: translateY(1px) !important;
}

@media (hover: hover) and (pointer: fine) {
    .clear-biometry-btn:hover {
        --button-shadow-color: 220, 38, 38;
        background: linear-gradient(180deg, #e96370 0%, #c92e3d 100%) !important;
        border-color: #b91c1c !important;
        box-shadow:
            0 2px 3px rgba(15, 23, 42, 0.08),
            0 3px 7px rgba(220, 38, 38, 0.12),
            var(--control-highlight) !important;
        color: #ffffff !important;
        transform: translateY(-1px) !important;
    }

    #clearBiometryBtn:hover {
        background: linear-gradient(180deg, #e96370 0%, #c92e3d 100%) !important;
        border-color: #b91c1c !important;
        box-shadow:
            0 2px 3px rgba(30, 27, 75, 0.1),
            0 3px 7px rgba(185, 28, 28, 0.14),
            var(--control-highlight) !important;
        color: #ffffff !important;
    }
}

.clear-biometry-btn:active,
#clearBiometryBtn:active {
    box-shadow: var(--control-shadow-pressed) !important;
    transform: translateY(1px) !important;
}

/* Keep pressed depth authoritative when pointer hover remains active. */
.report-details-btn:active,
.metadata-request-id-copy:active:not(:disabled) {
    box-shadow: var(--control-shadow-pressed) !important;
    transform: translateY(1px) !important;
}

.result-action-btn:active,
#toggleEditModeBtn:active {
    box-shadow: var(--control-shadow-pressed) !important;
    transform: translateY(1px) !important;
}

@media (prefers-reduced-motion: reduce) {
    .report-details-btn,
    .metadata-request-id-copy {
        transition-duration: 0.01ms !important;
    }

    .report-details-btn:hover,
    .report-details-btn:active,
    .metadata-request-id-copy:hover,
    .metadata-request-id-copy:active {
        transform: none !important;
    }
}
