/* =============================================================================
 * BiPRO-Panel (Web-Client)
 *
 * Zwei Sub-Views unter dem Nav-Eintrag "BiPRO":
 *   1. Sendungen-Cache   (bipro_shipments_cache + Fetch/Ack)
 *   2. VU-Verwaltung     (bipro_vu_credentials CRUD)
 *   3. Jobs-Log          (bipro_worker_jobs)
 *
 * Design-Richtlinien:
 *   - Dark-Theme nach ATLAS-Web-Client, ACENCIA-CI ueber die --ac-*-Tokens
 *     aus css/styles.css. KEINE Hex-Literale, KEINE Inline-Styles.
 *   - Namensschema .bp-* (BiPRO). Komponenten-Patterns sind an
 *     css/scs_imports.css angelehnt (gleiche Shell/Header/Table-/Modal-
 *     Konventionen), damit Panels konsistent wirken.
 * ========================================================================== */

/* ── Page-Shell ──────────────────────────────────────────────────────────── */

.bp-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 24px 24px;
  min-height: 100%;
  background: var(--ac-bg);
  color: var(--ac-text);
  font-family: var(--ac-font);
}

.bp-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ac-border);
}

.bp-header-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.bp-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: var(--ac-accent);
  font-weight: 600;
}

.bp-title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ac-text);
}

.bp-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--ac-text-muted);
  max-width: 720px;
  line-height: 1.5;
}

.bp-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.bp-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--ac-radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--ac-transition);
  border: 1px solid var(--ac-border-input);
  background: var(--ac-bg-elevated);
  color: var(--ac-text);
  font-family: var(--ac-font);
  white-space: nowrap;
}

.bp-btn:hover:not(:disabled) {
  border-color: var(--ac-border-hover);
  background: var(--ac-bg-card);
}

.bp-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bp-btn--primary {
  background: var(--ac-primary);
  border-color: var(--ac-primary);
  color: #ffffff;
}

.bp-btn--primary:hover:not(:disabled) {
  background: color-mix(in oklch, var(--ac-primary) 88%, white);
  border-color: color-mix(in oklch, var(--ac-primary) 88%, white);
}

.bp-btn--accent {
  background: var(--ac-accent);
  border-color: var(--ac-accent);
  color: #ffffff;
  box-shadow: 0 0 0 0 var(--ac-accent-glow);
  transition: box-shadow var(--ac-transition), background var(--ac-transition);
}

.bp-btn--accent:hover:not(:disabled) {
  background: color-mix(in oklch, var(--ac-accent) 88%, white);
  box-shadow: 0 0 0 6px var(--ac-accent-glow);
}

.bp-btn--danger {
  background: transparent;
  border-color: var(--ac-error);
  color: var(--ac-error);
}

.bp-btn--danger:hover:not(:disabled) {
  background: var(--ac-error-soft);
}

.bp-btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ac-text-secondary);
}

.bp-btn--ghost:hover:not(:disabled) {
  color: var(--ac-text);
  background: var(--ac-bg-elevated);
}

.bp-btn--small {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

/* ── Stats-Grid ──────────────────────────────────────────────────────────── */

.bp-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.bp-stat {
  position: relative;
  background: var(--ac-bg-card);
  border: 1px solid var(--ac-border);
  border-radius: var(--ac-radius);
  padding: 12px 14px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.bp-stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--bp-stat-accent, transparent);
}

.bp-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ac-text-muted);
}

.bp-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--ac-text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.bp-stat-sub {
  font-size: 11px;
  color: var(--ac-text-muted);
  margin-top: 2px;
}

.bp-stat--vus      { --bp-stat-accent: var(--ac-primary); }
.bp-stat--open     { --bp-stat-accent: var(--ac-accent); }
.bp-stat--queued   { --bp-stat-accent: var(--ac-primary); }
.bp-stat--acked    { --bp-stat-accent: var(--ac-green); }
.bp-stat--failed   { --bp-stat-accent: var(--ac-error); }

/* ── Tabs ────────────────────────────────────────────────────────────────── */

.bp-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--ac-border);
}

.bp-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  color: var(--ac-text-secondary);
  font-family: var(--ac-font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--ac-transition), border-color var(--ac-transition);
}

.bp-tab:hover {
  color: var(--ac-text);
}

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

/* ── Content-Container + Table-Section ───────────────────────────────────── */

.bp-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bp-section {
  background: var(--ac-bg-card);
  border: 1px solid var(--ac-border);
  border-radius: var(--ac-radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 220px;
}

.bp-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bp-section-count {
  font-size: 12px;
  color: var(--ac-text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Filter-Zeile ────────────────────────────────────────────────────────── */

.bp-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.bp-filter-select {
  height: 34px;
  padding: 0 12px;
  border-radius: var(--ac-radius-sm);
  border: 1px solid var(--ac-border-input);
  background: var(--ac-bg-input);
  color: var(--ac-text);
  font-family: var(--ac-font);
  font-size: 13px;
  min-width: 160px;
  cursor: pointer;
  transition: border-color var(--ac-transition);
}

.bp-filter-select:focus {
  outline: none;
  border-color: var(--ac-primary);
}

/* ── Tabellen ────────────────────────────────────────────────────────────── */

.bp-table-wrap {
  border: 1px solid var(--ac-border);
  border-radius: var(--ac-radius-sm);
  overflow: auto;
  max-height: 65vh;
}

.bp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.bp-table thead th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ac-border);
  background: var(--ac-bg-elevated);
  color: var(--ac-text-secondary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  z-index: 1;
}

.bp-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--ac-border);
  color: var(--ac-text);
  vertical-align: middle;
}

.bp-table tbody tr {
  transition: background var(--ac-transition);
}

.bp-table tbody tr:hover {
  background: var(--ac-bg-elevated);
}

.bp-table tbody tr:last-child td {
  border-bottom: 0;
}

.bp-cell-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.bp-cell-mono {
  font-family: 'JetBrains Mono', 'Consolas', 'SF Mono', Menlo, monospace;
  font-size: 11px;
  color: var(--ac-text-secondary);
  word-break: break-all;
}

/* ── Tags / Status-Pills ─────────────────────────────────────────────────── */

.bp-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
  white-space: nowrap;
}

/* Shipment-Ack-Status */
.bp-tag--open         { background: var(--ac-accent-soft); color: var(--ac-accent); border-color: var(--ac-accent); }
.bp-tag--acknowledged { background: var(--ac-green-soft);  color: var(--ac-green);  border-color: var(--ac-green); }
.bp-tag--failed       { background: var(--ac-error-soft);  color: var(--ac-error);  border-color: var(--ac-error); }

/* Job-Status */
.bp-tag--queued       { background: var(--ac-primary-soft); color: var(--ac-primary); border-color: var(--ac-primary); }
.bp-tag--running      { background: var(--ac-warning-soft); color: var(--ac-warning); border-color: var(--ac-warning); }
.bp-tag--succeeded    { background: var(--ac-green-soft);   color: var(--ac-green);   border-color: var(--ac-green); }
.bp-tag--cancelled    { background: var(--ac-bg-elevated);  color: var(--ac-text-muted); border-color: var(--ac-border); }

/* VU-Status */
.bp-tag--active       { background: var(--ac-green-soft);   color: var(--ac-green);   border-color: var(--ac-green); }
.bp-tag--inactive     { background: var(--ac-bg-elevated);  color: var(--ac-text-muted); border-color: var(--ac-border); }

/* ── Empty / Loading / Error ─────────────────────────────────────────────── */

.bp-empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--ac-text-muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.bp-empty-state-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ac-bg-elevated);
  border: 1px solid var(--ac-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ac-text-muted);
}

.bp-empty-state-title {
  color: var(--ac-text);
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.bp-empty-state-hint {
  color: var(--ac-text-muted);
  font-size: 12px;
  margin: 0;
  max-width: 420px;
  line-height: 1.5;
}

.bp-loading {
  padding: 40px 12px;
  text-align: center;
  color: var(--ac-text-muted);
  font-size: 13px;
}

.bp-error-box {
  padding: 10px 14px;
  background: var(--ac-error-soft);
  border: 1px solid var(--ac-error);
  color: var(--ac-error);
  border-radius: var(--ac-radius-sm);
  font-size: 13px;
}

/* ── Modal (VU-CRUD) ─────────────────────────────────────────────────────── */

.bp-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 13, 0.55);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bp-modal {
  background: var(--ac-bg-card);
  color: var(--ac-text);
  border: 1px solid var(--ac-border);
  border-radius: var(--ac-radius);
  min-width: 480px;
  max-width: 640px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--ac-shadow-lg);
  animation: bp-modal-fade 0.18s ease-out;
}

@keyframes bp-modal-fade {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

.bp-modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--ac-border);
  background: var(--ac-bg-elevated);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.bp-modal-header h2 {
  margin: 0;
  font-size: 15px;
  color: var(--ac-text);
  font-weight: 600;
}

.bp-modal-body {
  padding: 18px 20px;
  overflow: auto;
  flex: 1;
}

.bp-modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--ac-border);
  background: var(--ac-bg-elevated);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Formular (Modal-Felder) ─────────────────────────────────────────────── */

.bp-form-row {
  margin-bottom: 12px;
}

.bp-form-row > label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--ac-text-secondary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bp-form-row > input,
.bp-form-row > select,
.bp-form-row > textarea {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--ac-border-input);
  border-radius: var(--ac-radius-sm);
  background: var(--ac-bg-input);
  color: var(--ac-text);
  font-family: var(--ac-font);
  font-size: 13px;
  box-sizing: border-box;
  transition: border-color var(--ac-transition);
}

.bp-form-row > textarea {
  height: auto;
  min-height: 80px;
  padding: 8px 10px;
  resize: vertical;
  font-family: 'JetBrains Mono', 'Consolas', 'SF Mono', Menlo, monospace;
  font-size: 11px;
  line-height: 1.4;
}

.bp-form-row > input::placeholder,
.bp-form-row > textarea::placeholder {
  color: var(--ac-text-muted);
}

.bp-form-row > input:focus,
.bp-form-row > select:focus,
.bp-form-row > textarea:focus {
  outline: none;
  border-color: var(--ac-primary);
}

.bp-form-help {
  display: block;
  margin-top: 4px;
  color: var(--ac-text-muted);
  font-size: 11px;
  line-height: 1.4;
}

.bp-form-row--split {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.bp-form-row--split > .bp-form-row {
  flex: 1;
  margin-bottom: 0;
}
