/* Base styles */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: sans-serif;
  overflow-wrap: break-word;
  background-color: #f7f7f7;
  padding: 1rem 2rem;
  color: #333;
}

header {
  display: grid;
  grid-template-areas:
    "h1 user"
    "nav nav"
    "h2 h2";
  align-items: center;
  margin-bottom: 1.25rem;
}

header nav {
  grid-area: nav;
  max-width: 600px;
  padding-top: 0.75rem;
}

header h1 {
  grid-area: h1;
}

header h2 {
  grid-area: h2;
  margin: 0;
  padding: 1.25rem 0 0 0;
}

h1, h2, h3, h4, h5, h6 {
  color: #004080;
}

h1 {
  margin: 0;
}

h2, h3, h4, h5, h6 {
  margin: 0 0 1rem 0;
}

h2:not(:first-child):not(header h2),
h3:not(:first-child),
h4:not(:first-child),
h5:not(:first-child),
h6:not(:first-child) {
  margin-top: 1.75rem;
}

p:first-child {
  margin-top: 0;
}

ul {
  margin-top: 0;
  padding: 0 0 0 1.5rem;
}

ul:last-child {
  margin-bottom: 0;
}

ul:not(:last-child) {
  margin-bottom: 0.75rem;
}

li {
  margin-bottom: 0.1rem;
}

a {
  color: #2563eb;
  text-decoration: none;
  cursor: pointer;
}

a:hover {
  text-decoration: underline;
}

hr {
  border: 0;
  height: 1px;
  background-image: linear-gradient(to right, rgba(0,0,0,0.1), rgba(0,0,0,0.5), rgba(0,0,0,0.1));
  margin: 1.5rem 0;
}

pre {
  white-space: pre-wrap;
}

label {
  display: block;
}

label.bold{
  font-weight: bold;
}

span.label-style {
  display: block;
  font-weight: bold;
}

label:not(:first-child):not(:has(input[type="radio"], input[type="checkbox"])):not(.filter-dropdown-label):not(.tooltip-label),
span.label-style:not(:first-child):not(:has(input[type="radio"], input[type="checkbox"])):not(.tooltip-label) {
  margin-top: 0.75rem;
}

label:not(:last-child):not(:has(input[type="radio"], input[type="checkbox"])):not(.filter-dropdown-label):not(.tooltip-label),
span.label-style:not(:last-child):not(:has(input[type="radio"], input[type="checkbox"])):not(.tooltip-label) {
  margin-bottom: 0.5rem;
}

button,
select,
input:not([type="checkbox"],[type="radio"]),
textarea {
  min-height: 2.25rem;
  height: 2.25rem;
  line-height: 2.25rem;
  padding: 0 0.5rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
}

select,
input[type="file"],
input[type="text"],
input[type="email"],
input[type="password"],
input[type="datetime-local"],
textarea {
  font-family: sans-serif;
  display: block;
  width: 100%;
  min-width: 100%;
  max-width: 100%;
}

input[type="text"],
textarea {
  background: #fff;
}

input::placeholder,
textarea::placeholder {
  color: #999;
}

textarea.email-list {
  max-height: 4.5rem;
}

button,
input[type="submit"],
input[type="button"] {
  margin-top: 0;
  border: none;
  cursor: pointer;
}

.align-centre {
  text-align: center;
}

/* Colour schemes */
.neutral {
  background-color: #ffffff;
  border: 1px solid #d1d5db;
}

.info,
.email-info {
  background-color: #f0f8ff;
  border: 1px solid #d1ecf1;
}

.info-neutral,
.version-info {
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
}

.success {
  background-color: #f0fdf4;
  border: 1px solid #28a745;
  color: #155724;
}

.warning {
  background-color: #fff4e5;
  border: 1px solid #e67e22;
  color: #a84300;
}

.error {
  background-color: #fef2f2;
  border: 1px solid #dc3545;
  color: #dc2626;
}

.neutral, 
.info,
.email-info,
.info-neutral,
.version-info,
.success,
.warning,
.error {
  border-radius: 8px;
}

/* Centered form for user management pages */
.centered-form-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 2rem);
}

.login-form-container {
  width: 100%;
  max-width: 450px;
  text-align: center;
}

/* Boxed Single Panel */
.boxed-panel {
  width: fit-content;
  min-width: 600px;
  max-width: 1200px;
}

/* Two Panel */
.two-panel {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

.form-panel {
  flex: 1;
  max-width: 600px;
}

.results-panel {
  flex: 1;
}

.space-between-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Panel styles */
.styled-panel {
  padding: 1.5rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* Buttons */
.button-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.button-row:not(:last-child) {
  margin-bottom: 1rem;
}

.button-row button,
.button-row input[type="submit"],
.button-row input[type="button"] {
  flex: 1;
}

.button-action {
  background-color: #004080;
  color: white;
}

.button-action:hover {
  background-color: #0066cc;
}

.button-secondary {
  background-color: #e0e0e0;
  color: #333;
}

.button-secondary:hover {
  background-color: #cfcfcf;
}

.button-critical-action {
  background-color: #d97706;
  color: white;
}

.button-critical-action:hover {
  background-color: #b45309;
}

.button-critical-action:disabled {
  background-color: #ddd;
  color: #999;
  cursor: not-allowed;
  opacity: 0.5;
}

.hidden {
  display: none !important;
}

/* User Menu Styles */
.user-menu {
  grid-area: user;
  position: relative;
  justify-self: end;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.user-menu-trigger:hover {
  background: #f8f9fa;
  border-color: #9ca3af;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.user-menu-trigger .dropdown-arrow {
  color: #6b7280;
  font-size: 0.8rem;
  transition: transform 0.2s ease;
}

.user-menu.active .dropdown-arrow {
  transform: rotate(180deg);
}

.user-menu-trigger .user-name {
  font-weight: 600;
  color: #374151;
  font-size: 0.9rem;
}

/* User Dropdown */
.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  min-width: 220px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  z-index: 100;
}

.user-menu.active .user-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-dropdown .dropdown-section:not(:last-child) {
  border-bottom: 1px solid #e8eaed;
}

.user-dropdown .user-email-small {
  padding: 1rem;
  display: block;
  color: #6b7280;
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.user-dropdown .dropdown-section-title {
  padding: 1rem 1rem 0.25rem 1rem;
  display: block;
  font-weight: 600;
  color: #374151;
  font-size: 0.9rem;
}

.user-dropdown .dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: #374151;
  transition: background-color 0.2s ease;
  font-size: 0.9rem;
}

.user-dropdown .dropdown-item:hover {
  text-decoration: none;
  background: #f8f9fa;
  color: #1f2937;
}

/* Navigation Menu */
.nav-menu {
  list-style: none;
  padding: 0;
  display: flex;
  gap: 0.75rem;
}

.nav-item {
  flex: 1 1 0;
}

.nav-link {
  display: block;
  padding: 0.75rem 1.25rem;
  color: #555;
  font-weight: 500;
  font-size: 0.9rem;
  text-align: center;
  transition: all 0.2s ease;
  border: none;
  border-radius: 8px 8px 0 0;
  background: #e8eaed;
  border-bottom: 3px solid transparent;
}

.nav-link:hover {
  text-decoration: none;
  background-color: #d1d5db;
  color: #374151;
  border-bottom-color: #9ca3af;
}

.nav-item.active .nav-link {
  background-color: #ffffff;
  color: #004080;
  border-bottom-color: #004080;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.nav-item.active .nav-link:hover {
  background-color: #ffffff;
  color: #0066cc;
  border-bottom-color: #0066cc;
}

/* Tooltip */
.tooltip-container {
  position: relative;
  display: inline-block;
  margin: 0;
  text-align: left;
}

.tooltip-container:has(label, .label-style) {
  margin-bottom: 0.5rem;
}

.tooltip-container:not(:first-of-type):has(label) {
  margin-top: 0.75rem;
}

.tooltip-container h2 {
  margin: 0;
}

.tooltip-container:has(h2) {
  margin-bottom: 1rem;
}

.tooltip-container a {
  color: #333;
}

.tooltip-container a:hover {
  text-decoration: none;
}

.tooltip-container .tooltip-label {
  border-bottom: 1px dashed dimgray;
  cursor: help;
}

.tooltip-container .tooltip-text {
  visibility: hidden;
  position: absolute;
  
  /* vertically center */
  top: 50%;
  transform: translateY(-50%);
  
  /* basic styles */
  width: max-content;
  padding: 0.6rem;
  border-radius: 8px;
  background: #000;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.5;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);

  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 200;
}
  
.tooltip-container .tooltip-text.left {
  right: 100%;
  margin-right: 13px;
}

.tooltip-container .tooltip-text.right {
  left: 100%;
  margin-left: 13px;
}

.tooltip-container.interactive.active .tooltip-text,
.tooltip-container.static:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

.tooltip-container .tooltip-text::before {
  content: '';
  visibility: hidden;
  position: absolute;
 
  /* vertically center */
  top: 50%;
  transform: translateY(-50%);
 
  /* the arrow */
  border: 8px solid #000;
}

.tooltip-container .tooltip-text.left::before {
  left: 100%;
  margin-right: -5px;
  border-color: transparent transparent transparent black;
}

.tooltip-container .tooltip-text.right::before {
  right: 100%;
  margin-left: -5px;
  border-color: transparent black transparent transparent;
}

.tooltip-container.interactive.active .tooltip-text::before,
.tooltip-container.static:hover .tooltip-text::before {
  visibility: visible;
  opacity: 1;
}

.tooltip-container .tooltip-text a {
  color: #fff;
  text-decoration: underline;
}

.tooltip-container .tooltip-text p,
.tooltip-container .tooltip-text ul,
.tooltip-container .tooltip-text li {
  margin: 0;
  padding: 0;
}

.tooltip-container .tooltip-text ul {
  padding-left: 1rem;
  list-style-type: disc;
}

/* SVG icon */
.icon {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.icon.middle {
  vertical-align: middle;
}

.icon.text-bottom {
  vertical-align: text-bottom;
  margin-left: 0.25rem;
}

a .icon,
button .icon {
  fill: #333;
}

a:hover .icon,
button:hover .icon {
  fill: #2563eb;
}

a.active .icon,
button.active .icon {
  fill: #28a745;
}

/* Display table styles */
.table-container {
  display: table;
  width: 100%;
}

.table-header-row {
  display: table-row;
  font-weight: 600;
}

.table-row {
  display: table-row;
  font-size: 0.9rem;
  transition: background-color 0.3s;
}

.table-row:nth-child(even) {
  background-color: #f8f8f8;
}

.table-row:hover {
  background-color: #dceeff;
}

.table-cell {
  display: table-cell;
}

.table-cell span:not(.tooltip-container) {
  display: inline-block;
  padding: 0.75rem;
}

.bordered-section {
  border: 1px solid #ccc;
  border-radius: 8px;
}

.bordered-section:not(:last-child) {
  margin-bottom: 2rem;
}

/* Pagination */
.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  margin-top: 2rem;

  a {
    padding: 0.5rem 0.75rem;
    color: #333;
    text-decoration: none;
    border-radius: 8px;
    transition: background-color .3s ease;
    font-size: 0.875rem;
  }
  
  a.active,
  a:hover {
    background: #e5e7eb;
  }
}

.pagination-info {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.875rem;
}

/* Layout for user management pages */
.login-form {
  text-align: left;
}

.login-form label {
  margin-bottom: 0.25rem;
  font-weight: bold;
}

.login-form input[type="email"],
.login-form input[type="password"],
.login-form input[type="text"] {
  margin: 0.5rem 0 1rem 0;
}

.login-form button {
  margin-top: 1rem;
}

.login-form-description  {
  text-align: center;
  margin-bottom: 1.5rem;
  color: #6b7280;
  font-size: 0.875rem;
  line-height: 1.5;
}

.login-form-description strong {
  color: #374151;
}

.login-form-section {
  text-align: center;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid #e5e7eb;
}

.login-form-section p {
  margin: 0 0 0.25rem 0;
  color: #6b7280;
  font-size: 0.875rem;
}

.login-form-section a {
  font-weight: 500;
  font-size: 0.875rem;
}

.login-form-message {
  text-align: center;
  font-size: 0.875rem;
  padding: 0.75rem;
  margin-bottom: 1.5rem;
}

.login-form-message p {
  margin: 0.5rem 0;
  padding: 0;
}

/* Password Requirements */
.password-requirements {
  margin-top: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: #f8f9fa;
  border: 1px solid #e8eaed;
  border-radius: 8px;
  font-size: 0.85rem;
}

.password-requirements p {
  margin: 0 0 0.5rem 0;
  font-weight: 600;
  color: #374151;
}

.password-requirements ul {
  margin: 0;
  padding-left: 1.25rem;
  color: #6b7280;
}

.password-requirements li {
  margin-bottom: 0.25rem;
}

/* Grids  */
.grid {
  display: grid;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.tracking-stats {
  grid-template-columns: repeat(5, 1fr);
}

.space-between-container h3 {
  margin: 0;
}

.quick-ref {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-item {
  padding: 1.5rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.grid-item h4 {
  margin-top: 0;
}

.grid-item:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
  /* transform: translateY(-2px); */
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  /* z-index: 100; */
}

.grid-item p {
  margin: 0;
  color: #6b7280;
  font-size: 0.9rem;
  line-height: 1.5;
}

.grid-item code {
  background: #f3f4f6;
  color: #1f2937;
  padding: 0.125rem 0.25rem;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  border: 1px solid #d1d5db;
}

/* Toggle button */
.toggle-button {
  position: relative;
  width: 72px;
  height: 36px;
  overflow: hidden;
  border-radius: 8px;
}

.toggle-button .checkbox {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 3;
}

.toggle-button .knobs,
.toggle-button .layer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.toggle-button .knobs {
  z-index: 2;
}

.toggle-button .layer {
  width: 100%;
  transition: 0.3s ease all;
  z-index: 1;
}

.toggle-button .knobs:before,
.toggle-button .knobs:after,
.toggle-button .knobs span {
  position: absolute;
  top: 4px;
  width: 28px;
  height: 28px;
  text-align: center;
  padding: 7px 0;
  border-radius: 8px;
  transition: 0.3s ease all;
}

.toggle-button .knobs:before {
  content: "";
  left: 4px;
  background-color: #03a9f4;
}

.toggle-button .knobs:after {
  content: "%";
  right: 4px;
  color: #4e4e4e;
}

.toggle-button .knobs span {
  display: inline-block;
  left: 4px;
  color: #fff;
  z-index: 1;
}

.toggle-button .checkbox:checked + .knobs span {
  color: #4e4e4e;
}

.toggle-button .checkbox:checked + .knobs:before {
  left: 40px;
}

.toggle-button .checkbox:checked + .knobs:after {
  color: #fff;
}

/* Markdown Examples Page Styles */
.markdown-example-row {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.markdown-example-cell {
  flex: 1;
  padding: 0.75rem;
  line-height: 1.5;
}

.markdown-code {
  margin-top: 0.25rem;
  padding: 0.75rem;
  background: #1f2937;
  color: #f9fafb;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
  line-height: 1.5;
}

.markdown-result {
  margin-top: 0.25rem;
  padding: 0.75rem;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  line-height: 1.5;
}

.extension-note {
  margin: 0.75rem;
  padding: 0.75rem;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  color: #1e40af;
  font-size: 0.875rem;
  /* font-style: italic; */
}

/* Markdown Table Styles */
.markdown-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.875rem;
}

.markdown-table th,
.markdown-table td {
  padding: 0.5rem;
  text-align: left;
  border: 1px solid #d1d5db;
}

.markdown-table th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
}

.markdown-table td {
  background: white;
  color: #374151;
}

/* Form panel sections and components */
.form-section {
  margin-bottom: 1rem;
  padding: 1.25rem 1rem;
  border-radius: 8px;
  line-height: 1.2;
}

.form-section.normal {
  border-left: 4px solid #ccc;
  background-color: #f9f9f9;
}

.form-section.warning {
  border-top: none;
  border-right: none;
  border-bottom: none;
  border-left: 4px solid #e67e2247;
}

.form-section.error {
  border-top: none;
  border-right: none;
  border-bottom: none;
  border-left: 4px solid #fecaca;
}

.form-section p {
  max-width: 100%;
  margin: 0.25rem 0;
}

.form-section.warning a {
  color: #a84300;
  text-decoration: underline;
}

.item-warning {
  color: #a84300;
}

/* Email preview panel */
.preview-info {
  max-width: 600px;
  margin: 1rem auto;
  padding: 0.5rem 1rem;
}

.preview-info p,
.preview-info span{
  margin: 0.25rem 0;
  line-height: 1.4rem;
}

.preview-info .to-email-for-preview {
  margin: 0.5rem 0;
  display: flex;
  align-items: center;
  width: 100%;
  gap: 5px;
}

.preview-info .filter-dropdown {
  flex: 1;
  display: block;
  min-width: 0;
}

.preview-info .filter-dropdown-label {
  height: 2rem !important;
}

.preview-info .filter-dropdown-list {
  top: 2rem !important;
}

.preview-info.button-row {
  padding: 0;
}

span.preview-highlight {
  background-image: linear-gradient(#e1bee7, #e1bee7);
  background-position: 0 100%;
  background-repeat: repeat-x;
  background-size: 100% 2px;
  padding-bottom: 2px;
}

div.preview-highlight {
  background-color: #f8f4f9;
  border-left: 2px solid #e1bee7;
  border-radius: 8px;
  padding: 0.25rem 0.5rem;
  margin: 0;
}

/* Filter dropdown */
.filter-dropdown {
  position: relative;
  margin: 0;

  .filter-dropdown-list {
    padding: 0.75rem 1rem;
    background: #e8eaed;
    position: absolute;
    top: 2.25rem;
    left: 8px;
    right: 8px;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    transform-origin: 50% 0;
    transform: scale(1, 0);
    transition: transform .15s ease-in-out .15s;
    max-height: 66vh;
    overflow-y: scroll;
    z-index: 100;
  }

  .filter-dropdown-lookup {
    background: #fff;
  }
  
  .filter-dropdown-lookup:focus {
    outline: 3px solid #ddd;
  }
  
  .filter-dropdown-option {
    display: block;
    padding: 0.25rem 0;
    opacity: 0;
    transition: opacity .15s ease-in-out;
  }
  
  .filter-dropdown-label {
    margin: 0;
    height: 2.25rem;
    background: #e8eaed;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    
    &:before {
      content: '▼';
      float: right;
    }
  }

  textarea,
  input[type=text] {
    margin-bottom: 0.75rem;
  }
  
  &.on {
   .filter-dropdown-list {
      transform: scale(1, 1);
      transition-delay: 0s;
      
      .filter-dropdown-option {
        opacity: 1;
        transition-delay: .2s;
      }
    }
    
    .filter-dropdown-label:before {
      content: '▲';
    }
  }
}

.date-range-container {
  display: flex;
  gap: 0.5rem;
  margin: 0;
}

.date-range-container input[type=date] {
  flex: 1;
}

/* API call response dialog */
.response-dialog-container {
  padding: 3rem 1.5rem 1.5rem 1.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.response-dialog-container::backdrop {
  background-color: rgba(0, 0, 0, 0.5);
}

.close-button {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  padding: 0;
}