/* WMS Dashboard - Desktop-first, no icons, no images
   Dark/Light mode via CSS custom properties. */

/* --- Theme Variables --- */

:root {
  /* Light theme (default - office) */
  --bg-page: #f5f5f5;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-topbar: #1a237e;
  --bg-table-header: #f5f5f5;
  --bg-table-hover: #f8f9ff;
  --bg-input: #ffffff;
  --bg-detail: #ffffff;
  --text-primary: #333333;
  --text-secondary: #444444;
  --text-muted: #888888;
  --text-dim: #666666;
  --text-topbar: #ffffff;
  --text-topbar-dim: #bbdefb;
  --accent: #1a237e;
  --accent-hover: #283593;
  --accent-light: #c5cae9;
  --accent-bg: #e8eaf6;
  --success: #2e7d32;
  --success-bg: #e8f5e9;
  --success-border: #a5d6a7;
  --danger: #c62828;
  --danger-bg: #ffebee;
  --danger-border: #ef9a9a;
  --border: #dddddd;
  --border-light: #eeeeee;
  --shadow: rgba(0, 0, 0, 0.1);
}

body.theme-dark {
  /* Dark theme */
  --bg-page: #1a1a2e;
  --bg-card: #16213e;
  --bg-sidebar: #16213e;
  --bg-topbar: #0f3460;
  --bg-table-header: #1a1a2e;
  --bg-table-hover: #1e2a4a;
  --bg-input: #1a1a2e;
  --bg-detail: #16213e;
  --text-primary: #eaeaea;
  --text-secondary: #cccccc;
  --text-muted: #888888;
  --text-dim: #aaaaaa;
  --text-topbar: #ffffff;
  --text-topbar-dim: #4fc3f7;
  --accent: #4fc3f7;
  --accent-hover: #81d4fa;
  --accent-light: #0f3460;
  --accent-bg: #1a2a4a;
  --success: #4caf50;
  --success-bg: #1b3a1b;
  --success-border: #4caf50;
  --danger: #e94560;
  --danger-bg: #4a0000;
  --danger-border: #e94560;
  --border: #0f3460;
  --border-light: #2a2a4a;
  --shadow: rgba(0, 0, 0, 0.3);
}

/* --- Reset --- */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg-page);
  color: var(--text-primary);
  height: 100%;
  /* Only .main-content scrolls; the page itself never does. */
  overflow: hidden;
}

/* --- Layout --- */

.app-layout {
  display: flex;
  /* Start below the fixed 48px top-bar and fill the rest of the viewport, so
     the inner scroll stays inside .main-content (footer no longer slides off). */
  height: calc(100vh - 48px);
  margin-top: 48px;
}

/* --- Top bar --- */

.top-bar {
  background: var(--bg-topbar);
  color: var(--text-topbar);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  position: fixed;
  top: 0;
  left: 200px; /* starts to the right of the full-height sidebar */
  right: 0;
  height: 48px;
  z-index: 100;
}

/* Centered title; user-info sits on the right. app-name is centered via
   absolute positioning so it stays centered regardless of user-info width. */
.top-bar .app-name {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 1px;
  pointer-events: none;
}

.top-bar .user-info {
  margin-left: auto; /* push to the right edge */
  position: relative;
  z-index: 1; /* above the centered title */
}

.top-bar .user-info {
  font-size: 13px;
  color: var(--text-topbar-dim);
}

.top-bar .theme-btn {
  background: none;
  border: 1px solid var(--text-topbar-dim);
  color: var(--text-topbar-dim);
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  margin-left: 12px;
}

.top-bar .theme-btn:hover {
  background: rgba(255,255,255,0.1);
}

/* --- Sidebar --- */

.sidebar {
  width: 200px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 101; /* full-height, above the top-bar which starts at left:200px */
}

/* Logo slot at the top-left of the sidebar (same height as the top-bar). */
.sidebar-logo {
  height: 96px;
  display: flex;
  align-items: center;
  padding: 0 16px;
}

.sidebar-logo .site-logo {
  max-height: 32px;
  max-width: 100%;
  object-fit: contain;
}

.sidebar-logo .site-logo-placeholder {
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 1px;
  color: var(--accent);
}

.nav-group {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

/* Push the nav down so the first item lines up roughly with where the data
   table starts in the content area (below top-bar + page title + filters). */
.sidebar-logo + .nav-group {
  padding-top: 72px;
}

/* Push the first nav group down so it starts roughly level with the data table
   on the right (below the top-bar + page title + filters). */
.nav-group:first-of-type {
  margin-top: 108px;
}

.nav-group-title {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 16px;
  letter-spacing: 0.5px;
}

.nav-item {
  display: block;
  padding: 8px 16px 8px 24px;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  font-size: 13px;
}

.nav-item:hover {
  background: var(--accent-bg);
}

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: bold;
}

/* --- Main content --- */

.main-content {
  margin-left: 200px;
  padding: 20px 20px 48px; /* extra bottom space so content clears the fixed footer */
  flex: 1;
  /* Own scroll region; fills .app-layout (which is already below the top-bar). */
  height: 100%;
  overflow-y: auto;
}

/* --- App footer --- */

.app-footer {
  position: fixed;
  bottom: 0;
  left: 200px; /* clears the fixed 200px sidebar */
  right: 0;
  background: var(--bg-page);
  border-top: 1px solid var(--border-light);
  padding: 6px 20px;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.5;
  z-index: 40;
}

.app-footer-line:first-child {
  font-weight: 500;
}

.app-footer-line:last-child {
  font-size: 9px;
  opacity: 0.85;
}

/* --- Capacity bar --- */

.capacity-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.capacity-bar {
  flex: 0 0 120px;
  height: 16px;
  background: var(--bg-table-header);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.capacity-bar-fill {
  height: 100%;
  background: #8bc34a;
  border-radius: 3px 0 0 3px;
  transition: width 0.2s ease;
}

.capacity-text {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* --- Page header --- */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.page-title {
  font-size: 20px;
  font-weight: bold;
  color: var(--accent);
}

/* --- Cards --- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

/* A card that fills the remaining page height (e.g. Start "recent operations"),
   so its inner .table-scroll can grow to the footer instead of a fixed cap. */
.card--grow {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* --- Stats row --- */

.stats-row {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px;
  flex: 1;
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: bold;
  color: var(--accent);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 4px;
}

/* --- Tables --- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.data-table th {
  background: var(--bg-table-header);
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 2px solid var(--border);
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}

.data-table tr:hover {
  background: var(--bg-table-hover);
  cursor: pointer;
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* --- Filters --- */

.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
}

.filter-group label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.filter-group input,
.filter-group select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 13px;
  min-width: 140px;
  background: var(--bg-input);
  color: var(--text-primary);
}

.filter-group input:focus,
.filter-group select:focus {
  border-color: var(--accent);
  outline: none;
}

/* --- Buttons --- */

.btn {
  padding: 8px 16px;
  font-size: 13px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-weight: 500;
}

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

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border-light);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* --- Status badges (text only) --- */

.status-active {
  color: var(--success);
  font-weight: bold;
}

.status-inactive {
  color: var(--danger);
  font-weight: bold;
}

/* --- Modal / Detail panel --- */

.detail-panel {
  position: fixed;
  top: 48px;
  right: 0;
  width: 400px;
  bottom: 0;
  background: var(--bg-detail);
  border-left: 2px solid var(--accent);
  padding: 20px;
  overflow-y: auto;
  box-shadow: -4px 0 12px var(--shadow);
  z-index: 50;
  display: none;
}

.detail-panel.open {
  display: block;
}

.detail-panel .close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
}

.detail-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.detail-row .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.detail-row .value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-top: 2px;
}

/* Section heading inside the detail panel (replaces the old <hr> separator). */
.detail-section-title {
  font-size: 16px;
  font-weight: normal;
  color: var(--text-primary);
  margin: 20px 0 10px;
}

/* --- Forms --- */

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 14px;
  background: var(--bg-input);
  color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  outline: none;
}

/* --- Pagination --- */

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding: 6px 0;
  flex-shrink: 0;
}

.pagination .info {
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Notifications --- */

.toast {
  position: fixed;
  top: 60px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  display: none;
}

.toast.show { display: block; }
.toast-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.toast-error { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }

/* --- Section pages hidden by default --- */

.page { display: none; }
/* Active page fills the scroll region as a flex column so a table can take the
   remaining height and scroll internally (header + filters stay fixed). */
.page.active { display: flex; flex-direction: column; height: 100%; }

/* Scrollable table wrapper: takes remaining vertical space; only the rows
   scroll. min-height:0 is required so the flex child can actually shrink. */
.table-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* Inside the scroll wrapper the table must NOT clip (overflow:hidden +
   border-radius on <table> breaks position:sticky on its thead). The border
   and rounding live on .table-scroll instead. */
.table-scroll .data-table {
  border: none;
  border-radius: 0;
  overflow: visible;
}

/* Start-page tables live in stacked cards: cap the height and scroll internally
   instead of filling the whole page. Grows with content up to the cap. */
.table-scroll--capped {
  flex: 0 1 auto;
  max-height: 320px;
}

/* Column headers stay visible while rows scroll. With border-collapse the
   collapsed border detaches from a sticky th, so draw the bottom line as an
   inset box-shadow (which travels with the sticky element). */
.table-scroll .data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-table-header);
  border-bottom: 1px solid var(--border);
}

/* --- Empty state --- */

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

/* --- Export button area --- */

.actions-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* --- Remove number input spinner arrows (global) --- */

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
