/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

:root {
  color-scheme: light dark;
  --color-background: #fbfaf8;
  --color-surface: #ffffff;
  --color-text: #241c1d;
  --color-muted: #665c5d;
  --color-border: #ddd5d2;
  --color-accent: #7c1f2b;
  --color-accent-contrast: #ffffff;
  --color-row-alt: #f5efec;
  --shadow-soft: 0 8px 24px rgba(36, 28, 29, 0.08);
}

.theme-dark {
  color-scheme: dark;
  --color-background: #181415;
  --color-surface: #241f20;
  --color-text: #f4efed;
  --color-muted: #c8bdbc;
  --color-border: #46393b;
  --color-accent: #d66a78;
  --color-accent-contrast: #241012;
  --color-row-alt: #2e2728;
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-background);
  color: var(--color-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header,
.site-footer {
  background: var(--color-surface);
  border-color: var(--color-border);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-soft);
}

.site-header__inner,
.page-shell,
.site-footer nav {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header__inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--color-text);
  font-weight: 700;
  text-decoration: none;
}

.site-logo__mark {
  width: 40px;
  height: 40px;
  display: block;
}

.primary-menu {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 18px;
}

.primary-menu__list,
.primary-menu__submenu {
  margin: 0;
  padding: 0;
  list-style: none;
}

.primary-menu__list {
  display: flex;
  align-items: center;
  gap: 12px;
}

.primary-menu__item--has-children {
  position: relative;
}

.primary-menu__link,
.theme-toggle {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--color-text);
  background: transparent;
  font: inherit;
  text-decoration: none;
}

.primary-menu__link:hover,
.theme-toggle:hover,
.primary-menu__item--has-children:focus-within > .primary-menu__link,
.primary-menu__item--has-children:hover > .primary-menu__link {
  border-color: var(--color-border);
  background: var(--color-row-alt);
}

.primary-menu__link--placeholder {
  color: var(--color-muted);
  cursor: default;
}

.primary-menu__submenu {
  min-width: 180px;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  display: none;
  padding: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.primary-menu__item--align-right .primary-menu__submenu {
  right: 0;
  left: auto;
}

.primary-menu__submenu .primary-menu__link {
  display: block;
}

.primary-menu__item--has-children:hover .primary-menu__submenu,
.primary-menu__item--has-children:focus-within .primary-menu__submenu {
  display: block;
}

.theme-toggle {
  border-color: var(--color-border);
  cursor: pointer;
}

.menu-toggle {
  display: none;
  margin-left: auto;
  width: 42px;
  height: 42px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: transparent;
  color: var(--color-text);
}

.menu-toggle__bar {
  display: block;
  width: 20px;
  height: 2px;
  margin: 4px auto;
  background: currentColor;
}

.page-shell {
  flex: 1;
  width: min(1120px, calc(100% - 32px));
}

.page-section {
  padding: 56px 0;
}

.home h1,
.static-page h1 {
  margin: 0 0 16px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.1;
}

.home p,
.static-page p,
.static-page li {
  max-width: 760px;
  color: var(--color-muted);
}

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--color-border);
}

.site-footer nav {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
}

.site-footer a {
  color: var(--color-muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--color-accent);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

.data-table tbody tr:nth-child(even) {
  background: var(--color-row-alt);
}

.table-search {
  width: min(100%, 320px);
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
}

.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: 8px;
  padding: 24px;
  background: var(--color-surface);
}

.drop-zone--active {
  border-color: var(--color-accent);
  background: var(--color-row-alt);
}

.placeholder-text {
  color: var(--color-accent);
  font-weight: 600;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header h1 {
  margin: 0;
}

.flash {
  margin: 16px 0;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.flash--notice {
  border-color: #4f8a62;
}

.flash--alert {
  border-color: #b65353;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-left: 6px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--color-row-alt);
  color: var(--color-muted);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-tag--pending,
.status-tag--pending-review {
  border-color: #b58a2a;
  color: #8a651c;
}

.status-tag--rejected {
  border-color: #b65353;
  color: #9d3838;
}

.status-tag--merged {
  border-color: #4f8a62;
  color: #2f6f44;
}

.splash {
  display: grid;
  gap: 12px;
  margin: 16px 0;
  padding: 18px;
  border: 1px solid var(--color-accent);
  border-radius: 8px;
  background: var(--color-surface);
  box-shadow: var(--shadow-soft);
}

.splash h2,
.splash p {
  margin: 0;
}

.button,
.actions a,
.actions button,
.form-actions input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.button--primary,
.form-actions input[type="submit"] {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

.button--danger,
.actions .button--danger {
  border-color: #b65353;
  color: #b65353;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.resource-form,
.resource-details {
  display: grid;
  gap: 16px;
  max-width: 760px;
}

.field {
  display: grid;
  gap: 6px;
}

.field-with-action {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.form-panel,
.inline-fields {
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
}

.inline-fields[hidden] {
  display: none;
}

.form-panel h2 {
  margin: 0;
  font-size: 1.1rem;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field.checkbox-field input[type="checkbox"] {
  width: auto;
}

.field label,
.field-label,
.resource-details dt {
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

.buy-choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.buy-choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--color-surface);
}

.buy-choice input {
  width: auto;
}

.buy-choice--yes {
  border-color: #4f8a62;
  color: #2f6f44;
}

.buy-choice--no {
  border-color: #b65353;
  color: #9d3838;
}

.field-hint,
.error-messages,
.empty-state {
  color: var(--color-muted);
}

.error-messages {
  padding: 12px 14px;
  border: 1px solid #b65353;
  border-radius: 8px;
}

.error-messages h2 {
  margin-top: 0;
  font-size: 1rem;
}

.resource-details {
  grid-template-columns: max-content minmax(0, 1fr);
}

.resource-details dd {
  margin: 0;
}

.table-toolbar,
.table-pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 14px;
}

.table-pagination {
  margin-top: 14px;
  justify-content: flex-end;
}

.table-row-count {
  color: var(--color-muted);
}

.watch-list-history {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--color-border);
}

.watch-list-history p {
  margin: 0;
}

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.data-table th button,
.data-table__sortable-header {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.data-table__sortable-header:hover {
  color: var(--color-accent);
}

.appellation-grape-fields {
  grid-template-columns: minmax(160px, 1fr) minmax(220px, 1.4fr) auto;
  align-items: end;
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  font-weight: 700;
}

.icon-button--danger {
  border-color: #b65353;
  color: #b65353;
}

.icon-button--success {
  border-color: #4f8a62;
  color: #2f6f44;
}

.data-table--compact {
  width: 100%;
  table-layout: auto;
}

.data-table--compact th,
.data-table--compact td {
  white-space: nowrap;
}

.data-table--compact td:first-child {
  width: 100%;
}

.table-cell--date {
  white-space: nowrap;
}

.data-table--tasting-notes th:first-child,
.data-table--tasting-notes td:first-child {
  width: 1%;
  white-space: nowrap;
}

.data-table tbody tr.data-table__row--buy-yes,
.data-table tbody tr.data-table__row--buy-yes:nth-child(even) {
  background: rgba(79, 138, 98, 0.18);
}

.data-table tbody tr.data-table__row--buy-no,
.data-table tbody tr.data-table__row--buy-no:nth-child(even) {
  background: rgba(182, 83, 83, 0.18);
}

.related-section {
  margin-top: 32px;
}

.related-section h2 {
  margin: 0;
  font-size: 1.25rem;
}

.related-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.related-actions {
  margin-top: 16px;
}

@media (max-width: 720px) {
  .site-header__inner {
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 0;
  }

  .menu-toggle {
    display: block;
  }

  .primary-menu {
    display: none;
    width: 100%;
    margin-left: 0;
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .primary-menu--open {
    display: flex;
  }

  .primary-menu__list {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-menu__submenu {
    position: static;
    display: block;
    margin-top: 6px;
    box-shadow: none;
  }
}

.print-label-page {
  min-height: 70vh;
  display: grid;
  place-items: center;
}

.bottle-label {
  width: 90mm;
  height: 29mm;
  display: grid;
  grid-template-columns: 24mm 23mm minmax(0, 1fr);
  gap: 2mm;
  align-items: center;
  padding: 2mm;
  border: 1px solid var(--color-border);
  background: #fff;
  color: #000;
  overflow: hidden;
}

.bottle-label__brand {
  display: grid;
  justify-items: center;
  gap: 1mm;
  font-size: 7pt;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
}

.bottle-label__brand span {
  white-space: nowrap;
}

.bottle-label__mark {
  width: 10mm;
  height: 10mm;
  filter: grayscale(1) contrast(2);
}

.bottle-label__qr svg {
  width: 23mm;
  height: 23mm;
  display: block;
}

.bottle-label__inventory {
  min-width: 0;
  font-size: 16pt;
  font-weight: 700;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

@media print {
  @page {
    size: 90mm 29mm;
    margin: 0;
  }

  .site-header,
  .site-footer,
  .flash {
    display: none;
  }

  body,
  .page-shell,
  .print-label-page {
    width: auto;
    min-height: auto;
    margin: 0;
    padding: 0;
    display: block;
    background: #fff;
  }

  .bottle-label {
    border: 0;
  }
}
