.resp-form-container {
    max-width: 900px;
    min-width: 230px;
    margin: 10px auto;
    padding: 0px 10px 10px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-family: 'Roboto', sans-serif !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
}

.resp-form-section {
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
}

.resp-form-section:not(:last-child) {
    margin-bottom: 10px;
}

.resp-form-group {
    margin-bottom: 5px;
    display: flex;
}

.resp-form-group label {
    margin-right: 10px;
    flex-shrink: 0;
    height: 26px;
    padding: 0 4px 0 0;
    text-align: right;
    position: relative;
    top: 4px;
    margin-left: 10px;
    font-size: 14px;
}

.resp-form-group label:first-of-type {
    width: 110px;
    margin-left: 0px;
}

.resp-form-group label:has(input[type="checkbox"]) {
    width: auto;
    margin-right: 10px;
    flex-shrink: 0;
    color: black;
    height: 26px;
    padding: 0 4px 0 0;
    font-weight: normal;
    text-align: right;
    position: relative;
    top: -3px;
    display: inline-flex;
    align-items: center;
    float: left;
    margin-left: 0px;
}

.resp-form-group input,
.resp-form-group textarea {
    flex-grow: 1;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    min-width: 10px;
}

.resp-form-group textarea {
    resize: vertical;
    height: 100px;
    padding-left: 4px;
    font-family: 'Roboto', sans-serif !important;
}

.resp-form-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 5px;
    position: relative;
    max-width: 900px; 
}

.resp-form-header h2 {
    margin: 0;
    font-size: 24px;
    flex: 0 1 auto;
}

.buttons-placeholder {
    position: absolute;
    right: 0px;
    display: flex;
    gap: 4px;
}

.resp-form-header .button {
    padding: 6px 8px;
    background-color: rgb(6,  141, 205);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.resp-form-header .button:hover {
    background-color: rgb(6, 174, 241);
}

.resp-form-header .button:active {
    background-color: rgb(98, 211, 255);
}

.resp-form-header .button.disabled {
    pointer-events: none;
    opacity: 0.6;
}

.resp-form-header-left {
    display: flex;
    justify-content: left;
    align-items: center;
    margin-bottom: 5px;
}

.resp-form-header-left label {
    font-weight: bold;
}

.resp-form-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.resp-section-buttons {
    flex: 1;
    text-align: left;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    color: #999A9A;
}

.resp-section-buttons .resp-grid-action-btn {
    margin-left: 5px;
    position: relative;
    top: -1px;
}

.resp-form-section .resp-form-group label {
    width: 90px;
}

@keyframes flashHighlight {
  0%   { background-color: #ffffe4; }
  100% { background-color: transparent; }
}

.item-highlight {
  animation: flashHighlight 1s ease-out;
}

.resp-form-error {
    background-color: #ffe6e6;
    border: 1px dotted red;
    padding: 8px;
}

#modalError {
    margin: auto;
}

/* Grid Section Styles */
.resp-grid-container {
    max-width: 900px;
    margin: 20px auto;
    font-family: Roboto, sans-serif;
}

.resp-with-overflow {
    overflow-x: auto;
}

.resp-grid-header, .resp-grid-row {
    display: flex;
    border-bottom: 1px solid #ccc;
}

.resp-grid-header {
    font-weight: bold;
    background-color: #f8f9fa;
}

.resp-grid-cell {
    flex: 1;
    padding: 10px;
    text-align: left;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.resp-grid-cell.question {
    flex: 2;
}

.resp-grid-cell.answer {
    flex: 0 0 auto;
    white-space: nowrap; 
}

.resp-grid-cell.text {
    width: 40%;
}

.resp-grid-cell.seqNo {
    max-width: 60px;
}

.resp-grid-cell.actions {
    flex: 0 0 295px; 
    display: flex;
    gap: 5px;
    align-items: center;
    justify-content: flex-start;
}

.resp-grid-header .resp-grid-cell.actions {
    flex: 0 0 295px; 
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.resp-grid-action-btn {
    padding: 5px 8px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    color: white;
    min-width: 20px; 
    max-width: 60px;
    text-align: center;
    background-color: rgb(6,  141, 205);
    background-repeat: no-repeat;
    background-position: center;
}

.resp-grid-action-btn:hover {
    background-color: rgb(6, 174, 241);
}

.resp-grid-action-btn:active {
    background-color: rgb(98, 211, 255);
}

.resp-grid-action-btn.up,
.resp-grid-action-btn.down {      
    min-width: 10px;
    max-width: 10px;
}

.resp-grid-action-btn.edit {
    max-width: 25px;
}

.resp-grid-action-btn.delete {
    max-width: 35px;
}

.resp-grid-action-btn.add {
    max-width: 100px;
}

.resp-grid-action-btn.up {    
    background-image: url('../images/arrow_up.png');
}

.resp-grid-action-btn.down {
    background-image: url('../images/arrow_down.png');
}

.resp-grid-action-btn.delete,
#cancel-test-button {
    background-color: #dc3545;
}

.resp-grid-action-btn.delete:hover,
#cancel-test-button:hover {
    background-color: #fa5061;
}

.resp-grid-action-btn.delete:active,
#cancel-test-button:active {
    background-color: #fc7a87;
}

.resp-grid-action-btn.disabled {
    pointer-events: none;
    opacity: 0.6;
}

.seqNo-section {
    flex: unset;
}

.seqNo-section .seqNo-indent, .seqNo-section .seqNo {
    height: 100%;
}

.required-question {
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" height="10" width="10"><text x="0" y="8" font-size="10" fill="red">*</text></svg>');
    background-repeat: no-repeat;
    background-position-y: 13px;
    background-position-x: 0px;
}

td.required-question {
    background-position-y: 10px !important;
    background-position-x: 2px !important;
}

.question-section {
    flex-direction: column;
    align-items: start;
    padding-left: 0px;
    padding-right: 0px;
}

.question {
    margin-bottom: 4px;
}

.yesno-label {
    display: inline-flex;
    align-items: baseline;
}

.yesno-label:last-of-type {
    margin-right: 8px;
}

.yesno-controls {
    display: flex;
}

.yesno-controls:has(label) {
    position: relative;
    left: -4px;
}

.yesno-controls input[type="text"] {
    margin-right: -4px;
}

.full-width {
    width: 100%;
}

.flex-gap-layout {
    display: flex;
    gap: 4px;
}

label:has(input[disabled]) {
    color: #ccc !important;
}

/* Modal Styles */
.resp-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.resp-modal-content {
    background-color: white;
    padding: 10px;
    border-radius: 5px;
    max-width: 556px;
    width: 90%;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative; 
    margin: 10px;
}

.resp-modal-content h3 {
    margin: 0 0 20px;
    font-size: 20px;
    text-align: center;
}

.resp-modal-content .form-group {
    margin-bottom: 15px;
}

.resp-modal-content .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.resp-modal-content .form-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.resp-modal-content .form-buttons {
    justify-content: flex-end;
}

.modal-header {
    background: linear-gradient(to bottom, #f7fcff 0%, #caeef7 100%);
    border: 1px solid #ccc;
    margin: -11px -11px 10px -11px;
    padding: 4px;
    border-radius: 4px 4px 0px 0px;
    font-weight: bold;
}

.modal-body {
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}

.modal-sub-header {
    background: #f4f4f4;
    border: 1px solid gray;
    padding: 4px;
    border-radius: 4px 4px 0px 0px;
    font-weight: bold;
    font-size: 13px;
}

.modal-sub-list {
    border-radius: 0px 0px 4px 4px !important;
    overflow: auto !important;
    height: 200px;
}

.resp-close-modal, .resp-close-scan-modal, .resp-close-scan-disc-modal {
    position: absolute;
    top: 1px;
    right: 13px;
    font-size: 20px;
    cursor: pointer;
    color: #333;
}

.resp-modal select {
    width: 100%;
    max-width: 100%;    
    box-sizing: border-box; 
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

/* Table */
.responsive-table {
    width: 100%;
    border-collapse: collapse;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    min-width: 600px;
}

.responsive-table th,
.responsive-table td {
    border: 1px solid #ddd;
    padding: 4px;
    text-align: left;
}

.responsive-table th {
    text-align: center;
    vertical-align: middle;
}

.responsive-table td {
    text-align: left;
    vertical-align: middle;
}

.responsive-table input {    
    box-sizing: border-box;
}

.modal-table {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #9a9a9a;
    border-radius: 4px;
}

.modal-table-header {
    display: flex;
    background: #f4f4f4;
    font-weight: bold;
    border-bottom: 1px solid #9a9a9a;
    border-radius: 4px 4px 0px 0px;
    font-size: 14px;
}

.modal-table-body {
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
}

.modal-table-row {
    display: flex;
    align-items: center;
}

.modal-table-cell {
    flex: 1;
    padding: 2px;
    text-align: left;
}

.option-answer {
    flex: 2;
    text-align: center;
}

.option-score {
    max-width: 80px;
    text-align: center;
}

.option-actions {
    display: flex;
    gap: 3px;
    justify-content: center;
    max-width: 90px;
}

.number-scores-actions {
    display: flex;
    gap: 3px;
    justify-content: center;
    max-width: 50px;
}

.option-score input, .number-scores input {
    width: 100%;
    padding: 5px;
    box-sizing: border-box;
}

.option-answer input {
    width: 100%;
    padding: 5px;
    box-sizing: border-box;
}

.option-actions .option,
.number-scores-actions .number-scores {
    height: 14px;
    max-width: 14px;
    min-width: 10px;
}

.number-min, .number-max, .number-score {
    max-width: 100px;
}

.radiogroup label {
    margin-right: 0px;
}

.modal-table-row.options:last-of-type .resp-grid-action-btn.option,
.modal-table-row.number-scores:last-of-type .resp-grid-action-btn.number-scores {
    display: none;
}

.question-form-body {
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}

.no-margin-left {
    margin-left: 0px !important;
}

.resp-grid-rows {
    max-height: 300px;
    overflow-y: auto;
}

/* Card View for Small Screens */
@media (max-width: 540px) {
    .resp-form-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .resp-form-header button {
        margin-top: 10px;
    }

    .resp-form-group {
        flex-direction: column;
        align-items: flex-start;
    }

    .resp-form-group label {
        width: auto;
        margin-right: 0;
        margin-bottom: 2px;
        margin-top: 4px;
        position: unset;
        top: unset;
        height: auto;
        margin-left: 0px;
    }

    .resp-form-group label:first-of-type {
        width: unset;        
    }

    .resp-form-group label:has(input[type="checkbox"]) {
        width: auto;
        margin-right: 0;
        margin-bottom: 2px;
        margin-top: 4px;
        position: unset;
        top: unset;
        height: auto;
    }

    .resp-form-section .resp-form-group label {
        width: auto;
    }

    .resp-form-group input,
    .resp-form-group textarea {
        width: 100%;
    }

    .checkbox {
        width: unset !important;
    }

    .resp-grid-header {
        display: none;
    }

    .resp-grid-row {
        flex-direction: column;
        border: 1px solid #ccc;
        border-radius: 5px;
        margin-bottom: 10px;
        background-color: #fff;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        height: unset !important;
    }

    .resp-grid-cell {
        padding: 8px !important;
        border-bottom: 1px solid #eee;
        display: block;
    }

    .resp-grid-cell:last-child {
        border-bottom: none;
    }

    .resp-grid-cell::before {
        content: attr(data-label);
        font-weight: bold;
        display: block;
        margin-bottom: 5px;
    }

    .resp-grid-cell.question {
        flex: 1;
    }

    .resp-grid-cell.answer {
        max-width: initial; 
    }

    .resp-grid-cell.answer {
        width: initial; 
    }

    .resp-grid-cell.icon {
        margin: 4px; 
    }

    .resp-grid-action-btn.attachments {
        width: unset;
        text-align: center;
    }

    .resp-grid-cell.actions {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 5px;
        align-items: center;
        justify-content: flex-start;
        flex: 1;
        padding-bottom: 10px;
    }

    .resp-grid-cell.actions::before {
        display: block;
        width: 100%;
        margin-bottom: 8px;
    }

    .resp-grid-action-btn {
        width: 100%;
        text-align: left;
        min-width: unset; /* Remove min-width in card view */
    }

    .resp-section-buttons .resp-grid-action-btn {
        margin-left: unset;
        top: unset;
    }

    .resp-section-buttons {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 5px;
        align-items: center;
        justify-content: flex-start;
        flex: 1;
        padding-top: 10px;        
    }

    .resp-section-buttons::before {
        content: attr(data-label);
        font-weight: bold;
        display: block;
        margin-bottom: 5px;
        width: 100%;
    } 

    .tristate-checkbox {
        top: -3px;
    }

    .responsive-table {
        min-width: unset;
    }

    .responsive-table thead {
        display: none;
    }

    .responsive-table, 
    .responsive-table tbody, 
    .responsive-table tr, 
    .responsive-table td {
        display: block;        
    }

    .responsive-table tr {
        margin-bottom: 1.5rem;
        border: 1px solid #ccc;
        padding: 1rem;
        border-radius: 6px;       
    }

    .responsive-table td.stats-column {
        padding: 4px;
        text-align: left;
        position: relative;
        align-content: center;
        height: 24px;
    }

    .responsive-table td::before {
        content: attr(data-label);
        font-weight: bold;
        display: inline-block;
        width: 100%;
        padding-right: 1rem;
    }

    .responsive-table td.stats-column::before {
        width: unset;
    }

    .responsive-table td input {
        float: right;
        width: calc(100% - 116px);
        margin-bottom: 5px;
    }

    .seqNo-indent {
        display: none;
    }

    .modal-table-header {
        display: none;
    }

    .modal-table-body {
        max-height: 100px;
        padding-right: 6px;
    }

    .modal-table-row {
        display: flex;
        flex-direction: column;
        padding: 4px;
        background: unset;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

    .modal-table-cell {
        display: flex;
        align-items: center;
        width: 100%;
        box-sizing: border-box;
    }

    .modal-table-cell::before {
        content: attr(data-label);
        font-weight: bold;
        font-size: 14px;
        width: 100px;
        display: inline-block;
        text-align: left;
    }

    .option-answer, .option-score {
        flex: none;
    }

    .option-score, .number-scores  {
        width: 100%;
        max-width: unset;
    }

    .option-actions, .number-scores-actions {
        justify-content: flex-start;
        max-width: unset;
    }

    .option-answer input, .option-score input, .number-scores input {
        width: unset !important;
    }

    .option {
        position: relative;
        left: -4px;
    }

    .radiogroup, .radiogroup label {
        display: flex;
    }

    .radiogroup label input[type="radio"] {
        top: -3px !important;
    }

    .number-min, .number-max, .number-score {
        max-width: unset;
    }

    .flex-nowrap {
        flex-wrap: nowrap !important;
        flex: 1 !important;
    }

    .required-question {
        background-position-x: 2px;
    }
}