/* =====================================================================
   PARTECO ADMIN — DESIGN SYSTEM
   A parts-catalog visual language: warehouse location-code tags,
   ticket/label motifs, signal-orange accent against an industrial
   charcoal + paper-white palette. Built for fast scanning of data-dense
   screens, not a marketing aesthetic.
   ===================================================================== */

:root {
  /* Palette */
  --pt-bg: #F4F5F7;
  --pt-surface: #FFFFFF;
  --pt-dark: #14181F;
  --pt-dark-elevated: #1D232D;
  --pt-dark-border: #2B323D;
  --pt-accent: #FF6A39;
  --pt-accent-dark: #E2551F;
  --pt-accent-soft: #FFE7DC;
  --pt-success: #1F9D6B;
  --pt-success-soft: #DFF5EA;
  --pt-warning: #C8870A;
  --pt-warning-soft: #FBEFD6;
  --pt-danger: #D63B3B;
  --pt-danger-soft: #FBE2E2;
  --pt-text: #181B20;
  --pt-text-muted: #6B7280;
  --pt-text-faint: #9AA1AC;
  --pt-border: #E6E8EC;

  /* Type */
  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  /* Layout */
  --sidebar-w: 264px;
  --topbar-h: 64px;
  --radius: 10px;
}

/* Dark theme — toggled via html[data-theme="dark"], sidebar stays dark always by design */
html[data-theme="dark"] {
  --pt-bg: #15181E;
  --pt-surface: #1C212A;
  --pt-text: #E7E9EC;
  --pt-text-muted: #9BA2AD;
  --pt-text-faint: #6B7280;
  --pt-border: #2B313C;
  --pt-accent-soft: #3D2818;
  --pt-success-soft: #11301F;
  --pt-warning-soft: #382D0E;
  --pt-danger-soft: #371616;
}

html[data-theme="dark"] .pt-form-control { color: var(--pt-text); }
html[data-theme="dark"] .pt-login-aside::before { opacity: 0.5; }

* { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  /*background: var(--pt-bg);*/
  color: var(--pt-text);
  font-size: 14.5px;
}

h1, h2, h3, h4, .pt-display {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

.pt-mono { font-family: var(--font-mono); }

a { text-decoration: none; }

/* ---------------------------------------------------------------------
   Sidebar
   --------------------------------------------------------------------- */
.pt-sidebar {
  width: var(--sidebar-w);
  background: var(--pt-dark);
  color: #fff;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 1030;
}

.pt-sidebar-brand {
  padding: 22px 20px;
  border-bottom: 1px solid var(--pt-dark-border);
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.pt-sidebar-brand .mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: #fff;
}

.pt-sidebar-brand .mark span { color: var(--pt-accent); }

.pt-sidebar-brand .sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--pt-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pt-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
}

.pt-nav-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--pt-text-faint);
  padding: 14px 12px 6px;
}

.pt-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: #C7CCD4;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 1px;
  transition: background 0.15s ease, color 0.15s ease;
}

.pt-nav-item:hover {
  background: var(--pt-dark-elevated);
  color: #fff;
}

.pt-nav-item.active {
  background: var(--pt-dark-elevated);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--pt-accent);
}

.pt-nav-code {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  width: 30px;
  text-align: center;
  padding: 3px 0;
  border-radius: 4px;
  background: var(--pt-dark-elevated);
  color: var(--pt-text-faint);
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.pt-nav-item.active .pt-nav-code,
.pt-nav-item:hover .pt-nav-code {
  background: var(--pt-accent);
  color: #1A0D06;
}

.pt-nav-item i { font-size: 15px; width: 16px; text-align: center; }

.pt-sidebar-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--pt-dark-border);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--pt-text-faint);
}

/* ---------------------------------------------------------------------
   Topbar + main area
   --------------------------------------------------------------------- */
.pt-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

.pt-topbar {
  height: var(--topbar-h);
  background: var(--pt-surface);
  border-bottom: 1px solid var(--pt-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.pt-search {
  background: var(--pt-bg);
  border: 1px solid var(--pt-border);
  border-radius: 8px;
  padding: 7px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 320px;
  max-width: 100%;
  flex: 1 1 auto;
  min-width: 0;
}

.pt-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13.5px;
  width: 100%;
}

.pt-search i { color: var(--pt-text-faint); }

.pt-content { padding: 28px; }

/* ---------------------------------------------------------------------
   Page header
   --------------------------------------------------------------------- */
.pt-page-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--pt-accent-dark);
  font-weight: 700;
}

.pt-page-title { font-size: 26px; font-weight: 700; margin: 2px 0 4px; }
.pt-page-sub { color: var(--pt-text-muted); font-size: 13.5px; }

/* ---------------------------------------------------------------------
   Stat cards (signature: tag/ticket left edge with a perforation dot)
   --------------------------------------------------------------------- */
.pt-stat-card {
  background: var(--pt-surface);
  border: 1px solid var(--pt-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.pt-stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--accent-color, var(--pt-accent));
}

.pt-stat-card .pt-stat-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--pt-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.pt-stat-card .pt-stat-value {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 700;
  margin-top: 8px;
  line-height: 1;
}

.pt-stat-card .pt-stat-delta {
  font-size: 12px;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pt-stat-delta.up { color: var(--pt-success); }
.pt-stat-delta.down { color: var(--pt-danger); }
.pt-stat-delta.flat { color: var(--pt-text-muted); }

/* ---------------------------------------------------------------------
   Panels / tables
   --------------------------------------------------------------------- */
.pt-panel {
  background: var(--pt-surface);
  border: 1px solid var(--pt-border);
  border-radius: var(--radius);
}

.pt-panel-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--pt-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.pt-panel-head h3 { font-size: 15px; font-weight: 700; margin: 0; }

.pt-table { width: 100%; font-size: 13.5px; }
.pt-table th {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--pt-text-muted);
  font-weight: 600;
  padding: 10px 20px;
  border-bottom: 1px solid var(--pt-border);
  text-align: left;
}
.pt-table td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--pt-border);
  vertical-align: middle;
}
.pt-table tbody tr:last-child td { border-bottom: none; }
.pt-table tbody tr:hover { background: var(--pt-bg); }

.pt-id-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--pt-bg);
  border: 1px solid var(--pt-border);
  padding: 2px 7px;
  border-radius: 5px;
  color: var(--pt-text-muted);
}

/* ---------------------------------------------------------------------
   Badges
   --------------------------------------------------------------------- */
.pt-badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  display: inline-block;
}
.pt-badge.success { background: var(--pt-success-soft); color: var(--pt-success); }
.pt-badge.warning  { background: var(--pt-warning-soft); color: var(--pt-warning); }
.pt-badge.danger   { background: var(--pt-danger-soft); color: var(--pt-danger); }
.pt-badge.neutral  { background: var(--pt-bg); color: var(--pt-text-muted); border: 1px solid var(--pt-border); }

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn-pt {
  background: var(--pt-accent);
  border: none;
  color: #fff;
  font-weight: 600;
  font-size: 13.5px;
  padding: 9px 18px;
  border-radius: 8px;
  transition: background 0.15s ease;
}
.btn-pt:hover { background: var(--pt-accent-dark); color: #fff; }

.btn-pt-outline {
  background: transparent;
  border: 1px solid var(--pt-border);
  color: var(--pt-text);
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 16px;
  border-radius: 8px;
}
.btn-pt-outline:hover { border-color: var(--pt-text-faint); }

/* ---------------------------------------------------------------------
   Topbar controls: theme toggle + mobile menu button
   --------------------------------------------------------------------- */
.pt-icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--pt-border);
  background: var(--pt-surface);
  color: var(--pt-text);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.pt-icon-btn:hover { background: var(--pt-bg); }

.pt-menu-btn { display: none; }
@media (max-width: 900px) {
  .pt-menu-btn { display: flex; }
}

.pt-sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 12, 16, 0.5);
  z-index: 1025;
  display: none;
}
.pt-sidebar-backdrop.show { display: block; }

/* ---------------------------------------------------------------------
   Toast flash messages (replaces static inline alert banners)
   --------------------------------------------------------------------- */
.pt-toast-stack {
  position: fixed;
  top: 18px; right: 18px;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.pt-toast {
  background: var(--pt-surface);
  border: 1px solid var(--pt-border);
  border-left: 4px solid var(--pt-accent);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13.5px;
  color: var(--pt-text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: pt-toast-in 0.2s ease;
}
.pt-toast.success { border-left-color: var(--pt-success); }
.pt-toast.error { border-left-color: var(--pt-danger); }
.pt-toast .pt-toast-close { margin-left: auto; cursor: pointer; color: var(--pt-text-faint); background: none; border: none; font-size: 14px; line-height: 1; }

@keyframes pt-toast-in {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---------------------------------------------------------------------
   Button loading state (applied by admin.js on form submit)
   --------------------------------------------------------------------- */
.pt-btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.pt-btn-loading::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid rgba(255,255,255,0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: pt-spin 0.6s linear infinite;
}
.btn-pt-outline.pt-btn-loading::after { border-color: rgba(0,0,0,0.2); border-top-color: var(--pt-text); }

@keyframes pt-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------------
   Multi-image upload preview strip
   --------------------------------------------------------------------- */
.pt-img-preview-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.pt-img-thumb {
  width: 64px; height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--pt-border);
  background: var(--pt-bg);
}
.pt-img-thumb img { width: 100%; height: 100%; object-fit: cover; }

.pt-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
}
.pt-gallery-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--pt-border);
  aspect-ratio: 1;
  background: var(--pt-bg);
}
.pt-gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pt-gallery-item .pt-gallery-remove {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}
.pt-gallery-item .pt-gallery-primary-badge {
  position: absolute; bottom: 4px; left: 4px;
  font-size: 9px;
  background: var(--pt-accent);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

/* ---------------------------------------------------------------------
   Print / Save-as-PDF — hides chrome, leaves just the report content
   --------------------------------------------------------------------- */
@media print {
  .pt-sidebar, .pt-topbar, .pt-sidebar-backdrop, .pt-toast-stack,
  .no-print, form button, a.btn { display: none !important; }
  .pt-main { margin-left: 0 !important; }
  .pt-content { padding: 0 !important; }
  body { background: #fff !important; }
  .pt-panel { border: 1px solid #ccc !important; box-shadow: none !important; }
}

/* ---------------------------------------------------------------------
   Login screen
   --------------------------------------------------------------------- */
.pt-login-wrap { min-height: 100vh; display: flex; }

.pt-login-aside {
  width: 46%;
  background: var(--pt-dark);
  color: #fff;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.pt-login-aside::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--pt-dark-border) 1px, transparent 1px),
    linear-gradient(90deg, var(--pt-dark-border) 1px, transparent 1px);
  background-size: 36px 36px;
  opacity: 0.35;
}

.pt-login-aside .content { position: relative; z-index: 1; }

.pt-login-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--pt-dark-elevated);
  border: 1px solid var(--pt-dark-border);
  padding: 6px 12px;
  border-radius: 20px;
  color: var(--pt-text-faint);
  margin-bottom: 28px;
}

.pt-login-tag .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--pt-accent);
}

.pt-login-aside h1 {
  font-size: 38px;
  font-weight: 700;
  line-height: 1.15;
  max-width: 420px;
}

.pt-login-aside h1 span { color: var(--pt-accent); }

.pt-login-aside p.lead {
  color: var(--text-faint, #9AA1AC);
  margin-top: 14px;
  max-width: 380px;
  font-size: 14.5px;
}

.pt-login-foot {
  position: relative; z-index: 1;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--pt-text-faint);
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--pt-dark-border);
  padding-top: 16px;
}

.pt-login-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pt-surface);
  padding: 40px;
}

.pt-login-card { width: 100%; max-width: 380px; }

.pt-login-card .brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  margin-bottom: 36px;
}
.pt-login-card .brand-mark span { color: var(--pt-accent); }

.pt-login-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.pt-login-card p.help { color: var(--pt-text-muted); font-size: 13.5px; margin-bottom: 28px; }

.pt-form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--pt-text);
  margin-bottom: 6px;
  display: block;
}

.pt-form-control {
  width: 100%;
  border: 1px solid var(--pt-border);
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 14px;
  background: var(--pt-bg);
  outline: none;
  transition: border-color 0.15s ease;
}
.pt-form-control:focus {
  border-color: var(--pt-accent);
  background: var(--pt-surface);
  box-shadow: 0 0 0 3px var(--pt-accent-soft);
}

@media (max-width: 900px) {
  .pt-login-aside { display: none; }
  .pt-sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  .pt-sidebar.open { transform: translateX(0); }
  .pt-main { margin-left: 0; }
  .pt-content { padding: 18px; }
  .pt-topbar { padding: 0 14px; gap: 10px; }
  .pt-page-title { font-size: 22px; }

  /* Kanban columns stack on tablets/phones instead of squeezing 4-wide */
  #kanban-board > [class*="col-"] { width: 100%; max-width: 100%; flex: 0 0 100%; margin-bottom: 14px; }

  /* Stat-card grids: 2-up instead of 4-up so numbers stay readable */
  .row.g-3 > [class*="col-lg-3"], .row.g-3 > [class*="col-md-3"] { flex: 0 0 50%; max-width: 50%; }
}

@media (max-width: 560px) {
  .pt-content { padding: 14px; }
  .pt-topbar { padding: 0 10px; }
  .pt-search input::placeholder { font-size: 12px; }
  .pt-page-title { font-size: 19px; }
  .pt-sidebar-brand .sub { display: none; } /* "Admin Console" subtitle — sidebar is full-width drawer here anyway */
  .pt-stat-card { padding: 14px 16px; }
  .pt-stat-value { font-size: 22px; }

  /* Full-width single column for stat cards on very small phones */
  .row.g-3 > [class*="col-lg-3"], .row.g-3 > [class*="col-md-3"] { flex: 0 0 100%; max-width: 100%; }

  /* Modals: edge-to-edge with a small margin instead of Bootstrap's default centered gutter */
  .modal-dialog { margin: 10px; }

  /* Gallery thumbnails shrink a bit more to fit 3-up on narrow screens */
  .pt-gallery-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }

  /* Panel-head buttons go full width and stack under the heading */
  .pt-panel-head { flex-direction: column; align-items: stretch; }
  .pt-panel-head a.btn, .pt-panel-head button.btn { width: 100%; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
