:root {
    --primary-color: #008188;
    --bs-primary: var(--primary-color);
    --bs-primary-rgb: 0, 129, 136;
    --bs-link-color: var(--primary-color);
    --bs-link-hover-color: #00656b;
    --bs-focus-ring-color: rgba(0, 129, 136, 0.25);
    /* Dash's built-in components (Dropdown, Checklist/RadioItems, DatePicker,
       Slider, buttons, text inputs, ...) derive all of their hover/selected/
       focus colors from these two variables. Override them so those native
       components match the app's primary color instead of Dash's default
       purple (#7f4bc4). Use !important so this wins regardless of the load
       order between this stylesheet and Dash's own (equally-specific) :root
       rule. */
    --Dash-Fill-Interactive-Strong: var(--primary-color) !important;
    --Dash-Fill-Interactive-Weak: rgba(0, 129, 136, 0.12) !important;
    --text-default: #404145;
    --text-secondary: #9fa3aa;
    --code-bg: #f1f2f3;
    --code-text: #404145;
    --info-bg: #c7e0f9;
    --info-text: #0054a1;
    --warning-bg: #ffc400;
    --warning-text: #2c2d30;
    --error-bg: #eb1212;
    --error-text: white;
}

body {
    color: var(--text-default);
}

a {
    color: var(--primary-color);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 500;
}
h1 {
    font-size: 1.71429rem;
}
h2 {
    font-size: 1.42857rem;
}
h3 {
    font-size: 1.28571rem;
}
h4 {
    font-size: 1.14286rem;
}

.toplevel-container-div {
    padding: 1rem;
}

.padded-div {
    padding-left: 1rem;
    padding-right: 1rem;
}

.title-small {
    font-size: 0.9rem;
}

.bold-text {
    font-weight: bold;
}

.grey-text {
    color: var(--text-secondary);
}

.calculate-optimisation-button {
    margin-top: 1rem;
    margin-bottom: 2rem;
    width: 200px;
}

#bills-calculate-optimisation-button {
    width: 300px;
}

#bills-calculate-all-optimisation-button {
    width: 400px;
    margin-left: 5px;
}

.positive-button,
.positive-button:active,
.positive-button:focus {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}
.positive-button:hover {
    background: white;
    border-color: var(--primary-color);
    color: var(--primary-color);
}
.positive-button:disabled {
    background: var(--primary-color);
    border-color: white;
    opacity: 0.4;
    cursor: not-allowed;
}

input[type='checkbox'],
input[type='radio'] {
    accent-color: var(--primary-color);
}

.form-check-input:hover,
.form-check-input:focus {
    border-color: var(--primary-color);
}

.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 129, 136, 0.25);
}

.Select.is-focused:not(.is-open) > .Select-control,
.Select.is-open > .Select-control {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 129, 136, 0.18);
}

.Select-option:hover,
.Select-option.is-focused {
    background-color: rgba(0, 129, 136, 0.12);
    color: var(--primary-color);
}

.Select-option.is-selected {
    background-color: var(--primary-color);
    color: white;
}

.Select.is-open .Select-arrow,
.Select .Select-arrow-zone:hover > .Select-arrow {
    border-top-color: var(--primary-color);
}

.CalendarDay__selected,
.CalendarDay__selected:hover,
.CalendarDay__selected:active {
    background: var(--primary-color);
    border: 1px double var(--primary-color);
    color: white;
}

.CalendarDay__selected_span,
.CalendarDay__selected_span:hover,
.CalendarDay__selected_span:active,
.CalendarDay__hovered_span,
.CalendarDay__hovered_span:hover {
    background: rgba(0, 129, 136, 0.12);
    border-color: rgba(0, 129, 136, 0.12);
    color: var(--primary-color);
}

/* Checkbox styling to match Dexma UI Components */
.dexma-checkbox {
  width: 18px;
  height: 18px;
  margin-right: 8px;
  margin-bottom: 4px;
  position: relative;
  vertical-align: middle;
  appearance: none;
  -webkit-appearance: none;
  background-color: #fff;
  border: 2px solid #e1e5eb;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.dexma-checkbox:hover {
  border-color: var(--primary-color);
}
.dexma-checkbox:active,
.dexma-checkbox:checked {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}
.dexma-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.dexma-checkbox:disabled {
  background-color: #f1f2f3;
  border-color: #e1e5eb;
  cursor: not-allowed;
  opacity: 0.7;
}

.checkbox-label {
  cursor: pointer;
  margin-bottom: 0 !important;
  font-size: 1em;
  display: inline-flex;
  align-items: center;
  user-select: none;
}

/* Alert styling with icons */
.alert-icon {
  margin-top: -8px;
}

.alert-container {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.alert-icon-container {
  flex-shrink: 0;
  margin-top: 2px;
}

/* Target any element that is not .alert-icon-container but is a child of .alert-container */
.alert-container > *:not(.alert-icon-container) {
  flex-grow: 1;
  margin-bottom: 0;
}

.alert-container > *:not(.alert-icon-container) > * {
  margin-bottom: 0;
}

/* Specific fixes for Markdown content */
.alert-container > .dash-markdown p:first-child,
.alert-container > .dash-markdown ul:first-child {
  margin-top: 0;
}

.alert-container > .dash-markdown p:last-child,
.alert-container > .dash-markdown ul:last-child {
  margin-bottom: 0;
}

/* Ensure icon doesn't stretch */
.alert-icon {
  width: 24px;
  height: 24px;
  min-width: 24px;
}

.data-info {
    background-color: var(--info-bg);
    margin-bottom: 2rem;
    border: none;
    font-weight: 600;
}
.data-info, 
.data-info * {
    color: var(--info-text);
}

.data-warning {
    background-color: var(--warning-bg);
    margin-bottom: 2rem;
    border: none;
    font-weight: 600;
}
.data-warning, 
.data-warning * {
    color: var(--warning-text);
}

.data-error {
    background-color: var(--error-bg);
    margin-bottom: 2rem;
    border: none;
    font-weight: 600;
}
.data-error, 
.data-error * {
    color: var(--error-text);
}

#data-completeness-alert > div > p, 
#data-completeness-alert > div > ul {
    margin-block-end: 0;
}

.DateInput_input {
    padding: 5px 11px 5px !important;
}

.optimisation-results-table {
    max-width: 70%;
    font-size: 14px;
    margin-top: 1rem !important;
}

.splash-container {
    text-align: center;
}

.empty-div {
    margin: 3rem;
}

.no-grow {
    flex-grow: 0;
}

.DateInput_input__disabled {
    font-style: normal !important;
}

.no-padding {
    padding: 0;
}

.results-spinner {
    align-self: flex-start;
    width: 100%;
}

.results-spinner .dash-sk-circle .dash-sk-child:before {
    background-color: var(--primary-color) !important;
}

.results-div {
    min-height: 4rem;
}

.optimisation-results-table td.difference-value {
    font-weight: normal;
}

.optimisation-results-table td.difference-value--good {
    color: #008759 !important;
}

.optimisation-results-table td.difference-value--bad {
    color: #EB1212 !important;
}

.optimisation-results-table td.difference-value--neutral {
    color: var(--text-default) !important;
}

.optimisation-results-table td.difference-value--total {
    font-weight: 600;
}

.toplevel-container-div {
    min-height: 100vh;
}

/* Dash Tabs styling to match Dexma UI components */
.tab-container {
  border-bottom: 1px solid #e1e5eb;
  display: flex !important;
  justify-content: flex-start !important;
}

.tab {
    font-size: 1em;
    background-color: white !important;
    color: var(--text-default);
    transition: all 0.2s ease;
    border: 0px !important;
    box-shadow: none;
    cursor: pointer;
    margin-right: 32px;
    padding: 12px 0;
    flex: 0 0 auto !important;
    width: auto !important;
}
.tab:active,
.tab:hover {
  color: var(--primary-color) !important;
  border-bottom: none;
}

.tab--selected {
    border-bottom: 3px solid var(--primary-color) !important;
    color: var(--primary-color) !important;
}

.tab-content {
  padding-top: 20px;
}

/* Drag and drop & button file upload */
#bills-file-upload > div {
    width: 100%;
    height: 60px;
    line-height: 60px;
    border-width: 2px !important;
    border-style: dashed !important;
    border-radius: 4px;
    text-align: center;
    cursor: pointer;
    font-size: 1rem;
    color: var(--primary-color) !important;
    background-color: white !important;
    border: 1px solid var(--primary-color);
    transition: all 0.2s ease-in-out;
    margin-top: 20px;
}
#bills-file-upload > div:active,
#bills-file-upload > div:hover {
    background-color: var(--primary-color) !important;
    color: white !important;
}

/* Download template xlsx file */
#btn-xlsx {
    font-size: 1rem;
    background-color: white;
    border: 1px solid var(--text-secondary);
    border-radius: 4px;
    padding: 8px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    text-decoration: none;
    margin-left: 16px;
    line-height: 1.5;
}
#btn-xlsx:active,
#btn-xlsx:hover {
    background-color: var(--text-secondary);
    color: white;
}

/* Beta label */
#bills-tab > span::after {
    margin-left: 10px;
    padding: 1px 4px;
    border-radius: 4px;
    font-size: 13px;
    background-color: rgb(200, 240, 242);
    color: rgb(64, 65, 69);
    content: "Beta";
}

#svg-legend-bills-table {
    margin: 70px 0 0 30px;
}

code {
    color: var(--code-text);
    background-color: var(--code-bg);
    padding: 0 3px 0 2px;
    border-radius: 3px;
}

.formula-details-div {
    max-width: 850px;
}

.formula-details-div img {
    max-width: 100%;
    height: auto;
    display: block;
}
