/** TABLE OF CONTENTS
 *  1. General
 *  2. Contact Form
 *    2.1 Columns & Rows
 *    2.2 Control spacings in contact form
 *    2.2.1 Spacing for reversed rows
 *    2.3 Control contact forms field stylings
 *      2.3.1 Customize Select Menus
 *      2.3.2 Customize Checkboxes + Radiobuttons
 *      2.3.3 Customize Upload Buttons
 *      2.3.4 Customize form submit button
 *      2.3.5 Customize Loading animation
 *      2.3.6 Goodbye message container
 *      2.3.7 Required form fields
 *  3. Responsiveness
 */

/* 1. General */

html {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.contact-form-container .missing-form-field {
  border-color: red;
}

/* 2. Contact Form */

.database-operation-feedback {
  z-index: 999;
  position: fixed;
  top: 0;
  background-color: white;
  color: black;
}

#custom-contact-form-container {
  max-height: 2500px;
  opacity: 1;
  overflow-y: hidden;
  transition: max-height 1s ease-in-out, opacity 1s;
}

/* 2.1 Columns & Rows */

.contact-form-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0 20px;
  margin: 0 auto;
}

/* Enable flex-wrap in mobile view, as row column widths may expand to over 100%
 * in mobile view, as half row column widths will expand to 100%, quarter row
 * column widths to 50%, etc., in mobile view
 */
.contact-form-section {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
}

/* In mobile view, indicated row widths are doubled */
.full-sections-width {
  width: 100%;
  display: flex;
}

.half-sections-width {
  width: 100%;
  display: flex;
}

.quarter-sections-width {
  width: 48%;
  display: flex;
}

.field-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
}

.full-parent-width {
  width: 100%;
}

.half-parent-width {
  width: 50%;
}

.quarter-parent-width {
  width: 25%;
}

.three-quarters-parent-width {
  width: 75%;
}

div > .field-container.half-parent-width {
  width: 49%;
}

div > .field-container.quarter-parent-width {
  width: 24%;
}

div > .field-container.three-quarters-parent-width {
  width: 74%;
}

/* Remove margin from every half row width column container for mobile sizes, as
 * they will all be displayed one below the other, because they're expanded to
 * full width in mobile view
 */
.contact-form-section > .half-sections-width {
  margin-right: 0;
}

.field-container > * {
  width: 100%;
}

.sub-rows-container {
  display: flex;
  flex-direction: column;
}

.contact-form-sub-row {
  display: flex;
  flex-direction: row;
}

div > .field-container:first-child:not(.full-parent-width) {
  margin-right: 1%;
}

div > .field-container:not(:first-child) {
  margin-left: 1%;
}

/* Reverse flex wrap behaviour where needed */
.reverse-wrap-on-mobile {
  flex-wrap: wrap-reverse;
}

/* 2.2 Control spacings in contact form */

.contact-form-label {
  padding-bottom: 10px;
}

.contact-form-section > div:not(:last-child),
.contact-form-section,
.contact-form-section .contact-form-sub-row:not(:last-child) {
  margin-bottom: 10px;
}

.contact-form-container .contact-form-section .only-rows-full-width-column {
  margin-right: 0;
}

/* 2.3 Control contact forms field stylings */

.contact-form-container textarea,
.contact-form-container input,
.contact-form-container select,
.select-menu-container {
  width: 100%;
}

.contact-form-container textarea,
.contact-form-container input,
.contact-form-container select {
  border: 1px solid lightgray;
  border-radius: 6px;
  height: 40px;
  /* Add left and right padding from field content to borders, and box-sizing added again to avoid that this resizes widths*/
  padding: 0 7px;
  box-sizing: border-box;
  font-family: inherit;
}

.contact-form-container textarea {
  height: auto;
  padding: 7px;
  resize: none;
}

/* Add box shadow when focused */
/*.contact-form-container textarea:focus,
.contact-form-container input:focus,
.contact-form-container select:focus {
  box-shadow: 1px 1px 9px rgb(228,0,69);
}*/

select,
input,
textarea {
  padding: 0;
}

/* 2.3.1 Customize Select Menus */

.select-menu-container {
  position: relative;
  display: flex;
  align-items: center;
  /* Select tag must be set to slightly higher height than inputs to have the same height */
}

.contact-form-container select {
  /* Auto-adapts height */
  flex-grow: 1;
  /* Removes default select arrow */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  /* Height has to be set to be higher as inputs to have the same size on FE */
  height: 42px;
  border: 1px solid lightgray;
  border-radius: 4px;
}

/* Hide select arrow in IE */
select::-ms-expand {
  display: none;
}

/* Remove focusring added by browser */
*:-moz-focusring {
	outline: none;
}

/* Remove focusring in Chrome and Safari from form elements */
*:focus {
  outline: none;
}

select:hover {
  cursor: pointer;
}

.select-menu-icon {
  position: absolute;
  width: 20px;
  height: 20px;
  right: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  top: 12px;
}

.select-menu-icon::after {
  content: "v";
  transform: scale(1.5,0.8);
  color: red;
}

/* 2.3.2 Customize Checkboxes + Radiobuttons */

input[type="checkbox"],
input[type="radio"] {
  display: none;
}

.checkbox-option-description {
  position: relative;
  padding-left: 40px;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-wrap: wrap;
}

.customized-checkbox {
  position: absolute;
  left: 10px;
  width: 20px;
  height: 20px;
  border: 1px solid lightgray;
  border-radius: 3px;
  display: flex;
  justify-content: center;
  align-items: center;
  left: 0;
  top: 0;
}

.customized-checkbox::after {
  position: absolute;
  width: 5px;
  height: 10px;
  border-bottom: 2px solid black;
  border-right: 2px solid black;
  transform: rotate(45deg);
  content: "";
  bottom: 5px;
  display: none;
}

input:checked ~ .customized-checkbox::after {
  display: block;
}

.checkbox-option-description:hover input:not(:checked) ~ .customized-checkbox {
  background-color: lightgray;
}

/*.checkbox-option-description:focus input ~ .customized-checkbox {
  box-shadow: 1px 1px 9px rgb(228,0,69);
}*/

.checkbox-option-description:hover {
  cursor: pointer;
}

/* 2.3.3 Customize Upload Buttons */

/* When using visibility hidden or display none, assistive technology interprets to mean the file input isn't interactive. */
input[type="file"] {
  display: none;
}

.custom-upload-button {
  padding: 12px 20px;
  background-color: red;
  border-radius: 2px;
}

.custom-upload-button:hover {
  cursor: pointer;
  color: white;
}

.upload-button-label-container {
  display: flex;
  margin: 1.5rem 0;
}

.upload-file-preview {
  display: flex;
  justify-content: center;
  align-items: center;
}

.upload-file-preview ul {
  margin: 0;
  padding: 0;
}

.upload-file-preview li {
  list-style-position: inside;
}

.upload-button-container {
  display: flex;
  flex-direction: column;
}

.file-upload-error {
  color: red;
  margin-left: 20px;
}

/* 2.3.4 Customize form submit button */

.contact-form-submit-button {
  padding: 10px 25px;
  color: white;
  background-color: rgb(228,0,69);
  border: 2px solid rgb(228,0,69);
  transition: background-color 0.5s, color 0.5s;
  font-size: 1.2rem;
  white-space: nowrap;
  font-family: inherit;
  width: auto;
}

.contact-form-submit-button:hover,
.contact-form-submit-button:focus {
  background-color: white;
  color: rgb(228,0,69);
  cursor: pointer;
}

/* 2.3.5 Customize loading animation */

.loading-icon {
  display: block;
  height: 30px;
  width: 30px;
  background-color: black;
  border-radius: 15px;
  border-right: 2px solid white;
  border-bottom: 2px solid white;
  animation-name: loader;
  animation-duration: 0.75s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  transition: background-color 0.5s, border-color 0.5s;
}

#submit-contact-form:hover .loading-icon,
#submit-contact-form:focus .loading-icon {
  background-color: white;
  border-right: 2px solid black;
  border-bottom: 2px solid black;
}

@keyframes loader {
  100% { transform:rotate(360deg); }
}

/* 2.3.6 Goodbye message container */

#thank-you-par {
  height: 100px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Arial';
  font-weight: bold;
  padding: 20px;
}

/* 2.3.7 Reqired Form Fields */

.required-form-field {
  width: auto;
}

.required-form-field::after {
  content: "*";
  margin-left: 3px;
  color: black;
}

/* 3. Responsiveness - Double all the column widths at the breakpoint of 1280px */

@media (min-width:1095px) {

  /* Make contact form rows and columns responsive */
  /* Add a right margin to all field containers, except if it's the only field of
   * a row, which is when the "full-parent-width" class will be attached onto it.
   * This is only needed for desktop view */
   .contact-form-section > div:first-child {
     margin-right: 1%;
   }

   .contact-form-section > div:not(:first-child) {
     margin-left: 1%;
   }

  /* In desktop view, half a row width equals 48% (2% to account for the margins) */
  .half-sections-width {
    width: 49%;
  }

  .quarter-rows-width {
    width: 24%;
  }

  /* Avoid contact form rows to wrap in desktop view, because total won't exceed 100% width */
  .contact-form-section {
    flex-wrap: nowrap;
  }

  /* Turn off bottom margin of section container of sections which hold columns
   * with multiple rows, otherwise bottom margin is doubled in desktop view
   */
  .page-container .contact-form-container .multiple-rows-section {
    margin-bottom: 0;
  }

}

/* 2.2.1 Spacing for reversed rows */

@media (max-width:1094px) {

  .reverse-wrap-on-mobile > div:not(:first-child) {
    margin-bottom: 10px;
  }

  .reverse-wrap-on-mobile > div:first-child {
    margin-bottom: 0;
  }

}
