@use "sass:map";

@import "bootstrap/functions";

/* Define core theme colors as variables */

$primary: #8b48b3;
$danger: #dd7685;
$success: #8b48b3;
$tertiary: #9fdd76;
$quaternary: #ecd8fb;
$cardBg: transparent;
$deEmphasized: #556272;
$customWhite: #fff;
$customBlack: #181f2f;

@import "bootstrap/variables";
@import "bootstrap/variables-dark";

/* Tweak and extend default Bootstrap spacer size definitions */

$custom-spacers: (
  5: $spacer * 2,
  6: $spacer * 2.5,
  7: $spacer * 3,
);

$spacers: map.deep-merge($spacers, $custom-spacers);

/* Tweak and extend default Bootstrap theme and validation colors */

$theme-colors: (
  "primary": $primary,
  "danger": $danger,
  "success": $success,
  "warning": $warning,
);

$validation-colors: (
  "valid": (
    "color": $success,
    "border-color": $success,
    "tooltip-color": $success,
  ),
  "invalid": (
    "color": $danger,
    "border-color": $danger,
    "tooltip-color": $danger,
  ),
);

$form-validation-states: map.deep-merge(
  $form-validation-states,
  $validation-colors
);

/* Tweak default Bootstrap accordion colors */

$accordion-bg: $cardBg;
$accordion-button-active-bg: $cardBg;
$accordion-button-bg: $cardBg;
$accordion-body-padding-y: 0.375rem;

/* Selectively load Bootstrap components */

@import "bootstrap/maps";
@import "bootstrap/mixins";
@import "bootstrap/utilities";

// Layout & components
@import "bootstrap/root";
@import "bootstrap/reboot";
@import "bootstrap/type";
@import "bootstrap/images";
@import "bootstrap/containers";
@import "bootstrap/grid";
// @import "bootstrap/tables";
@import "bootstrap/forms";

/* this fix is for a bug(?) in bootstrap5 wherein this extremely specific background-image
   setting for select drop-downs which have failed validation (which is intended to paint both
   an "invalid!" warning symbol _and_ the dropdown carat) is unintentionally cascaded over 
   by the baseline definition for invalid form fields, 86ing the carat. this fixes that. */
.was-validated .form-select:invalid:not([multiple]):not([size]),
.was-validated .form-select:invalid:not([multiple])[size="1"],
.form-select.is-invalid:not([multiple]):not([size]),
.form-select.is-invalid:not([multiple])[size="1"] {
  background-image: var(--bs-form-select-bg-img), var(--bs-form-select-bg-icon, none);
}

@import "bootstrap/buttons";
@import "bootstrap/transitions";
@import "bootstrap/dropdown";
@import "bootstrap/button-group";
@import "bootstrap/nav";
@import "bootstrap/navbar";
@import "bootstrap/card";
@import "bootstrap/accordion";
@import "bootstrap/breadcrumb";
// @import "bootstrap/pagination";
@import "bootstrap/badge";
@import "bootstrap/alert";
// @import "bootstrap/progress";
@import "bootstrap/list-group";
@import "bootstrap/close";
// @import "bootstrap/toasts";
@import "bootstrap/modal";
// @import "bootstrap/tooltip";
// @import "bootstrap/popover";
// @import "bootstrap/carousel";
// @import "bootstrap/spinners";
// @import "bootstrap/offcanvas";
// @import "bootstrap/placeholders";

/* Extend .invalid-feedback button styling into django-bootstrap template defaults */

.help-block.error-msg {
  @extend .invalid-feedback;
  display: block;
}

/* Customize default Bootstrap button styling by leveraging available @includes */

.btn-secondary {
  @include button-variant(
    $customWhite,
    $customWhite,
    $customBlack,
    $primary,
    $primary,
    $primary
  );
}
.btn-tertiary {
  @include button-variant($primary, $primary);
}
.btn-quaternary,
.collapsed .btn-primary {
  @include button-variant($quaternary, $quaternary);
}
.btn-unmet {
  @include button-variant($deEmphasized, $deEmphasized);
}

.btn-check:checked + label {
  .btn.btn-tertiary {
    @include button-variant($tertiary, $tertiary);
  }
}

// Helpers
@import "bootstrap/helpers";

// Utilities
@import "bootstrap/utilities/api";
// scss-docs-end import-stack
