/* Base Opinio styles pulled in from within your CSS so RU gets them too */
@import url("/opinio/upload/css/1/css_reset.css") screen,print;
@import url("/opinio/upload/css/1/default.css")    screen,print;
@import url("/opinio/upload/css/1/theme.css")      screen,print;
@import url("/opinio/upload/css/1/style_black.css") screen,print;
/* Optional (print only) */
@import url("/opinio/upload/css/1/print.css")      print; 

body, html {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    background: #ffffff;
    overflow-x: hidden;
}

.container {
    max-width: 100%;
    padding: 1rem;
    box-sizing: border-box;
}

/* Matrix table styling for desktop with vertical lines */
.matrix {
    width: 100%;
    border-collapse: collapse !important;
    table-layout: fixed;
}

.matrix th, .matrix td {
    border: 1px solid #999 !important;
    padding: 0.6rem !important;
    text-align: center !important;
    font-size: 0.95rem;
    word-wrap: break-word;
    white-space: normal;
}

/* Responsive fixes for mobile */
@media screen and (max-width: 768px) {
    .matrix {
        display: block;
        overflow-x: auto;
    }

    .matrix th, .matrix td {
        font-size: 0.85rem;
        min-width: 80px;
    }
}

.matrixCell:first-child {
    width: 70% !important;
    min-width: 280px !important;
    word-wrap: break-word !important;
    white-space: normal !important;
}

.matrixCell:not(:first-child) {
    width: 60px !important;
    min-width: 45px !important;
    max-width: 80px !important;
}

body, html {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    background: #ffffff;
    overflow-x: auto; /* Allow horizontal scroll when needed */
}

.container {
    max-width: 100%;
    padding: 1rem;
    box-sizing: border-box;
    overflow-x: auto; /* Enable horizontal scroll for container */
}

/* -------------------- MATRIX (desktop baseline) -------------------- */
table.matrix {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed; /* Fixed layout for consistent column widths */
    min-width: 100%; /* Ensure table takes full width */
}

table.matrix th,
table.matrix td {
    border: 1px solid #999;
    padding: 0.6rem;
    font-size: 0.95rem;
    text-align: center;
    vertical-align: top; /* Align content to top of cells */
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word; /* Break long words to prevent overflow */
    box-sizing: border-box;
}

/* First column = item text */
table.matrix th:first-child,
table.matrix td:first-child {
    text-align: left;
    width: 60%; /* Adjust based on your content needs */
    min-width: 200px;
    max-width: 400px;
}

/* Option columns: consistent sizing */
table.matrix th:not(:first-child),
table.matrix td:not(:first-child) {
    width: auto;
    min-width: 80px;
    max-width: 120px;
}

/* Ensure headers don't get repositioned */
table.matrix thead th {
    position: static !important;
    display: table-cell !important;
    float: none !important;
}

/* -------------------- MATRIX (mobile) -------------------- */
@media (max-width: 768px) {
    /* Allow horizontal scrolling on mobile */
    html, body {
        overflow-x: auto !important;
    }
    
    .container {
        padding: 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Mobile matrix container */
    .matrix-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        border: 1px solid #ccc;
        border-radius: 4px;
    }

    table.matrix {
        display: table !important; /* Keep as table on mobile */
        width: auto !important; /* Allow natural width */
        min-width: 700px !important; /* Increased minimum table width */
        table-layout: auto !important; /* Auto layout for mobile flexibility */
    }

    /* Mobile cell adjustments */
    table.matrix th,
    table.matrix td {
        padding: 0.4rem;
        font-size: 0.85rem;
        min-width: 60px;
        overflow: visible !important;
        text-overflow: clip !important;
    }

    /* Data cells keep nowrap, headers do not */
    table.matrix tbody td {
        white-space: nowrap; /* Only data cells get nowrap */
    }

    /* First column on mobile */
    table.matrix th:first-child,
    table.matrix td:first-child {
        white-space: normal !important; /* Allow wrapping in first column */
        min-width: 150px;
        max-width: 250px;
        width: 200px;
        position: sticky; /* Make first column sticky */
        left: 0;
        background: #ffffff;
        z-index: 2;
        border-right: 2px solid #999; /* Stronger border for sticky column */
    }

    /* Option columns on mobile - FIXED FOR HEADER TEXT OVERLAP */
    table.matrix th:not(:first-child),
    table.matrix td:not(:first-child) {
        min-width: 130px !important; /* Further increased */
        width: 140px !important; /* Further increased */
        text-align: center;
        max-width: none !important;
    }

    /* Allow header text to wrap to prevent overlap */
    table.matrix thead th:not(:first-child) {
        white-space: normal !important; /* Override nowrap for headers */
        word-break: break-word !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        hyphens: auto;
        line-height: 1.4; /* Increased line height */
        padding: 0.6rem 0.4rem !important; /* More vertical padding */
        height: auto !important;
        min-height: 60px; /* Ensure minimum height for wrapped text */
        max-width: none !important;
        text-overflow: clip !important;
    }

    /* Ensure all header cells can wrap - OVERRIDE ALL EXTERNAL STYLES */
    table.matrix thead th {
        white-space: normal !important;
        word-wrap: break-word !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        text-overflow: clip !important;
        overflow: visible !important;
        background: #f5f5f5 !important;
        font-weight: bold !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 3 !important;
        vertical-align: middle !important;
        line-height: 1.4 !important;
        padding: 0.8rem 0.4rem !important;
        height: auto !important;
        min-height: 70px !important;
        max-width: none !important;
        font-size: 0.85rem !important;
    }

    /* First header cell gets both sticky positioning */
    table.matrix thead th:first-child {
        z-index: 4; /* Highest z-index for corner cell */
        background: #f0f0f0;
    }
}

/* Additional mobile-specific classes if needed */
@media (max-width: 480px) {
    table.matrix th,
    table.matrix td {
        font-size: 0.8rem;
        padding: 0.3rem;
    }

    table.matrix th:first-child,
    table.matrix td:first-child {
        min-width: 120px;
        width: 150px;
    }

    /* Increased column widths for very small screens */
    table.matrix th:not(:first-child),
    table.matrix td:not(:first-child) {
        min-width: 120px !important; /* Further increased */
        width: 130px !important; /* Further increased */
    }
}