/* General Resets & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

html,
body {
  height: 100%;
  font-family: 'Open Sans', sans-serif;
  background-color: #1b1b1b;
  color: #f8f8f8;
  background-image: url('images/background.png');
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  position: relative;
  z-index: -2;
}

/* Dark Overlay to improve contrast */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: -1;
}

/* Dark Mode: further darken the overlay */
body.darkmode::before {
  background: rgba(0, 0, 0, 0.75);
  z-index: -1;
}

/* Container to wrap the main content */
.container {
  max-width: 70rem;
  margin: 0 auto;
  padding: 1.25rem;
}

/* Headings */
h1,
h2,
h3 {
  font-family: 'Cinzel', serif;
  color: #c53030;
  margin-bottom: 1rem;
}

h1 {
  font-size: 2.2rem;
  text-align: center;
}

/* Input, Button & Text Input Styles */
input[type='number'],
button,
input[type='text'] {
  font-family: inherit;
  font-size: 1rem;
  margin: 0.5rem;
  padding: 0.5rem 1rem;
  border: 0.125rem solid #cf9f25;
  background-color: #2d2d2d;
  color: #cf9f25;
  border-radius: 0.25rem;
}

/* Button Hover & Active States */
button:hover,
input[type='number']:focus,
input[type='text']:focus {
  border-color: #cf9f25;
  outline: none;
}

button:active {
  background-color: #e53e3e;
  color: #1b1b1b;
}

/* Dark Mode Overrides for Buttons and Inputs */
body.darkmode button,
body.darkmode input[type='number'],
body.darkmode input[type='text'] {
  background-color: #1e1e1e;
  border-color: #555;
  color: #cf9f25;
}

body.darkmode button:hover,
body.darkmode input[type='number']:focus,
body.darkmode input[type='text']:focus {
  border-color: #cf9f25;
  outline: none;
}

body.darkmode button:active {
  background-color: #e53e3e;
  color: #1b1b1b;
}

/* Additional Dark Mode Overrides for Coin Toggle Buttons */
body.darkmode .toggle-btn {
  background-color: #1e1e1e;
  border-color: #777;
  color: #f8f8f8;
}
body.darkmode .toggle-btn.enabled {
  background-color: #38761d;
  border-color: #38761d;
}
body.darkmode .toggle-btn.disabled {
  background-color: #990000;
  border-color: #990000;
}

/* Sections for Inputs & Weights */
.input-section,
.weight-section {
  max-width: 30rem;
  margin: 0 auto 1.25rem auto;
  padding: 1.25rem;
  box-shadow: 2px 2px 8px 0px rgba(0, 0, 0, 0.3);
  border-radius: 0.5rem;
  background-image: url('images/frame-bk-darkmode.svg');
  background-size: 478px auto;
  background-position: center;
  background-repeat: no-repeat;
}

/* Dark Mode Overrides */
body.darkmode .input-section,
body.darkmode .weight-section {
  box-shadow: 2px 2px 8px 0px rgba(0, 0, 0, 0.7);
  background-image: url('images/frame-bk-darkmode.svg');
}

.gold-input {
  width: 100%;
  max-width: 26.5rem;
}

.input-buttons {
  display: flex;
}

.input-button {
  width: 14rem;
}

/* Labels & Notes */
.input-section p,
.weight-section .note {
  color: #ccc;
}

.note {
  font-size: 0.9rem;
  margin-top: 1rem;
}

body.darkmode .note,
body.darkmode .input-section p {
  color: #ccc;
}

/* Header Row for Coin Options */
.coin-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 1rem;
  color: #ccc;
  font-weight: medium;
  gap: 0.5rem;
}

body.darkmode .coin-header {
  color: #ccc;
}

.coin-header-type {
  text-align: center;
  max-width: 15.25rem;
  width: 100%;
}

.coin-header-ratio {
  max-width: 5rem;
  width: 100%;
  text-align: center;
  margin: 0;
  padding: 0;
}

.coin-header-result {
  max-width: 6rem;
  width: 100%;
  text-align: center;
  margin: 0;
  padding: 0;
}

/* Coin Option Row */
.coin-option {
  display: flex;
  align-items: center;
  margin: 0.5rem 0;
  justify-content: space-between;
}

.coin-firstSection {
  display: flex;
  align-items: center;
}

.coin-values {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  width: auto;
}

/* Coin Image (SVG) */
.coin-image {
  width: 2rem;
  height: auto;
  margin-right: 0.625rem;
}

/* Toggle Button Styles */
.toggle-btn {
  cursor: pointer;
  margin-right: 0.625rem;
  border: 0.125rem solid #c53030;
  background-color: #2d2d2d;
  color: #f8f8f8;
  border-radius: 0.25rem;
  transition: background-color 0.2s;
  width: 12rem;
}

.toggle-btn.enabled {
  background-color: #4caf50;
  border-color: #4caf50;
}

.toggle-btn.disabled {
  background-color: #f44336;
  border-color: #f44336;
}

/* Ratio Input Styles */
.coin-ratio {
  width: 4rem;
  text-align: center;
}

/* Result Field Styles */
.coin-result {
  width: 5rem;
  text-align: center;
}

/* Hide default arrows in number inputs */
input[type='number']::-webkit-inner-spin-button,
input[type='number']::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type='number'] {
  -moz-appearance: textfield;
}

/* Custom Language Selector Styles */
.custom-select-container {
  position: relative;
  width: 200px;
  user-select: none;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  background-color: #2d2d2d;
  border: 0.125rem solid #c53030;
  border-radius: 0.25rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  height: 52px;
}

.custom-select-flag {
  width: 24px;
  height: 24px;
  margin-right: 0.5rem;
  object-fit: cover;
}

.custom-select-text {
  flex: 1;
}

.custom-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: #2d2d2d;
  border: 0.125rem solid #c53030;
  border-top: none;
  border-radius: 0 0 0.25rem 0.25rem;
  display: none;
  z-index: 10;
}

.custom-select-container.open .custom-options {
  display: block;
}

.custom-option {
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  height: 52px;
}

.custom-option:hover {
  background-color: #e53e3e;
}

.custom-option img {
  width: 24px;
  height: 24px;
  object-fit: cover;
}

/* Language Selector Container for fallback (if needed) */
.language-selector {
  display: none;
}

/* Dark Mode Overrides for Custom Select */
body.darkmode .custom-select-container,
body.darkmode .custom-select-trigger,
body.darkmode .custom-options,
body.darkmode .custom-option {
  background-color: #1e1e1e;
  border-color: #555;
  color: #f8f8f8;
}

/* Dark Mode Toggle Switch using provided markup */
.ct-cta-preference-manager {
  border: 0.125rem solid rgb(113, 82, 128);
  border-radius: 0.5rem;
  display: inline-block;
  overflow: hidden;
}

.ct-cta-preference-manager__primary {
  background-image: url('https://www.dndbeyond.com/avatars/13574/100/637396156849705602.jpeg');
  background-size: cover;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ct-cta-preference-manager__primary-info {
  display: flex;
  align-items: center;
}

.ct-cta-preference-manager__primary-info-title {
  display: flex;
  align-items: center;
  height: 32px;
}

.ct-cta-preference-manager__primary-info-icon {
  width: 2rem;
  height: 2rem;
  margin-right: 0.5rem;
}

.ct-cta-preference-manager__primary-info-label {
  color: #fff;
  font-size: 1rem;
}

.ct-cta-preference-manager__switch {
  display: inline-block;
  position: relative;
}

.ct-cta-preference-manager__switch-input {
  opacity: 0;
  width: 0;
  height: 0;
}

.ct-cta-preference-manager__switch-slider {
  display: inline-block;
  width: 40px;
  height: 20px;
  background-color: rgb(113, 82, 128);
  border-radius: 20px;
  position: relative;
  cursor: pointer;
  transition: background-color 0.3s;
}

.ct-cta-preference-manager__switch-slider:before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 1px;
  bottom: 1px;
  background-color: #fff;
  border-radius: 50%;
  transition: transform 0.3s;
}

/* Toggle Switch Checked State */
.ct-cta-preference-manager__switch-input:checked
  + .ct-cta-preference-manager__switch-slider:before {
  transform: translateX(20px);
}

/* Dark Mode adjustments for the toggle switch */
body.darkmode .ct-cta-preference-manager__switch-slider {
  background-color: #555;
}

body.darkmode
  .ct-cta-preference-manager__switch-input:checked
  + .ct-cta-preference-manager__switch-slider {
  background-color: #4e0202;
}

/* Language & Dark Mode Container */
.language-darkmode-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  margin-top: 1.25rem;
}

/* Mobile Responsiveness */
@media (max-width: 37.5rem) {
  .container {
    padding: 0.625rem;
  }
  h1 {
    font-size: 1.8rem;
  }
  input[type='number'],
  button,
  input[type='text'],
  .language-selector select {
    font-size: 0.875rem;
    padding: 0.4rem 0.8rem;
  }
  .coin-header-type,
  .coin-header-ratio,
  .coin-header-result {
    font-size: 0.875rem;
  }
}
