/* BitBuilder Software — site stylesheet */

:root {
  --color-bg: #ffffff;
  --color-text: #2a2a2a;
  --color-muted: #666666;
  --color-brand: #1a4b7a;
  --color-brand-dark: #123350;
  --color-border: #e2e2e2;
  --color-surface: #f7f8fa;
  --content-width: 960px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.55;
}

.wrap {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 20px;
}

a { color: var(--color-brand); }
a:hover { color: var(--color-brand-dark); }

h1, h2, h3 { line-height: 1.2; color: var(--color-brand-dark); }
h1 { margin-top: 0.4em; }

/* Header / nav */

.site-header {
  border-bottom: 3px solid var(--color-brand);
  padding: 14px 0;
}

/* The public header's own content (logo + 5 nav links) no longer fits
   inside the page's normal 960px content width now that the logo is
   bigger -- it was wrapping the nav links onto their own row below the
   logo. Widening just the header strip (not .wrap generally, so the page
   body below stays at its normal narrower width) fixes that without
   making a page that's already light on content look even more spread
   out. body.internal/body.pricebooks override this again further down
   (wider still, 1500px) to fit their own longer nav. */
.site-header .wrap {
  max-width: 1200px;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.site-header .logo img {
  display: block;
  height: 56px;
  width: auto;
}

.site-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
}

.site-nav a {
  display: inline-block;
  padding: 8px 12px;
  text-decoration: none;
  color: var(--color-text);
  border-radius: 4px;
}

.site-nav a:hover { background: var(--color-surface); }

.site-nav a.active {
  color: #fff;
  background: var(--color-brand);
}

/* Main content */

main.wrap {
  min-height: 60vh;
  padding-top: 28px;
  padding-bottom: 40px;
}

/* Home slideshow */

.slideshow {
  position: relative;
  max-width: 100%;
  aspect-ratio: 16 / 7;
  overflow: hidden;
  border-radius: 8px;
  background: var(--color-surface);
  margin: 20px 0;
}

.slideshow img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.9s ease-in-out;
}

.slideshow img.active { opacity: 1; }

/* Software page */

.software-item {
  display: flex;
  gap: 24px;
  align-items: center;
  margin: 32px 0;
  flex-wrap: wrap;
}

.software-item img {
  width: 360px;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  flex-shrink: 0;
}

.software-item-text {
  flex: 1;
  min-width: 260px;
}

.software-item-text h2 {
  margin-top: 0;
}

/* Changelog tables */

table.changelog {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
}

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

table.changelog th {
  background: var(--color-surface);
  white-space: nowrap;
}

table.changelog td:first-child,
table.changelog td:nth-child(2) {
  white-space: nowrap;
}

/* Tips / articles */

article.tip {
  padding: 16px 0;
  border-bottom: 1px solid var(--color-border);
}

article.tip:last-of-type { border-bottom: none; }

p.notice {
  background: #fff6e0;
  border: 1px solid #e8cf8a;
  border-radius: 4px;
  padding: 10px 14px;
}

/* Footer */

.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: 20px 0;
  font-size: 0.9em;
  color: var(--color-muted);
}

.site-footer .site-nav ul { margin-bottom: 10px; }
.site-footer .site-nav a { padding: 4px 10px; }

@media (max-width: 600px) {
  .site-header .wrap { flex-direction: column; align-items: flex-start; }
}

/* Internal area / dealer portal (pricebooks) — same "tagged" header layout */

body.internal .site-header .logo,
body.pricebooks .site-header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Groups the logo together with the "Internal" tag and any other tag
   links (Public Site, Dealer Portal) at the same tight spacing the logo
   and its own tag used to have, now that there's more than one tag. */
.header-tags {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.internal-tag {
  font-size: 0.7em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #fff;
  background: var(--color-brand);
  padding: 2px 8px;
  border-radius: 3px;
  text-decoration: none;
}

a.internal-tag:hover {
  background: var(--color-brand-dark);
  color: #fff;
}

body.internal .site-header .wrap,
body.pricebooks .site-header .wrap {
  justify-content: flex-start;
  gap: 24px;
}

.whoami {
  margin-left: auto;
  font-size: 0.9em;
  color: var(--color-muted);
  white-space: nowrap;
}

form.login-form {
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 20px 0;
}

form.login-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9em;
  color: var(--color-muted);
}

form.login-form label.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

form.login-form input[type="text"],
form.login-form input[type="password"],
form.login-form input[type="email"],
form.login-form input[type="date"],
form.login-form select {
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 1em;
  font-family: inherit;
}

/* A row of small filter/search fields (Recent Reports & Errors' search
   bar) — same input look as .login-form, but laid out as a wrapping row
   instead of a narrow stacked column, since these forms are wide and
   have several short fields side by side rather than one field per line. */
form.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  margin: 20px 0;
}

form.filter-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9em;
  color: var(--color-muted);
}

form.filter-form input[type="text"],
form.filter-form input[type="date"],
form.filter-form select {
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 1em;
}

/* The generic `button` rule (below) sets align-self: flex-start for
   every button on the site — right for a form where the button is the
   only element, but it overrides this row's flex-end and makes the
   Search button float up to the row's top instead of sitting level with
   the input boxes' bottoms. */
form.filter-form button {
  align-self: flex-end;
}

button,
form.login-form button {
  align-self: flex-start;
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  background: var(--color-brand);
  color: #fff;
  font-size: 0.95em;
  font-family: inherit;
  line-height: normal;
  cursor: pointer;
}

button:hover { background: var(--color-brand-dark); }

/* Shrink an actions column to fit its buttons instead of taking a share
   of the table's leftover width (the default table auto-layout spreads
   unused width across columns, even ones with short, fixed content like
   a couple of buttons) — the 1%-width trick forces it to hug its
   content so the leftover space goes to a column that can actually use
   it (a wrapping description column, etc.) instead. */
table.changelog td.actions {
  width: 1%;
  white-space: nowrap;
}

table.changelog td.actions form,
table.changelog td.actions details {
  display: inline-block;
  margin-right: 6px;
}

table.changelog td.actions button,
table.changelog td.actions summary {
  padding: 4px 10px;
  font-size: 0.85em;
  white-space: nowrap;
}

/* Tables with many columns (like admin.php's dealer accounts list) can be
   wider than the page — let them scroll horizontally instead of squeezing
   every column, and the action buttons in particular, down to nothing. */
.table-scroll {
  overflow-x: auto;
  margin: 20px 0;
}

.table-scroll table.changelog {
  margin: 0;
  width: auto;
  min-width: 100%;
}

/* Any changelog-style table whose 2nd column is a description rather than
   a short value (Custom Reports, Customer Files) needs that column to
   wrap like any other text instead of forcing the table wider than the
   page the way table.changelog's 2nd-column nowrap rule normally does
   (that rule is meant for short columns like a customer name or version
   number). Add this class to the <table> alongside .changelog. */
table.changelog.wide-desc-col2 td:nth-child(2) {
  white-space: normal;
}

p.notice.error {
  background: #fde3e3;
  border-color: #e79a9a;
  color: #7a1f1f;
}

/* Dealer portal (pricebooks) file listing */

.file-tag {
  font-size: 0.75em;
  font-weight: 600;
  margin-left: 6px;
  white-space: nowrap;
}

.file-tag.dealer { color: #b23c3c; }
.file-tag.category { color: #7b1fa2; }

/* Native [hidden] is unreliable on <tr> in some browsers because `tr`'s
   default `display: table-row` can win over the UA stylesheet's
   `[hidden] { display: none }` — so table rows use this class instead. */
table.file-listing tr.row-hidden {
  display: none;
}

/* Vendor-group rows (multiple monthly builds of one vendor collapsed into
   one clickable "Kellogg (4 files)" row) -- field.php and pricebook-admin's
   All Files tab both use this. */
table.file-listing tr.file-group-header {
  cursor: pointer;
  background: var(--color-surface);
}

table.file-listing tr.file-group-header:hover {
  background: #eceef1;
}

table.file-listing tr.file-group-header .group-chevron {
  display: inline-block;
  width: 1em;
}

table.file-listing tr.file-group-child td:first-child {
  padding-left: 28px;
}

/* Sorted by Last Modified: grouping is dropped entirely (see the inline
   script), so a former child row's indent would look like a stray mistake. */
table.file-listing.flat-view tr.file-group-child td:first-child {
  padding-left: 10px;
}

table.file-listing .group-count {
  color: var(--color-muted);
  font-weight: normal;
  font-size: 0.85em;
}

table.file-listing td.actions {
  white-space: nowrap;
}

table.file-listing td.actions button {
  padding: 4px 10px;
  font-size: 0.8em;
}

.button-secondary {
  background: #ccc;
  color: var(--color-text);
}

.button-secondary:hover { background: #bbb; }

/* Admin dashboard style (used on internal/'s staff pages and the dealer
   portal's own pages) — stat cards + tabs, same blue color scheme as the
   rest of the site rather than the old orange one. */

/* Wider than the site's normal 960px reading width — these are data
   table-heavy tools, not marketing pages, and the extra room keeps wide
   tables (like a dealer accounts list) from squeezing their action
   buttons. Scoped to the whole .internal section and the whole
   .pricebooks section (every page in each, not just the dashboard-style
   ones) so the header bar is the same width on every page within a
   section — clicking between pages in the same nav shouldn't visibly
   resize the header. */
body.internal .site-header .wrap,
body.internal main.wrap,
body.pricebooks .site-header .wrap,
body.pricebooks main.wrap {
  max-width: 1500px;
}

.admin-dashboard .stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.admin-dashboard .stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 16px 18px;
}

.admin-dashboard .stat-card h3 {
  margin: 0 0 10px;
  font-size: 0.85em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
}

.admin-dashboard .stat-number {
  font-size: 2em;
  font-weight: 700;
  color: var(--color-brand-dark);
  line-height: 1;
}

.admin-dashboard .stat-label {
  font-size: 0.85em;
  color: var(--color-muted);
  margin-top: 2px;
}

.admin-dashboard .stat-row {
  display: flex;
  gap: 24px;
}

.admin-dashboard .stat-card small {
  display: block;
  margin-top: 8px;
  color: var(--color-muted);
}

.admin-dashboard .action-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 20px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}

.admin-dashboard .action-panel p {
  flex-basis: 100%;
  margin: 0 0 2px;
  color: var(--color-muted);
}

.admin-dashboard .action-panel form { margin: 0; }

.admin-dashboard .btn-link {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 4px;
  background: var(--color-brand);
  color: #fff;
  text-decoration: none;
  font-size: 0.95em;
  font-family: inherit;
  line-height: normal;
  border: none;
  cursor: pointer;
  vertical-align: middle;
}

.admin-dashboard .btn-link:hover { background: var(--color-brand-dark); color: #fff; }

.admin-dashboard .btn-link.button-secondary:hover { background: #bbb; }

.admin-dashboard .tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-bottom: 2px solid var(--color-border);
  margin: 32px 0 0;
}

.admin-dashboard .tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 4px 4px 0 0;
  padding: 10px 16px;
  font-size: 0.95em;
  color: var(--color-muted);
  cursor: pointer;
}

.admin-dashboard .tab:hover { background: var(--color-surface); color: var(--color-text); }

.admin-dashboard .tab.active {
  color: var(--color-brand-dark);
  border-bottom-color: var(--color-brand);
  font-weight: 600;
  background: none;
}

.admin-dashboard .tab-panel { display: none; padding: 20px 0 4px; }
.admin-dashboard .tab-panel.active { display: block; }

/* Popup dialogs (e.g. pricebook-admin.php's Edit-dealer and dealer-history
   popups) — plain native <dialog>, no JS modal library needed. */
dialog.modal {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0;
  max-width: 560px;
  width: 92vw;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

dialog.modal.modal-wide { max-width: 760px; }

dialog.modal::backdrop { background: rgba(20, 30, 40, 0.55); }

dialog.modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 8px 8px 0 0;
}

dialog.modal .modal-header h3 { margin: 0; font-size: 1.1em; }

dialog.modal .modal-close {
  background: none;
  border: none;
  color: var(--color-muted);
  font-size: 1.4em;
  line-height: 1;
  padding: 2px 6px;
  cursor: pointer;
}

dialog.modal .modal-close:hover { background: none; color: var(--color-text); }

dialog.modal .modal-body {
  padding: 18px 20px;
  max-height: 70vh;
  overflow-y: auto;
}

dialog.modal .modal-body form.login-form { margin: 0; max-width: none; }

/* A plain text-styled button used where a table cell needs to act as a
   link (e.g. "Last login" opening the history popup) without looking
   like the row's other action buttons. */
button.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-brand);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  align-self: auto;
}

button.link-button:hover { background: none; color: var(--color-brand-dark); }

/* "More actions" popup (reset password, send emails, delete) — keeps a
   row's less-common actions out of the way instead of stacking every
   button in the row, which is what forced the Dealers table to scroll
   horizontally. This is a <dialog>, not an absolutely-positioned
   dropdown, on purpose: a table cell inside .table-scroll clips an
   absolutely-positioned child (setting overflow-x makes the browser
   force overflow-y to clip too), but a <dialog> renders in the browser's
   top layer and is never clipped by an ancestor's overflow. */
.action-list form { margin: 0 0 6px; }
.action-list form:last-child { margin-bottom: 0; }

.action-list button {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 9px 12px;
  font-size: 0.9em;
  align-self: auto;
}

.action-list button:hover { background: #eceef1; }
.action-list button.danger { color: #b23c3c; border-color: #e79a9a; }
.action-list button.danger:hover { background: #fde3e3; }

/* Tabs inside the dealer-history popup — same look as the page-level
   .admin-dashboard tabs, kept as separate classes so the page's own tab
   switcher script doesn't also pick these up. */
.mtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-bottom: 2px solid var(--color-border);
  margin: 4px 0 0;
}

.mtab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 4px 4px 0 0;
  padding: 8px 14px;
  font-size: 0.9em;
  color: var(--color-muted);
  cursor: pointer;
  align-self: auto;
}

.mtab:hover { background: var(--color-surface); color: var(--color-text); }

.mtab.active {
  color: var(--color-brand-dark);
  border-bottom-color: var(--color-brand);
  font-weight: 600;
  background: none;
}

.mtab-panel { display: none; padding: 14px 0 4px; }
.mtab-panel.active { display: block; }

.mtab-panel table.changelog { margin: 0; }
