/* src/css on the 12th of April 2026 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: Arial, sans-serif;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: env(safe-area-inset-top);
  color: #1f2937;
  background: #ffffff;
  overflow: hidden;
  
  overscroll-behavior: none; /* prevent tiny vertical wiggle on desktop */
}

/* App container */
.container {
  position: relative;
  width: 100%;
  max-width: 650px;
  margin: 0 auto;
  padding: 20px;
  padding-bottom: 28px;
  border-radius: 12px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.10);
  overflow: visible;
}

/* Title */
h1 {
  color: #111827;
  font-size: 1.8rem;
  text-align: center;
  margin-bottom: 18px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.welcome-banner {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  font-size: 0.95rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.welcome-banner p {
  margin: 0;
  flex: 1 1 auto;
}

.welcome-info-dot {
  font-weight: 700;
  margin-left: 2px;
}

.welcome-btn {
  flex: 0 0 auto;
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  background: #0b63ce;
  color: #ffffff;
  font-size: 0.9rem;
  cursor: pointer;
}

/* Info icon in header only */
.info-btn {
  position: absolute;
  top: 10px;
  right: 20px;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 32px;
  height: 32px;

  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #d0d7e2;
  color: #0b63ce;

  cursor: pointer;
  user-select: none;

  padding: 0;
  margin: 0;

  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.info-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* keyboard focus */
.info-btn:focus-visible {
  outline: 3px solid rgba(11, 99, 206, 0.7);
  outline-offset: 2px;
}

.info-btn:hover {
  background: #f0f7ff;
}

@keyframes pulseHalo {
  0% {
    box-shadow: 0 0 4px rgba(11, 99, 206, 0.4);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 12px rgba(11, 99, 206, 0.85);
    transform: scale(1.1);
  }
  100% {
    box-shadow: 0 0 4px rgba(11, 99, 206, 0.4);
    transform: scale(1);
  }
}

.info-btn.pulse {
  animation: pulseHalo 1.2s ease-in-out infinite;
}

/* Cards row: no page scrolling */
.form-container {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  max-width: 100%;
  justify-content: center;
  overflow: hidden;
  padding: 2px;
}

.option-container {
  flex: 1 1 0;
  min-width: 280px;
  max-width: 300px;

  padding: 15px;

  /* reserve label space */
  padding-top: 38px;

  background-color: #fbfbfc;
  border-radius: 12px;

  border: 2px solid transparent;

  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: visible;
}

.option-container:not(.better-deal) {
  border-color: #d1d5db;
}

.option-container.better-deal {
  background-color: #f1fbf3;
  border-color: #2e7d32;
}

/* Better Deal pill */
.deal-label {
  display: block;
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);

  font-size: 0.95rem;
  font-weight: 800;
  color: #2e7d32;
  text-align: center;

  visibility: hidden;
  white-space: nowrap;

  background-color: rgba(46, 125, 50, 0.08);
  border: 1px solid rgba(46, 125, 50, 0.28);
  padding: 2px 10px;
  border-radius: 999px;
}

.option-container.better-deal .deal-label {
  visibility: visible;
}

/* Rows */
.input-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  width: 100%;
}

.input-row label {
  font-size: 0.95rem;
  color: #111827;
  font-weight: 800;
}

/* Simple input */
.input-row input {
  padding: 8px;
  font-size: 0.95rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  width: 100%;
  height: 38px;
  color: #111827;
  background: #ffffff;
}

/* Paired input + select row */
.input-row div:not(.multipack-group) {
  display: flex;
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  overflow: visible;
  height: 38px;
  background: #ffffff;
}

.input-row div:not(.multipack-group) input {
  flex: 2;
  padding: 8px;
  font-size: 0.95rem;
  border: none;
  border-right: 1px solid #e5e7eb;
  border-radius: 8px 0 0 8px;
  height: 100%;
  color: #111827;
  background: transparent;
}

.input-row div:not(.multipack-group) select {
  flex: 0.6;
  padding: 8px;
  font-size: 0.90rem;
  border: none;
  border-radius: 0 8px 8px 0;
  background-color: #ffffff;
  appearance: none;
  height: 100%;
  color: #374151;
}

.input-row[hidden] {
  display: none !important;
}

/* Multipack */
.multipack-row .multipack-group {
  display: flex;
  width: 100%;
  gap: 8px;
}

.multipack-row .multipack-group select {
  width: 100%;
  height: 38px;
  font-size: 0.90rem;
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background-color: #ffffff;
  appearance: none;
  color: #374151;
}

.multipack-row .multipack-group input[type="number"] {
  display: none;
  width: 50%;
  height: 38px;
  font-size: 0.95rem;
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #111827;
  background: #ffffff;
}

.multipack-row .multipack-group.other-active select {
  width: 50%;
}

.multipack-row .multipack-group.other-active input[type="number"] {
  display: inline-block;
}

/* Quantity group */
.quantity-group {
  display: flex;
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  height: 38px;
  overflow: visible;
  background: #ffffff;
}

.quantity-group input {
  flex: 2;
  padding: 8px;
  font-size: 0.95rem;
  border: none;
  border-radius: 8px 0 0 8px;
  height: 100%;
  color: #111827;
  background: transparent;
}

.quantity-group select {
  flex: 1;
  padding: 8px;
  font-size: 0.90rem;
  border: none;
  border-left: 1px solid #e5e7eb;
  border-radius: 0 8px 8px 0;
  background-color: #ffffff;
  appearance: none;
  height: 100%;
  color: #374151;
}

/* Focus rings */
.quantity-group:focus-within,
.input-row div:not(.multipack-group):focus-within {
  outline: 3px solid rgba(11, 99, 206, 0.25);
  outline-offset: 1px;
}

.input-row > input:focus,
.multipack-row .multipack-group > select:focus,
.multipack-row .multipack-group > input[type="number"]:focus {
  outline: 3px solid rgba(11, 99, 206, 0.25);
  outline-offset: 1px;
}

.quantity-group input:focus,
.quantity-group select:focus,
.input-row div:not(.multipack-group) input:focus,
.input-row div:not(.multipack-group) select:focus {
  outline: none;
}

/* Result area */
.price-per-unit {
  font-size: 1.25rem;
  color: #111827;
  text-align: center;

  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid transparent;

  font-weight: 800;
  letter-spacing: 0.2px;
  line-height: 1.2;

  min-height: calc(1.2em + 12px + 1px);
}

.price-per-unit:not(:empty) {
  border-top-color: #e5e7eb;
}

.option-container.better-deal .price-per-unit {
  color: #1b5e20;
  border-top-color: rgba(46, 125, 50, 0.35);
}

/* Generic dialog baseline */
dialog {
  width: 90%;
  max-width: 500px;
  border: none;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  background: #ffffff;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-height: 100vh;
  overflow: visible;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

/* Combined About + Settings dialog */
dialog.settings-dialog {
  padding: 0;
  overflow: hidden;
  width: 90vw;
  max-width: 420px;
  height: auto;

  /* helps at odd zoom levels */
  max-height: 90vh;

  border-radius: 12px;

  /* zoom-proof border */
  border: 0;
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px #cbd5e1;
}

.settings-panel {
  background: #ffffff;
  color: #1f2933;
  display: flex;
  flex-direction: column;
  height: auto;
  max-height: none;
  border-radius: 12px;
  overflow: hidden;
}

/* Tabs row */
.dialog-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-header {
  padding: calc(env(safe-area-inset-top, 0px) + 10px)
    calc(env(safe-area-inset-right, 0px) + 16px)
    10px
    16px;
  border-bottom: 1px solid #e5e7eb;
}

.dialog-close-btn {
  margin-left: auto;
  flex: 0 0 auto;
  background: #f0fdf4;
  border-color: #86efac;
  color: #111827;
  font-weight: 600;
}

.dialog-close-btn:hover {
  background: #dcfce7;
  border-color: #4ade80;
}

.settings-body {
  padding: 16px 16px 16px;
  overflow: visible;
  overflow-x: hidden;
  -webkit-overflow-scrolling: auto;
  min-height: auto;
}

/* System / Theme / Default currency on a single line */
.settings-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.settings-field span {
  flex: 0 0 40%;
}

.settings-field select {
  flex: 1;
  width: 100%;
  padding: 10px 10px;
  border-radius: 8px;
  border: 1px solid #cbd2d9;
  font-size: 1rem;
}

/* Favourites section */
.settings-body select,
.settings-body input {
  max-width: 100%;
  box-sizing: border-box;
}

.settings-section {
  margin-top: 6px;
}

.settings-section-head {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

/* Currency checkboxes */
.settings-currency-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 10px 6px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  max-height: none;
  overflow-x: hidden;
  margin-bottom: 6px;
}

.settings-currency-group-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  column-gap: 12px;
  row-gap: 4px;
  padding: 4px 0;
}

.settings-currency-group-row + .settings-currency-group-row {
  border-top: 1px solid #e5e7eb;
  margin-top: 4px;
  padding-top: 8px;
}

.settings-currency-row {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  min-width: 0;
}

.settings-currency-row input {
  flex: 0 0 auto;
}

.settings-currency-row span {
  display: inline-block;
  font-size: 0.90rem;
  min-width: 0;
}

.settings-empty {
  padding: 6px 2px;
  opacity: 0.7;
}

.settings-hint {
  margin-top: 10px;
  font-size: 0.92rem;
  opacity: 0.8;
}

.settings-footer {
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
  display: none;
}

.settings-btn {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  font-size: 1rem;
}

.settings-btn.primary {
  background: #0b63ce;
  color: #ffffff;
  border-color: #0b63ce;
}

.tab-btn {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #111827;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.95rem;
  cursor: pointer;
}

.tab-btn[aria-selected="true"] {
  background: #0b63ce;
  border-color: #0b63ce;
  color: #ffffff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-panel h2 {
  margin: 0 0 10px 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: #111827;
}

.tab-panel p {
  margin: 0 0 12px 0;
  line-height: 1.4;
}

.tab-panel hr {
  margin: 10px 0 12px 0;
  border: none;
  border-top: 1px solid #e5e7eb;
}

.tab-panel a {
  white-space: normal;
}

/* Added list layout fixes */
.tab-panel .about-list {
  margin: 0 0 12px 1.25em;
  padding-left: 0;
}

.tab-panel .about-list li {
  margin-bottom: 4px;
}

/* Narrow screens */
@media (max-width: 600px) {
  .container {
    width: 90%;
    padding: 10px;
    padding-bottom: 18px;
  }

  .option-container {
    min-width: 150px;
    max-width: 200px;
    padding: 10px;
    padding-top: 38px;
  }

  .form-container {
    gap: 8px;
  }

  .deal-label {
    top: 8px;
    font-size: 0.88rem;
  }

  .input-row label {
    font-size: 0.92rem;
    font-weight: 800;
  }

  .input-row input,
  .input-row div:not(.multipack-group) input,
  .quantity-group input {
    font-size: 0.90rem;
  }

  .input-row div:not(.multipack-group) select,
  .quantity-group select,
  .multipack-row .multipack-group select {
    font-size: 0.86rem;
  }

  dialog.settings-dialog {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .settings-panel {
    height: 100%;
    max-height: none;
    border-radius: 0;
  }

  .settings-body {
    font-size: 0.9rem;
    overflow-y: auto;
  }

  .settings-currency-group-row {
    grid-template-columns: repeat(4, 1fr);
    column-gap: 10px;
  }

  .settings-currency-list {
    max-height: none;
  }

  .settings-currency-row span {
    font-size: 0.82rem;
  }

  .settings-hint {
    display: none;
  }
}

/* Very short viewports (landscape phones) */
@media (max-height: 500px) {
  html,
  body {
    overflow-y: auto;
    overflow-x: hidden;
  }

  body {
    align-items: flex-start;
  }

  dialog.settings-dialog {
    width: 100vw;
    max-width: none;
    height: 100vh;
    max-height: none;
    border-radius: 0;
    top: 0;
    left: 0;
    transform: none;
  }

  .settings-panel {
    height: 100vh;
    max-height: none;
    border-radius: 0;
  }

  .settings-body {
    min-height: 0;
    overflow-y: auto;
  }
}

/* Dark theme */
[data-theme="dark"] {
  color-scheme: dark;
}

[data-theme="dark"] body {
  background: #020617;
  color: #e5e7eb;
}

[data-theme="dark"] .container {
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] h1 {
  color: #e5e7eb;
}

[data-theme="dark"] .welcome-banner {
  background: #0b1120;
  border-color: #1e293b;
  color: #e5e7eb;
}

[data-theme="dark"] .info-btn {
  background: #020617;
  border-color: #475569;
  color: #60a5fa;
}

[data-theme="dark"] .info-btn:hover {
  background: #0b1120;
}

[data-theme="dark"] .option-container {
  background-color: #020617;
  border-color: #1f2937;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.65);
}

[data-theme="dark"] .option-container:not(.better-deal) {
  border-color: #1f2937;
}

[data-theme="dark"] .option-container.better-deal {
  background-color: #052e16;
  border-color: #16a34a;
}

[data-theme="dark"] .deal-label {
  color: #bbf7d0;
  background-color: rgba(22, 163, 74, 0.12);
  border-color: rgba(22, 163, 74, 0.4);
}

[data-theme="dark"] .input-row label {
  color: #e5e7eb;
}

[data-theme="dark"] .input-row input {
  border-color: #334155;
  background: #020617;
  color: #e5e7eb;
}

[data-theme="dark"] .input-row div:not(.multipack-group) {
  border-color: #334155;
  background: #020617;
}

[data-theme="dark"] .input-row div:not(.multipack-group) input {
  border-right-color: #1f2937;
  color: #e5e7eb;
}

[data-theme="dark"] .input-row div:not(.multipack-group) select {
  background-color: #020617;
  color: #e5e7eb;
}

[data-theme="dark"] .multipack-row .multipack-group select {
  border-color: #334155;
  background-color: #020617;
  color: #e5e7eb;
}

[data-theme="dark"] .multipack-row .multipack-group input[type="number"] {
  border-color: #334155;
  background: #020617;
  color: #e5e7eb;
}

[data-theme="dark"] .quantity-group {
  border-color: #334155;
  background: #020617;
}

[data-theme="dark"] .quantity-group input {
  color: #e5e7eb;
}

[data-theme="dark"] .quantity-group select {
  border-left-color: #1f2937;
  background-color: #020617;
  color: #e5e7eb;
}

[data-theme="dark"] .price-per-unit {
  color: #e5e7eb;
}

[data-theme="dark"] .price-per-unit:not(:empty) {
  border-top-color: #1f2937;
}

[data-theme="dark"] .option-container.better-deal .price-per-unit {
  color: #bbf7d0;
  border-top-color: rgba(22, 163, 74, 0.6);
}

[data-theme="dark"] dialog.settings-dialog {
  background: #020617;
  border: 0;
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.8),
    inset 0 0 0 2px #64748b;
}

[data-theme="dark"] .settings-panel {
  background: #020617;
  color: #e5e7eb;
}

[data-theme="dark"] .settings-header {
  border-bottom-color: #475569;
}

[data-theme="dark"] .settings-body {
  color: #e5e7eb;
}

[data-theme="dark"] .settings-field select {
  border-color: #334155;
  background: #020617;
  color: #e5e7eb;
}

[data-theme="dark"] .settings-section-head {
  color: #e5e7eb;
}

[data-theme="dark"] .settings-currency-list {
  border-color: #1f2937;
}

[data-theme="dark"] .settings-currency-group-row + .settings-currency-group-row {
  border-top-color: #1f2937;
}

[data-theme="dark"] .settings-currency-row span {
  color: #e5e7eb;
}

[data-theme="dark"] .tab-btn {
  border-color: #334155;
  background: #020617;
  color: #e5e7eb;
}

[data-theme="dark"] .tab-btn[aria-selected="true"] {
  background: #0b63ce;
  border-color: #0b63ce;
  color: #ffffff;
}

[data-theme="dark"] .tab-panel h2 {
  color: #e5e7eb;
}

[data-theme="dark"] .tab-panel hr {
  border-top-color: #1f2937;
}
