html {
  font-size: 16px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 0;
}

/* Align the add-coin form to the right */
.add-coin-form {
  display: flex;
  justify-content: flex-end;
  margin-left: auto;            /* push the whole form to the right */
  width: 100%;                  /* allow inner content to use available space */
}

/* Make the inner bootstrap row content-sized and remove negative margins */
.add-coin-form > .row {
  width: auto;
  margin-left: 0;
  margin-right: 0;
  flex-wrap: wrap;              /* allow wrapping on smaller screens */
  gap: .5rem;                   /* small gap between fields when wrapped */
}

/* Prevent columns from stretching too aggressively */
.add-coin-form > .row > [class^="col-"],
.add-coin-form > .row > [class*=" col-"] {
  flex: 0 1 auto;               /* allow to shrink/grow naturally */
  width: auto;
}

/* Keep a single row on large screens */
@media (min-width: 992px) {
  .add-coin-form > .row {
    flex-wrap: nowrap;
  }
}

/* Tom Select: ensure controls are readable and use full available width */
.ts-control {
  width: 100%;
  min-height: calc(2.25rem + 2px); /* similar to .form-control */
}

/* Navbar currency selector: avoid forcing the page to shrink on mobile */
.navbar .ts-control {
  min-width: 0;          /* allow to shrink on small screens */
  max-width: 100%;
  flex: 1 1 auto;
}
@media (min-width: 576px) {
  .navbar .ts-control { min-width: 220px; }
}
@media (min-width: 768px) {
  .navbar .ts-control { min-width: 280px; }
}

.form-select {
  min-width: 0;          /* don't force wide selects on mobile */
  margin-right: 10px;
}
@media (min-width: 576px) {
  .form-select { min-width: 150px; }
}

/* Header and footer sizes relative to typical content */
.header-nav {
  font-size: 1rem;
}
.header-nav .navbar-brand,
.header-nav .nav-link {
  font-size: 1.05rem; /* slightly larger than table text */
}
footer.footer {
  font-size: 1rem;
}

/* --- Dark mode ---------------------------------------------------------- */
/* Explicit dark theme styles activated by html[data-theme="dark"] */
html[data-theme="dark"] {
  color-scheme: dark;
  --bs-body-bg: #121212;
  --bs-body-color: #e6e6e6;
  --bs-border-color: #2a2a2a;
  --bs-secondary-color: #9aa0a6;
}

html[data-theme="dark"] body {
  background-color: var(--bs-body-bg);
  color: var(--bs-body-color);
}

/* Generic helpers to neutralize Bootstrap light utilities in dark mode */
html[data-theme="dark"] .bg-white { background-color: #1e1e1e !important; }
html[data-theme="dark"] .text-dark { color: #e6e6e6 !important; }
html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .text-body-secondary { color: var(--bs-secondary-color) !important; }

/* Navbar */
html[data-theme="dark"] .navbar {
  background-color: #1e1e1e !important;
  border-color: var(--bs-border-color) !important;
}
html[data-theme="dark"] .navbar .navbar-brand,
html[data-theme="dark"] .navbar .nav-link {
  color: #e6e6e6 !important;
}
html[data-theme="dark"] .navbar .navbar-text { /* ensure email/username is readable */
  color: #e6e6e6 !important;
}
html[data-theme="dark"] .navbar .nav-link:hover,
html[data-theme="dark"] .navbar .nav-link:focus {
  color: #ffffff !important;
}
html[data-theme="dark"] .navbar .btn-link.nav-link { /* logout link color */
  color: #e6e6e6 !important;
}
html[data-theme="dark"] .navbar .btn-link.nav-link:hover,
html[data-theme="dark"] .navbar .btn-link.nav-link:focus {
  color: #ffffff !important;
}
html[data-theme="dark"] .navbar-light .navbar-toggler-icon { filter: invert(1) grayscale(1); }
html[data-theme="dark"] .navbar-toggler { border-color: #666; }

/* Dropdowns */
html[data-theme="dark"] .dropdown-menu {
  background-color: #1e1e1e;
  color: #e6e6e6;
  border-color: #333;
}
html[data-theme="dark"] .dropdown-item { color: #e6e6e6; }
html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus {
  background-color: #2a2a2a;
  color: #fff;
}

/* Footer */
html[data-theme="dark"] footer.footer {
  background-color: #1e1e1e;
  color: #9aa0a6;
  border-top-color: var(--bs-border-color);
}

/* Tables */
html[data-theme="dark"] .table {
  --bs-table-color: #e6e6e6;
  --bs-table-bg: transparent;
  --bs-table-border-color: #333;
  --bs-table-striped-bg: rgba(255,255,255,.05);
  --bs-table-hover-bg: rgba(255,255,255,.075);
}
/* Ensure cells inherit color and transparent background for readability */
html[data-theme="dark"] .table > :not(caption) > * > * {
  color: #e6e6e6 !important;
  background-color: transparent !important;
  border-color: #333 !important;
}
html[data-theme="dark"] .table > thead > tr > th {
  background-color: #181818 !important;
  color: #e6e6e6 !important;
  border-bottom-color: #333 !important;
}
html[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: rgba(255,255,255,.03) !important;
  color: #e6e6e6 !important;
}

/* Improve status colors for dark backgrounds */
html[data-theme="dark"] .text-success { color: #4ddf71 !important; }
html[data-theme="dark"] .text-danger { color: #ff6b6b !important; }
/* Inputs */
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .ts-control,
html[data-theme="dark"] .ts-dropdown {
  background-color: #1c1c1c;
  color: #e6e6e6;
  border-color: #333;
}
html[data-theme="dark"] .form-label { color: #e6e6e6; }
html[data-theme="dark"] .form-control::placeholder { color: #9aa0a6; }

/* Tom Select active/hover */
html[data-theme="dark"] .ts-dropdown .active { background-color: #2a2a2a; }
html[data-theme="dark"] .ts-control input { color: #e6e6e6; }

/* Buttons */
html[data-theme="dark"] .btn-outline-secondary {
  color: #e6e6e6;
  border-color: #555;
}
html[data-theme="dark"] .btn-outline-secondary:hover {
  background-color: #2a2a2a;
}

/* Modal */
html[data-theme="dark"] .modal-content {
  background-color: #1e1e1e;
  color: #e6e6e6;
}
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer {
  border-color: #2a2a2a;
}
html[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1); }

/* Links */
html[data-theme="dark"] a { color: #8ab4f8; }
html[data-theme="dark"] a:hover { color: #a8c7fa; }