/* Import Raleway font */
@import url('https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,400;0,800;1,400;1,800&display=swap');

/* Root variables */
:root {
  --theme-color: var(--bs-primary, #2780E3);
  --body-background-color: #f2f6f9;
  --progressbar-position: top;
  --progress-bar-height: 10px;
  --progress-color: color-mix(in srgb, var(--theme-color) 80%, transparent);
  --footer-height: calc(1rem * 2 + 1.5em);
}

/* Styles for container and wrapper */
.sd-container {
    display: inline-block;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 0.5rem;
    background-color: #f9f9f9;
    margin: 0.5rem;
}

.sd-wrapper {
    text-align: center;
    margin: 0.5rem;
}

/* Layout */
body {
  background-color: var(--body-background-color);
}

.container-fluid .content {
  max-width: 800px;
  margin: 0 auto !important;
  padding: 0 0 5px !important;
}

.container-fluid {
  padding-bottom: 7rem;
}

/* Typography */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  margin-top: 0.5rem !important;
  margin-bottom: 0.5rem !important;
}

p, .form-group, .control-label {
  margin-bottom: 0.5rem;
}

.control-label, .radio label, .checkbox label {
  font-weight: normal;
  font-size: 1.1em;
}

/* Form elements */
.form-group {
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 1rem;
  background-color: #f9f9f9;
  margin-bottom: 1rem;
}

.form-group > label.control-label {
  margin-top: 0;
  margin-bottom: 0.3rem;
}

.form-control:focus {
  border-color: var(--theme-color);
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--theme-color) 25%, transparent);
}

.question-container {
  margin-left: auto;
  margin-right: auto;
  margin-bottom: auto;
  position: relative;
}

.shiny-input-container:not(.shiny-input-container-inline) {
  width: 100%;
}

/* Hidden Asterisk */
.hidden-asterisk {
  display: none;
  color: red;
  font-size: 1.5em;
  position: absolute;
  top: 0;
  right: 0.5em;
}

/* Radio and Checkbox styling */
.radio-inline,
.checkbox-inline,
.radio label,
.checkbox label {
  padding-bottom: 0.25rem;
}

.radio label span,
.checkbox label span {
  margin-left: 0.5rem;
}

.radio-group-buttons .btn-group-container-sw,
.checkbox-group-buttons .btn-group-container-sw {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  row-gap: 5px;
}

.checkbox-group-buttons .btn-group-container-sw {
  column-gap: 5px;
}

.radio-group-buttons .btn,
.checkbox-group-buttons .btn,
.btn-group-container-sw .btn {
  border: 1px solid var(--theme-color);
  background-color: color-mix(in srgb, var(--theme-color) 10%, white);
  color: var(--theme-color);
  transition: all 0.3s ease;
  white-space: normal;
  word-wrap: break-word;
}

.radio-group-buttons .btn:hover,
.checkbox-group-buttons .btn:hover,
.btn-group-container-sw .btn:hover {
  z-index: 1;
  background-color: color-mix(in srgb, var(--theme-color) 20%, white);
}

.radio-group-buttons .btn:first-child,
.checkbox-group-buttons .btn:first-child,
.btn-group-container-sw .btn:first-child {
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

.radio-group-buttons .btn:last-child,
.checkbox-group-buttons .btn:last-child,
.btn-group-container-sw .btn:last-child {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
  margin-right: 0;
}

.radio-group-buttons .btn.active,
.checkbox-group-buttons .btn.active,
.btn-group-container-sw .btn.active {
  background-color: color-mix(in srgb, var(--theme-color) 80%, white);
  color: white;
  z-index: 2;
}

/* Date range styling */
.shiny-date-range-input .input-group-addon {
  background: none;
  border: none;
  padding: 0 10px 0 5px;
}

/* Progress bar */
#progressbar {
  position: fixed;
  left: 0;
  right: 0;
  height: var(--progress-bar-height);
  z-index: 1000;
  background-color: #ECE8DF;
}

#progressbar.top {
  top: 0;
}

#progressbar.bottom {
  bottom: 0; /* Default position at very bottom when no footer */
}

/* When the footer exists, adjust bottom progress bar position */
:has(.footer) #progressbar.bottom {
  bottom: var(--footer-height);
}

#progressbar > div {
  width: 0%;
  height: 100%;
  background-color: var(--progress-color);
  transition: width 0.4s ease;
}

/* Buttons */
.btn-primary,
.btn-primary:hover,
.btn-primary:active,
.btn-primary:focus,
.action-button {
  background-color: var(--theme-color);
  border-color: var(--theme-color);
  color: #ffffff;
}

.action-button {
  background-color: color-mix(in srgb, var(--theme-color) 70%, transparent);
  transition: background-color 0.3s ease;
}

.action-button:hover,
.action-button:focus {
  background-color: var(--theme-color);
}

/* Links */
a:hover {
  color: color-mix(in srgb, var(--theme-color) 80%, black);
}

/* Media Queries */
@media screen and (max-width: 767px) {
  .radio-group-buttons .btn-group-container-sw,
  .checkbox-group-buttons .btn-group-container-sw {
    flex-direction: column;
  }
}

/* Footer styling */
.footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 1rem;
    height: var(--footer-height);
    background-color: color-mix(in srgb, var(--body-background-color) 90%, black);
    border-top: 1px solid #eee;
    color: #666;
    z-index: 999;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 800px;
    margin: 0 auto;
    height: 100%;
}

.footer-content.center {
    justify-content: center;
}

.footer-left {
    text-align: left;
    margin-right: auto;
}

.footer-center {
    text-align: center;
    flex: 1;
}

.footer-right {
    text-align: right;
    margin-left: auto;
}

.footer a {
    color: var(--theme-color);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
    color: color-mix(in srgb, var(--theme-color) 80%, black);
}

/* Matrix question styling */
.matrix-question-container {
    width: 100%;
    overflow-x: auto;
}

.matrix-question-container .form-group {
    border: none;
    padding: 0 0 1rem 0;
    margin-bottom: 0;
}

.matrix-question {
    width: 100%;
    border-collapse: collapse;
    font-size: 18px;
}

.matrix-question th, .matrix-question td {
    padding: 0;
    text-align: center;
    border: none;
    height: 10px;
    vertical-align: middle;
}

.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th {
  vertical-align: middle;
  padding: 4px;
}

.matrix-question th {
    background-color: transparent;
    font-weight: bold;
    font-size: 18px;
}

.table {
  --bs-table-striped-bg: #f9f9f9;
}

.matrix-question tr:nth-child(even) {
    background-color: #f9f9f9;
}

.matrix-question tr:nth-child(odd) {
    background-color: #f9f9f9;
}

.matrix-question .shiny-options-group {
    display: flex;
    justify-content: center; /* Center the radio buttons */
    width: 100%;
}

.matrix-question .shiny-options-group .radio {
    margin: 0;
    flex: 1;
    text-align: center;
}

.matrix-question .shiny-options-group .radio label {
    padding-left: 0;
    display: inline-block;
}

.matrix-question .shiny-options-group .radio input {
    margin: 0;
    position: relative;
    top: 0.5rem; /* radio button position */
}

/* Hide radio button labels */
.matrix-question .shiny-options-group .radio span {
    display: none;
}

/* Style for the sub-question labels */
.matrix-question td:first-child {
    text-align: left;
    font-weight: normal;
    padding-left: 15px; /* Add some left padding */
}

/* Container Borders */
.question-container[data-question-id] input[type="text"],
.question-container[data-question-id] input[type="number"],
.question-container[data-question-id] textarea,
.question-container[data-question-id] select {
  border: 1px solid #ddd;
}

.question-container[data-question-id] input[type="radio"],
.question-container[data-question-id] input[type="checkbox"] {
  border-color: #ddd;
}

/* SweetAlert custom styling */
div:where(.swal2-container) .swal2-popup {
  font-size: 1rem !important;
}

div:where(.swal2-container) .swal2-html-container {
  padding: 0 2em;
}

/* Exit pop-up */
.modal {
  display: block !important;
  opacity: 1 !important;
}

.modal-backdrop {
  opacity: 0.5 !important;
}

.modal-dialog {
  z-index: 1050 !important;
}

.modal-body .shiny-input-container .control-label {
  text-align: center;
  width: 100%;
}

/* Required question highlighting */

.required-question-highlight .form-group,
.required-question-highlight.form-group {
  border-color: #dc3545 !important;
  background-color: rgba(220, 53, 69, 0.1) !important;
}

.required-question-highlight .form-control {
  border-color: #dc3545 !important;
}

.required-question-highlight .form-control:focus {
  border-color: #dc3545 !important;
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}

/* Validation question highlighting (red, highest priority) */

.validation-question-highlight .form-group,
.validation-question-highlight.form-group {
  border-color: #dc3545 !important;
  background-color: rgba(220, 53, 69, 0.1) !important;
}

.validation-question-highlight .form-control {
  border-color: #dc3545 !important;
}

.validation-question-highlight .form-control:focus {
  border-color: #dc3545 !important;
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}

/* Unanswered question highlighting (blue) */

.unanswered-question-highlight .form-group,
.unanswered-question-highlight.form-group {
  border-color: #007bff !important;
  background-color: rgba(0, 123, 255, 0.1) !important;
}

.unanswered-question-highlight .form-control {
  border-color: #007bff !important;
}

.unanswered-question-highlight .form-control:focus {
  border-color: #007bff !important;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25) !important;
}

/* Unanswered question highlighting (orange) */

.unanswered-question-highlight-orange .form-group,
.unanswered-question-highlight-orange.form-group {
  border-color: #fd7e14 !important;
  background-color: rgba(253, 126, 20, 0.1) !important;
}

.unanswered-question-highlight-orange .form-control {
  border-color: #fd7e14 !important;
}

.unanswered-question-highlight-orange .form-control:focus {
  border-color: #fd7e14 !important;
  box-shadow: 0 0 0 0.2rem rgba(253, 126, 20, 0.25) !important;
}

/* Unanswered question highlighting (green) */

.unanswered-question-highlight-green .form-group,
.unanswered-question-highlight-green.form-group {
  border-color: #28a745 !important;
  background-color: rgba(40, 167, 69, 0.1) !important;
}

.unanswered-question-highlight-green .form-control {
  border-color: #28a745 !important;
}

.unanswered-question-highlight-green .form-control:focus {
  border-color: #28a745 !important;
  box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25) !important;
}

/* Unanswered question highlighting (purple) */

.unanswered-question-highlight-purple .form-group,
.unanswered-question-highlight-purple.form-group {
  border-color: #6f42c1 !important;
  background-color: rgba(111, 66, 193, 0.1) !important;
}

.unanswered-question-highlight-purple .form-control {
  border-color: #6f42c1 !important;
}

.unanswered-question-highlight-purple .form-control:focus {
  border-color: #6f42c1 !important;
  box-shadow: 0 0 0 0.2rem rgba(111, 66, 193, 0.25) !important;
}

/* Unanswered question highlighting (gray) */

.unanswered-question-highlight-gray .form-group,
.unanswered-question-highlight-gray.form-group {
  border-color: #6c757d !important;
  background-color: rgba(108, 117, 125, 0.1) !important;
}

.unanswered-question-highlight-gray .form-control {
  border-color: #6c757d !important;
}

.unanswered-question-highlight-gray .form-control:focus {
  border-color: #6c757d !important;
  box-shadow: 0 0 0 0.2rem rgba(108, 117, 125, 0.25) !important;
}

/* Priority system: red highlighting overrides all unanswered colors */
.required-question-highlight.unanswered-question-highlight .form-group,
.required-question-highlight.unanswered-question-highlight.form-group,
.required-question-highlight.unanswered-question-highlight-orange .form-group,
.required-question-highlight.unanswered-question-highlight-orange.form-group,
.required-question-highlight.unanswered-question-highlight-green .form-group,
.required-question-highlight.unanswered-question-highlight-green.form-group,
.required-question-highlight.unanswered-question-highlight-purple .form-group,
.required-question-highlight.unanswered-question-highlight-purple.form-group,
.required-question-highlight.unanswered-question-highlight-gray .form-group,
.required-question-highlight.unanswered-question-highlight-gray.form-group {
  border-color: #dc3545 !important;
  background-color: rgba(220, 53, 69, 0.1) !important;
}

.required-question-highlight.unanswered-question-highlight .form-control,
.required-question-highlight.unanswered-question-highlight-orange .form-control,
.required-question-highlight.unanswered-question-highlight-green .form-control,
.required-question-highlight.unanswered-question-highlight-purple .form-control,
.required-question-highlight.unanswered-question-highlight-gray .form-control {
  border-color: #dc3545 !important;
}

.required-question-highlight.unanswered-question-highlight .form-control:focus,
.required-question-highlight.unanswered-question-highlight-orange .form-control:focus,
.required-question-highlight.unanswered-question-highlight-green .form-control:focus,
.required-question-highlight.unanswered-question-highlight-purple .form-control:focus,
.required-question-highlight.unanswered-question-highlight-gray .form-control:focus {
  border-color: #dc3545 !important;
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}

/* Numeric input spinner styling */
.numeric-input-container {
  position: relative;
  display: inline-block;
  width: 100%;
}

.numeric-input-with-spinner {
  padding-right: 0 !important;
}

.numeric-input-with-spinner::-webkit-outer-spin-button,
.numeric-input-with-spinner::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.numeric-input-with-spinner[type=number] {
  -moz-appearance: textfield;
}

.native-spinner {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: calc(100% - 4px);
  display: flex;
  flex-direction: column;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: linear-gradient(to bottom, #f9f9f9 0%, #f0f0f0 100%);
  overflow: hidden;
}

.native-spinner-button {
  flex: 1;
  border: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  font-size: 0;
  outline: none;
}

.native-spinner-button:hover {
  background: rgba(0,0,0,0.05);
}

.native-spinner-button:active {
  background: rgba(0,0,0,0.1);
}

.native-spinner-button::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
}

.spinner-up::before {
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-bottom: 4px solid #666;
}

.spinner-down::before {
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-top: 4px solid #666;
}

.native-spinner-button:not(:last-child) {
  border-bottom: 1px solid #ccc;
}

/* Navigation buttons styling */
.sd-nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  width: 100%;
  clear: both;
}

.sd-nav-button {
  min-width: 100px;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.sd-nav-prev {
  margin-right: auto;
}

.sd-nav-next {
  margin-left: auto;
}

/* Ensure navigation buttons work well on mobile */
@media screen and (max-width: 767px) {
  .sd-nav-button {
    min-width: 80px;
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
  }
}
