/* ===== FONT FACE ===== */
@font-face {
  font-family: 'Nimbus Sans';
  src: url('/fonts/NimbusSans-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Nimbus Sans';
  src: url('/fonts/NimbusSans-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Nimbus Sans';
  src: url('/fonts/NimbusSans-Italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* ===== CSS VARIABLES ===== */
:root {
  --line-thickness: 2px;
  --margin-outer: 18px;
  --gutter: 12px;

  /* Chevron for select dropdowns */
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23000' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");

  /* Action colors */
  --action-color: #2563EB;
  --action-hover: #1d4ed8;

  /* Semantic grays */
  --color-text: #000;
  --color-meta: #666;
  --color-border: #ebebeb;
  --color-border-strong: #d4d4d4;
  --color-disabled: #bdbdbd;

  /* Status colors */
  --color-error: #d32f2f;
  --color-error-bg: #ffe6e6;
  --color-warning: #A16207;

  /* Surface colors */
  --color-row-hover: #fffde7;
  --color-row-active: #f5f5f5;

  /* Focus tints */
  --focus-tint: rgba(0, 0, 0, 0.04);
  --focus-tint-strong: rgba(0, 0, 0, 0.08);

  /* Modal */
  --modal-backdrop: rgba(0, 0, 0, 0.35);
  --modal-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);

  /* Border tokens (replaces --line-thickness overload) */
  --border-row: 1px solid var(--color-border);       /* table row separators */
  --border-section: 1px solid var(--color-border-strong); /* section dividers */
  --border-input: 2px solid var(--color-text);       /* input underlines */

  /* Table row spacing */
  --table-row-padding: 0.4rem;    /* Row padding — increase if text feels cramped */

  /* Spacing scale (4px base, Polaris/Atlassian convention) */
  --space-050: 0.125rem;  /* 2px  — micro: compact inline inputs, kv-row padding */
  --space-100: 0.25rem;   /* 4px  — tight: input padding, item rows, label margins */
  --space-200: 0.5rem;    /* 8px  — within-section: detail gaps, action margins */
  --space-300: 0.75rem;   /* 12px — form group margin, toast padding */
  --space-400: 1rem;      /* 16px — between-elements: search gaps, modal headings */
  --space-600: 1.5rem;    /* 24px — structural: nav padding, modal padding */
  --space-800: 2rem;      /* 32px — section breaks: form-section margin, error padding */

  /* Input padding (semantic tier) */
  --input-padding-inline:   0;                     /* data-grid: td owns spacing */
  --input-padding-compact:  var(--space-050) 0;    /* detail-panel compact inputs */
  --input-padding-default:  var(--space-100) 0;    /* forms, search, standard inputs */
}

/* ===== RESET ===== */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  background-color: #fff;
}

body {
  display: flex;
  flex-direction: column;
  font-family: 'Nimbus Sans', sans-serif;
  font-size: 1.25rem;
  color: var(--color-text);
  line-height: 1.3;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%; /* Prevent auto text sizing on orientation change */
  -moz-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: 1.3;
}

dialog {
  border: var(--border-section);
  box-shadow: var(--modal-shadow);
  padding: var(--space-600);
  width: 90vw;
  outline: none;
}

dialog::backdrop {
  background: var(--modal-backdrop);
}

dialog h2 {
  margin: 0 0 var(--space-400);
  font-weight: normal;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
}

p, div, span, label, a, li, td, th {
  line-height: 1.3;
}

/* ===== BUTTONS ===== */
/* Text-only style — colored text, no border/background */
button, .btn {
  background: transparent;
  color: var(--action-color);
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: normal;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: color 0.2s ease;
}

button:disabled, .btn:disabled {
  color: var(--color-disabled);
  cursor: not-allowed;
}

button:focus, .btn:focus {
  outline: none;
}

button:focus-visible, .btn:focus-visible {
  background: var(--focus-tint-strong);
}

button:active, .btn:active {
  color: var(--action-hover);
}

@media (hover: hover) {
  button:hover, .btn:hover {
    color: var(--action-hover);
  }

  button:disabled:hover, .btn:disabled:hover {
    color: var(--color-disabled);
  }
}

/* ===== TABLE ===== */
th {
  color: var(--color-meta);
}

tbody tr:hover {
  background: var(--color-row-hover);
}

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-400);
  margin: var(--space-800) 0;
}

.pagination span {
  color: var(--color-text);
  font-size: inherit;
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
  body {
    font-size: 1.125rem; /* slightly smaller on mobile */
  }
}

/* ===== UNDERLINE SYSTEM ===== */
/* Centralized underline patterns - see design-standards.md for documentation */

/* Base underlined class - apply to any element that needs text-width underline */
.underlined {
  display: inline-block;
  width: fit-content;
  border-bottom: var(--line-thickness) solid currentColor;
}

/* Verify page - link styling */
.verify-container a {
  display: inline-block;
  width: fit-content;
  border-bottom: var(--line-thickness) solid currentColor;
}

/* Dashboard - navigation tabs with show-on-hover underline */
nav button {
  display: inline-block;
  width: fit-content;
  border-bottom: var(--line-thickness) solid transparent;  /* Hidden by default */
}

nav button.active {
  border-bottom-color: var(--color-text);  /* Show underline when active */
}

nav button:active {
  border-bottom-color: var(--color-text);  /* Show underline when clicked */
}

@media (hover: hover) {
  nav button:hover {
    border-bottom-color: var(--color-text);  /* Show underline on hover */
  }
}


/* ===== UTILITY CLASSES ===== */
/* Visibility utilities for systematic show/hide control */
.show {
  display: block;
}

.hide {
  display: none;
}

/* Utility: opt-in tabular figures for elements without a semantic data class */
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* ===== FORM PATTERNS ===== */
/* Label-below-input pattern (matches shop checkout) */
.form-group {
  display: flex;
  flex-direction: column;
  margin: 0 0 var(--space-300) 0;
}

.form-group > label:first-child {
  color: var(--color-text);
  margin: var(--space-100) 0 0 0;
  order: 2;
}

.form-group > input,
.form-group > select,
.form-group > textarea {
  order: 1;
}

/* Section spacing between logically distinct form groups */
.form-group.form-section {
  margin-top: var(--space-800);
}

/* Override: label stays above for radio groups, complex sections */
.form-group.label-above > label:first-child {
  order: unset;
  margin: 0 0 var(--space-100) 0;
}

/* Prevent buttons from stretching full-width in flex column */
.form-group > button {
  align-self: flex-start;
}

/* Form text inputs (underline style) */
.form-group input[type="text"],
.form-group input[type="email"] {
  width: 100%;
  padding: var(--input-padding-default);
  border: none;
  border-bottom: var(--border-input);
  border-radius: 0;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  font-family: inherit;
  font-size: inherit;
  background: transparent;
  box-sizing: border-box;
}

/* Hide number input spinners — admin inputs are typed, not incremented */
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;
}

/* Form number inputs — direct child only to avoid item-row conflicts */
.form-group > input[type="number"] {
  width: 100%;
  padding: var(--input-padding-default);
  border: none;
  border-bottom: var(--border-input);
  border-radius: 0;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  font-family: inherit;
  font-size: inherit;
  background: transparent;
  box-sizing: border-box;
}

/* Form select (underline style with chevron) */
.form-group select {
  width: 100%;
  padding: var(--input-padding-default);
  border: none;
  border-bottom: var(--border-input);
  border-radius: 0;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  font-family: inherit;
  font-size: inherit;
  background: transparent;
  box-sizing: border-box;
  cursor: pointer;
  padding-right: var(--space-600);
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 0 center;
}

/* Form textarea (bordered) */
.form-group textarea {
  width: 100%;
  border: var(--border-section);
  border-radius: 0;
  -webkit-appearance: none;
  padding: var(--space-100);
  resize: vertical;
  font-family: inherit;
  font-size: inherit;
  background: transparent;
  box-sizing: border-box;
}

/* Focus states */
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-bottom-color: var(--color-text);
}

.form-group textarea:focus {
  outline: none;
  border-color: var(--color-text);
}

.form-group input:focus-visible,
.form-group select:focus-visible,
.form-group textarea:focus-visible {
  background: var(--focus-tint);
}

/* Placeholder styling */
.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--color-meta);
  font-size: inherit;
  opacity: 1;
}

/* Radio group */
.radio-group {
  display: flex;
  gap: var(--space-800);
}

.radio-group label {
  color: var(--color-text);
  cursor: pointer;
  order: unset;
  margin: 0;
}
