/* Enhanced Results Styles */

/* Compact info card (with icon integrated) */
.info-card-compact {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    border-left: 3px solid rgba(102, 126, 234, 0.15);
    border-right: 3px solid rgba(102, 126, 234, 0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.info-card-icon {
    color: rgba(102, 126, 234, 0.6);
    font-size: 1.25rem;
    flex-shrink: 0;
}

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

.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);
}

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

/* Notes card with border effect and fine outline, no background */
#notesDataCard .notes-card-wrapper {
    border-left: 3px solid rgba(102, 126, 234, 0.15);
    border-right: 3px solid rgba(102, 126, 234, 0.15);
    border-top: 1px solid rgba(102, 126, 234, 0.1);
    border-bottom: 1px solid rgba(102, 126, 234, 0.1);
    border-radius: 0.5rem;
    background: transparent;
    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: #495057;
    line-height: 1.5;
    white-space: pre-wrap;
}

#notesDataCard .notes-card-wrapper i {
    color: rgba(102, 126, 234, 0.6);
    font-size: 1.25rem;
    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%);
}

/* ESCRS Calculator button with logo */
.escrs-calc-btn {
    background: transparent;
    border: 2px solid #6c757d;
    border-radius: 0.375rem;
    padding: 0.5rem 1.25rem;
    transition: all 0.3s ease;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    height: auto;
}

.escrs-calc-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.escrs-calc-btn .escrs-logo {
    height: 24px;
    width: auto;
    display: block;
}

.escrs-calc-btn picture {
    transition: opacity 0.3s ease;
    display: block;
}

.escrs-calc-btn picture:has(.escrs-logo-white) {
    position: absolute;
    opacity: 0;
}

.escrs-calc-btn picture:has(.escrs-logo-black) {
    opacity: 1;
}

.escrs-calc-btn:hover,
.escrs-calc-btn:active {
    background: var(--gradient-primary);
    border-color: var(--color-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.escrs-calc-btn:hover picture:has(.escrs-logo-black),
.escrs-calc-btn:active picture:has(.escrs-logo-black) {
    opacity: 0;
}

.escrs-calc-btn:hover picture:has(.escrs-logo-white),
.escrs-calc-btn:active picture:has(.escrs-logo-white) {
    opacity: 1;
}

.escrs-calc-btn:active {
    transform: translateY(0);
}

/* Results action buttons - unified styling */
.result-action-btn {
    font-size: 0.95rem !important;
    padding: 0.5rem 1.25rem !important;
    border-radius: 0.375rem;
    border-width: 2px !important;
    font-weight: 500;
    transition: all 0.2s ease;
}

.result-action-btn:active {
    transform: translateY(0);
}

/* Download button - hover green */
#downloadJsonBtn:hover {
    background-color: #28a745 !important;
    border-color: #28a745 !important;
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

/* Edit button - hover yellow */
#toggleEditModeBtn:hover {
    background-color: #ffc107 !important;
    border-color: #ffc107 !important;
    color: #000 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
}

/* BiomPIN display - clean flex layout */
.biompin-display {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
}

/* BiomPIN textbox */
.biompin-textbox {
    flex: 1;
    font-family: 'Courier New', Consolas, Monaco, monospace;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: #7c3aed;
    background-color: #f9fafb;
    border: 2px solid #e0d4f7;
    border-radius: 0.5rem;
    padding: 0.875rem 1rem;
    text-align: center;
    user-select: all;
    cursor: text;
    transition: all 0.2s ease;
}

.biompin-textbox:focus {
    outline: none;
    border-color: #7c3aed;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

/* BiomPIN copy URL button */
.biompin-copy-btn {
    flex-shrink: 0;
    width: 50px;
    min-height: 44px;
    padding: 0;
    font-size: 1.125rem;
    color: #ffffff;
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    border: 2px solid #7c3aed;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.biompin-copy-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
    border-color: #6d28d9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.biompin-copy-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.2);
}

.biompin-copy-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* BiomPIN Result Card */
.biompin-result-card {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-bottom: 2px solid rgba(102, 126, 234, 0.2);
    margin: 0;
    transition: opacity 0.3s ease, filter 0.3s ease;
}

.biompin-result-card.disabled {
    opacity: 0.5;
    filter: grayscale(0.5);
    pointer-events: none;
}


.biompin-info {
    font-size: 0.9rem;
}

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

/* Tab navigation */
#resultsTabs .nav-link {
    color: var(--color-text-muted);
    border: none;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

#resultsTabs .nav-link:hover {
    color: var(--color-primary);
    background-color: rgba(102, 126, 234, 0.05);
}

#resultsTabs .nav-link.active {
    color: var(--color-primary);
    background-color: transparent;
    border-bottom-color: var(--color-primary);
    font-weight: 600;
}

/* 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 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 {
    background-color: #ffc107 !important;
    border-color: #ffc107 !important;
    color: #000 !important;
    font-weight: 600 !important;
    box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.25) !important;
}

#toggleEditModeBtn.active:hover {
    background-color: #ffb300 !important;
    border-color: #ffb300 !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 table */
#metadataTable {
    /* No height restriction - display full content */
}

/* Download button enhancement */
#downloadJsonBtn {
    transition: all 0.3s ease;
}

#downloadJsonBtn:hover {
    background-color: var(--color-success);
    color: white;
    border-color: var(--color-success);
}

/* 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;
}

/* BiomPIN about section styling */
.biompin-about-toggle {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.biompin-about-toggle:hover {
    color: var(--color-primary);
}

.biompin-about-chevron {
    transition: transform 0.3s ease;
    font-size: 0.75rem;
}

.biompin-about-toggle[aria-expanded="true"] .biompin-about-chevron {
    transform: rotate(90deg);
}

.biompin-about-content {
    padding: 0.75rem;
    background: rgba(102, 126, 234, 0.05);
    border-radius: var(--border-radius-sm);
}

.biompin-about-text {
    color: var(--color-text-muted);
    line-height: 1.5;
}

/* BiomPIN QR Code */
.biompin-qr-small {
    display: inline-block;
    cursor: pointer;
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: var(--border-radius-md);
    padding: 0.5rem;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.biompin-qr-small:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.biompin-qr-small canvas,
.biompin-qr-small img {
    display: block;
}

/* QR Modal */
.qr-modal-dialog {
    max-width: 500px;
}

@media (max-width: 768px) {
    .qr-modal-dialog {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }
}

.biompin-qr-large {
    display: inline-block;
    padding: 1rem;
    background: white;
    border-radius: var(--border-radius-md);
}

.biompin-qr-large canvas,
.biompin-qr-large img {
    display: block;
    max-width: 100%;
    height: auto;
}

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

    #resultsActions button {
        width: 100%;
    }

    .biompin-textbox {
        font-size: 1.25rem;
        letter-spacing: 0.03em;
    }

    /* 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;
    }

    /* Make ESCRS button smaller on mobile */
    .escrs-calc-btn {
        padding: 0.5rem 0.75rem;
    }

    .escrs-calc-btn .escrs-logo {
        height: 20px;
    }

    #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;
    }

    /* Shorten "Post Refractive" to "Post Refr." on mobile */
    #biometryDataTable tbody tr:nth-child(2) .parameter-label {
        font-size: 0;
    }

    #biometryDataTable tbody tr:nth-child(2) .parameter-label::after {
        content: "Post Refr.";
        font-size: 0.7rem;
    }

    /* 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;
    }
}

/* Very narrow displays - aggressive BiomPIN compacting */
@media (max-width: 400px) {
    /* BiomPIN display - prevent overflow */
    .biompin-display {
        gap: 0.5rem;
    }

    .biompin-textbox {
        font-size: 0.8rem;
        padding: 0.65rem 0.75rem;
        letter-spacing: 0.02em;
    }

    .biompin-copy-btn {
        width: 42px;
        min-width: 42px;
        font-size: 1rem;
    }

    /* BiomPIN card - reduce padding */
    .biompin-result-card .card-body {
        padding: 1rem 0.875rem;
    }

    /* QR code - smaller */
    .biompin-qr-small {
        padding: 0.375rem;
    }

    .biompin-qr-small canvas,
    .biompin-qr-small img {
        max-width: 120px;
        height: auto;
    }

    /* BiomPIN info text - smaller */
    .biompin-info {
        font-size: 0.85rem;
    }

    .biompin-about-toggle {
        font-size: 0.8rem;
    }

    .biompin-about-text {
        font-size: 0.75rem;
    }
}
