/*
 * Price list — layout and mobile refinements, loaded after style.css.
 * Keeps the original look; fixes overflowing price tables, the phone header,
 * the collection tabs and the quote bar.
 */

/* ---------- Product grid & cards ---------- */
.grid-container {
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}

.product-card {
  min-width: 0;
}

.card-head-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.card-thumb {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.card-body {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Price cells: number on top, unit + other unit underneath — never wraps mid-price */
.sizes-table th.price-header {
  white-space: nowrap;
  font-size: 0.75rem;
}

.price-cell {
  white-space: nowrap;
  line-height: 1.15;
  vertical-align: middle;
}

.price-cell .pc-main {
  display: block;
  font-size: 1rem;
}

.price-cell .pc-unit {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-light);
}

.price-cell .pc-sub {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-light);
  opacity: 0.8;
}

.size-label {
  font-size: 0.85rem;
}

/* ---------- Visible keyboard focus ---------- */
.tab-btn:focus-visible,
.control-btn:focus-visible,
.fab-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Tablets & phones ---------- */
@media (max-width: 768px) {
  /* Compact header: brand on one line, controls on the next, nothing cut off */
  .app-header {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    padding: 12px 16px;
  }

  .brand {
    gap: 8px;
    min-width: 0;
  }

  .brand h1 {
    font-size: 1.3rem;
    white-space: nowrap;
  }

  .controls {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
  }

  .controls .control-btn {
    height: 36px;
    padding: 0 12px;
    font-size: 0.85rem;
  }

  .controls .control-btn.icon-only {
    width: 36px;
    padding: 0;
    margin-left: auto;
  }

  #currency-select {
    max-width: 120px;
  }

  /* Collection tabs: one swipeable row that stays at the top */
  .tabs-container {
    position: sticky;
    top: 0;
    z-index: 99;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    gap: 4px;
    padding: 0 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }

  .tabs-container::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 12px 12px;
    border-right: none;
    border-bottom: 3px solid transparent;
    font-size: 0.88rem;
    scroll-snap-align: center;
  }

  .tab-btn.active {
    border-bottom-color: var(--accent);
  }

  /* Cards */
  .grid-container {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 12px;
    padding-bottom: calc(150px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .card-header {
    padding: 14px;
  }

  .card-body {
    padding: 8px 12px 12px;
  }

  .card-thumb {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }

  .sizes-table th {
    padding: 8px 4px;
    letter-spacing: 0.2px;
  }

  .size-label,
  .price-cell {
    padding: 10px 4px;
  }

  .price-cell .pc-main {
    font-size: 0.95rem;
  }

  /* Quote bar: docked to the bottom edge, compact, thumb-friendly */
  .fab-bar {
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    transform: none;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 14px;
    bottom: -220px;
  }

  .fab-bar.visible {
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .fab-count {
    font-size: 0.92rem;
    margin-bottom: 0;
  }

  .fab-hint {
    display: none;
  }

  .fab-actions {
    width: 100%;
    gap: 6px;
  }

  .fab-btn {
    flex: 1 1 0;
    justify-content: center;
    padding: 10px 8px;
    font-size: 0.85rem;
    min-height: 42px;
  }

  .fab-btn.primary:hover {
    transform: none;
  }
}

@media (max-width: 380px) {
  .brand .badge {
    display: none;
  }

  .tab-btn {
    padding: 12px 10px;
    font-size: 0.82rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fab-bar,
  .product-card,
  .tab-btn {
    transition: none !important;
  }
}

/* Nothing selected yet: on phones the bar is just a one-line hint */
@media (max-width: 768px) {
  .fab-bar.is-empty {
    padding: 8px 14px;
    opacity: 0.92;
  }

  .fab-bar.is-empty .fab-actions {
    display: none;
  }

  .fab-bar.is-empty .fab-count {
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
  }

  .fab-btn {
    white-space: nowrap;
  }

  .fab-btn svg {
    display: none;
  }

  /* Size picture drawer: smaller on phones */
  [id^="img-drawer-"] img {
    max-height: 240px !important;
    object-fit: contain;
  }
}

/* ---------------------------------------------------------------------------
   CRM look: same type, ink, clay and cards as the CRM.
   Loaded after style.css, so these replace the gold / Playfair theme.
   --------------------------------------------------------------------------- */
:root {
  --primary: #1a1916;
  --accent: #3d3530;
  --accent-light: #f0ede8;
  --bg: #f7f6f3;
  --card-bg: #ffffff;
  --text: #1a1916;
  --text-light: #6b6b6b;
  --border: #e5e4e0;
  --success: #2d6a4f;
  --danger: #9b1c1c;
  --clay: #b5562f;
  --font-sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --shadow-sm: 0 1px 2px rgba(26, 25, 22, 0.06);
  --shadow-md: 0 6px 16px rgba(26, 25, 22, 0.08);
  --shadow-lg: 0 18px 48px rgba(26, 25, 22, 0.12);
}

body,
button,
input,
select,
textarea {
  font-family: var(--font-sans);
}

h1, h2, h3, h4,
.brand h1,
.gate-box h1,
.card-title {
  font-family: var(--font-sans);
  letter-spacing: -0.01em;
}

.gate-container {
  background: var(--bg);
}

.gate-box {
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.gate-box h1 {
  font-size: 1.7rem;
  font-weight: 650;
}

.app-header {
  height: 56px;
  padding: 0 24px;
  box-shadow: none;
}

.brand h1 {
  font-size: 1.05rem;
  font-weight: 700;
}

.badge {
  background: #f6e7df;
  color: var(--clay);
  border-radius: 999px;
  letter-spacing: 0.04em;
  text-transform: none;
  font-weight: 650;
}

.control-btn,
.btn-primary,
.btn-primary-small {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 550;
}

.btn-primary,
.fab-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover,
.fab-btn.primary:hover {
  background: #2a2420;
}

.tabs-container {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: flex-start;
  overflow-x: auto;
  scrollbar-width: none;
}

@media (min-width: 769px) {
  .tabs-container {
    gap: 28px;
    padding: 0 24px;
  }
}

.tabs-container::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  border-radius: 8px 8px 0 0;
  font-size: 0.84rem;
  font-weight: 600;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--clay);
}

.tab-btn:focus {
  background: transparent;
}

.product-card {
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.product-card::before {
  display: none;
}

.product-card:hover {
  transform: translateY(-2px);
  border-color: #c8c7c2;
  box-shadow: var(--shadow-md);
}

.card-code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  border-radius: 5px;
}

.size-check.checked {
  background: var(--clay);
  border-color: var(--clay);
}

.fab-bar {
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.qr-modal,
.admin-container {
  border-radius: 14px;
}

.admin-tab.active {
  color: var(--primary);
  border-bottom-color: var(--clay);
}

input,
select,
textarea {
  border-radius: 6px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 53, 48, 0.14);
}

/* Phone rules last, so the fixed 56px header cannot clip the controls onto the tabs. */
@media (max-width: 768px) {
  .app-header {
    height: auto;
    min-height: 0;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px 16px;
  }

  .brand h1 {
    font-size: 1.15rem;
  }

  .controls {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
  }

  .tabs-container {
    gap: 16px;
    padding: 0 12px;
    position: sticky;
    top: 0;
  }
}

/* Admin uses the width of the window. The log table fits that width. */
.admin-container {
  width: 100%;
  max-width: none;
  min-width: 0;
  box-sizing: border-box;
}

.admin-body {
  min-width: 0;
  max-width: 100%;
}

.admin-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.admin-tab {
  flex: 0 0 auto;
  white-space: nowrap;
}

.table-responsive {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: auto;
  scrollbar-color: #b9b6ae transparent;
}

.table-responsive::-webkit-scrollbar {
  height: 12px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: #b9b6ae;
  border-radius: 99px;
  border: 3px solid #fff;
}

.admin-body .data-table {
  width: 100%;
  min-width: 0;
  table-layout: auto;
}

#sec-dashboard .data-table th,
#sec-dashboard .data-table td {
  white-space: normal;
}

.data-table .col-lead {
  width: auto;
  min-width: 0;
  max-width: none;
}

.data-table .log-actions {
  flex-wrap: nowrap;
}

#sec-create .lead-fields,
#sec-create .collections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
  align-items: start;
}

#sec-create .collections {
  gap: 16px 24px;
}

#sec-create .checkbox-group,
#sec-create .choice-row {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  background: #f7f6f3;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  min-height: 48px;
}

#sec-create .checkbox-group small {
  flex: 1 0 100%;
  color: #7a7570;
}

#sec-create .checkbox-group label,
#sec-create .choice-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 500;
}

#sec-create .checkbox-group input,
#sec-create .choice-row input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin: 0;
}

#sec-create .btn-primary {
  width: auto;
  min-width: 220px;
  margin-top: 4px;
}

@media (max-width: 900px) {
  #sec-create .lead-fields,
  #sec-create .collections,
  #sec-pricing > div[style*="grid-template-columns"],
  #upload-form {
    grid-template-columns: 1fr !important;
  }
}
