/* ==========================================================================
   App shell design tokens + chrome (bottom nav, top bar, install prompt)

   Tokens here extend the :root block that used to live only inline in
   dashboard.php - centralized so every page can share them, plus a proper
   mobile-first breakpoint scale (main.css only ever had one @767px rule).
   Existing main.css classes (.row, .col-12, .card-4, etc.) are left alone;
   this file adds the app-shell layer on top rather than replacing them.
   ========================================================================== */

/* Full viewport must always be the shell's dark color, even where a
   centered .app-shell-body leaves space on either side on a wider
   screen (tablets) - otherwise that space falls back to the browser's
   default white, showing as a jarring blank margin either side of
   the actual app content. */
html, body {
  background: #12121c;
}

:root {
  /* Brand (from the app icon: magenta -> pink, blue -> teal) */
  --brand-pink: #ec008c;
  --brand-pink-soft: #ff5aa0;
  --brand-blue: #00a8e8;
  --brand-teal: #00d2c8;

  /* Surface */
  --shell-bg: #12121c;
  --shell-surface: #1b1b29;
  --shell-surface-raised: #232335;
  --shell-border: #33334a;

  /* Legacy tokens carried over from dashboard.php's inline :root, kept for
     any content still using them */
  --bg: #ebf0f7;
  --header: #fbf4f6;
  --text: #2e2e2f;
  --white: #ffffff;
  --light-grey: #5f6164;
  --tag-1: #ceecfd; --tag-1-text: #2e87ba;
  --tag-2: #d6ede2; --tag-2-text: #13854e;
  --tag-3: #ceecfd; --tag-3-text: #2d86ba;
  --tag-4: #f2dcf5; --tag-4-text: #a734ba;
  --purple: #7784ee;

  /* Text on dark shell chrome */
  --shell-text: #f2f2f7;
  --shell-text-dim: #9a9ab0;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --shadow-up: 0 -2px 12px rgba(0,0,0,0.25);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.08);

  --bottom-nav-height: 64px;
  --top-bar-height: 56px;
}

/* ==========================================================================
   Top app bar - thin fixed header, replaces each page's ad-hoc <h2>+home-icon
   row. Optional: pages can omit this and just use the bottom nav.
   ========================================================================== */

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--top-bar-height);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  background: var(--shell-surface);
  color: var(--shell-text);
  border-bottom: 1px solid var(--shell-border);
}
.app-topbar__title {
  font-size: 17px;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-topbar__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--shell-text);
  text-decoration: none;
  background: transparent;
  border: none;
}
.app-topbar__action:active { background: rgba(255,255,255,0.08); }

/* ==========================================================================
   Bottom tab navigation - Production / Stock / Storage
   ========================================================================== */

.app-bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  height: var(--bottom-nav-height);
  display: flex;
  background: var(--shell-surface);
  border-top: 1px solid var(--shell-border);
  box-shadow: var(--shadow-up);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.app-bottomnav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--shell-text-dim);
  font-size: 11px;
  font-weight: 500;
}
.app-bottomnav__item i {
  font-size: 20px;
  line-height: 1;
}
.app-bottomnav__item--active {
  color: var(--brand-teal);
}
.app-bottomnav__item--active i {
  color: var(--brand-teal);
}

/* Reserve space so page content doesn't hide behind the fixed bottom nav */
.app-shell-body {
  padding-bottom: calc(var(--bottom-nav-height) + var(--space-4));
  min-height: 100vh;
  box-sizing: border-box;
}

/* ==========================================================================
   Install-app prompt banner (shown via js/pwa-install.js when the browser
   fires beforeinstallprompt)
   ========================================================================== */

.app-install-banner {
  display: none;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: linear-gradient(90deg, var(--brand-pink), var(--brand-blue));
  color: #fff;
}
.app-install-banner.is-visible { display: flex; }
.app-install-banner__text {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}
.app-install-banner__btn {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.5);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
}
.app-install-banner__dismiss {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 18px;
  line-height: 1;
  padding: 4px;
}

/* ==========================================================================
   Mobile-first breakpoint scale (main.css only had one @767px rule)
   ========================================================================== */

/* Small phones */
@media (max-width: 400px) {
  .app-topbar__title { font-size: 15px; }
}

/* Phones (this is the primary target device for this app) */
@media (max-width: 600px) {
  .app-bottomnav__item { font-size: 10px; }
}

/* Small tablets */
@media (min-width: 601px) and (max-width: 900px) {
  .app-shell-body { max-width: 760px; margin: 0 auto; }
}

/* Tablets and up */
@media (min-width: 901px) {
  .app-shell-body { max-width: 1100px; margin: 0 auto; }
}

/* ==========================================================================
   Redesign layer (dashboard + production forms) - added on top of
   everything above rather than replacing it. Pattern: dark shell chrome
   (topbar/bottomnav/page background use --shell-bg) with white/light card
   surfaces for actual content and form fields - keeps the PWA's dark brand
   feel without having to re-theme the third-party jQuery widgets
   (select2, daterangepicker) these forms already depend on, which ship
   their own light-mode CSS.
   ========================================================================== */

.app-shell-page {
  background: var(--shell-bg);
  min-height: 100vh;
}

/* ---- Job cards (dashboard) ---- */

.job-section-title {
  padding: var(--space-4) var(--space-4) var(--space-2);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--shell-text-dim);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}
.job-section-total {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 700;
  font-size: 12px;
  color: var(--brand-teal);
  white-space: nowrap;
}
.job-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: 0 var(--space-4) var(--space-2);
}
.job-card {
  display: block;
  background: #fff;
  color: #1a1a24;
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-decoration: none;
  box-shadow: var(--shadow-card);
}
.job-card:active { background: #f5f5f9; }
.job-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.job-card__lot {
  font-weight: 600;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job-card__badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 100px;
  white-space: nowrap;
}
.job-card__badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.job-card__badge--pending { background: #ffeceb; color: #d33; }
.job-card__badge--active { background: #e6f9ef; color: #189a5a; }

/* Highlight the whole card, not just the small badge, once work has
   started on it - visible at a glance without reading the badge text. */
.job-card--started {
  background: #eefaf3;
  border-left: 4px solid #189a5a;
  padding-left: calc(var(--space-4) - 4px);
}
.job-card__detail {
  font-size: 13px;
  color: #6b6b7d;
  margin-top: 4px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.4;
}
.job-card__detail i { width: 14px; text-align: center; opacity: 0.6; margin-top: 2px; }
.job-card__customer {
  font-size: 12px;
  color: #6b6b7d;
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px dashed #e2e2ea;
}
.job-card--shortcut {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-weight: 600;
  color: #1a1a24;
}
.job-card--shortcut i { font-size: 18px; color: var(--brand-blue); }

.job-empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--shell-text-dim);
  font-size: 14px;
}

/* ---- Filter chips (dashboard stage switcher) ---- */

.filter-chips {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-2) var(--space-4) var(--space-4);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0;
  padding: 7px 15px;
  border-radius: 100px;
  background: var(--shell-surface-raised);
  border: 1px solid var(--shell-border);
  color: var(--shell-text-dim);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.filter-chip.is-active {
  background: var(--brand-teal);
  border-color: var(--brand-teal);
  color: #04231f;
}

/* ---- Buttons ---- */

.btn-shell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  border: none;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
}
.btn-shell--primary { background: var(--brand-teal); color: #04231f; }
.btn-shell--primary:active { background: #00b8af; }
.btn-shell--secondary { background: #fff; color: #1a1a24; border: 1px solid #e2e2ea; }
.btn-shell--danger { background: #ff5a5a; color: #fff; }
.btn-shell--block { margin-top: var(--space-2); }

/* ---- Form cards (production forms) ---- */

.form-shell {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.form-card {
  background: #fff;
  color: #1a1a24;
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-card);
}
.form-card__title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8a8a9a;
  margin-bottom: var(--space-3);
}
.form-row { margin-bottom: var(--space-3); }
.form-row:last-child { margin-bottom: 0; }
.form-row--split { display: flex; gap: var(--space-3); }
.form-row--split > * { flex: 1; min-width: 0; }
.form-label {
  display: block;
  font-size: 12.5px;
  color: #8a8a9a;
  margin-bottom: 4px;
}
.form-value { font-size: 15px; font-weight: 500; }
.form-input, .form-select, select.form-input, input.form-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid #e2e2ea;
  background: #f7f7fb;
  color: #1a1a24;
  font-size: 15px;
  font-family: inherit;
  box-sizing: border-box;
}
.form-input:focus, .form-select:focus { outline: none; border-color: var(--brand-teal); }
.form-hint { font-size: 12px; color: #8a8a9a; margin-top: 4px; }

/* ---- Topbar back-link variant ---- */

.app-topbar__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-left: calc(-1 * var(--space-2));
  border-radius: 50%;
  color: var(--shell-text);
  text-decoration: none;
  flex-shrink: 0;
}
.app-topbar__back:active { background: rgba(255,255,255,0.08); }

/* ==========================================================================
   Tablet job-card grid - placed after .job-list's own base rule
   (display:flex, single column) further up this file so these win the
   cascade at equal specificity by source order. Without this a media
   query defined earlier in the file loses to a same-specificity rule
   that comes later, regardless of which one is "active" for the
   viewport - a real bug caught here during testing.
   ========================================================================== */
@media (min-width: 601px) and (max-width: 900px) {
  .job-list { display: grid; grid-template-columns: repeat(2, 1fr); align-items: start; }
}
@media (min-width: 901px) {
  .job-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-items: start; }
}
