/* Label Certification Dashboard — FedEx Light Theme (matching Label Validation AI) */

:root {
  --bg: #f5f7f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8f9fb;
  --border: #e8e8ed;
  --border-light: #f0f0f4;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --purple: #4b0082;
  --purple-light: #5c0099;
  --purple-dim: rgba(75, 0, 130, 0.06);
  --green: #16a34a;
  --green-dim: rgba(22, 163, 74, 0.08);
  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.06);
  --amber: #d97706;
  --amber-dim: rgba(217, 119, 6, 0.06);
  --blue: #2563eb;
  --blue-dim: rgba(37, 99, 235, 0.06);
  --header-height: 56px;
  --sidebar-width: 260px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================================
   TOP HEADER BAR
   ============================================================================ */
.top-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--purple);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(75, 0, 130, 0.15);
}
.top-header-brand {
  display: flex; align-items: center; gap: 10px;
  color: #ffffff; font-size: 16px; font-weight: 600;
}
.top-header-brand svg { width: 22px; height: 22px; fill: currentColor; }
.top-header-right {
  display: flex; align-items: center; gap: 16px;
  color: rgba(255,255,255,0.9); font-size: 13px;
}
.header-user { color: rgba(255,255,255,0.85); }
.header-badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 600;
  background: #ff6d00; color: #ffffff;
}
.header-icon {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.7); cursor: pointer;
  transition: background 0.15s; font-size: 16px;
}
.header-icon:hover { background: rgba(255,255,255,0.1); color: #ffffff; }

/* ============================================================================
   SIDEBAR
   ============================================================================ */
.sidebar {
  position: fixed; top: var(--header-height); left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: #ffffff;
  border-right: 1px solid var(--border);
  padding: 20px 0;
  overflow-y: auto;
  z-index: 50;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); border-radius: 4px; }

.nav-section { margin-bottom: 24px; }
.nav-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; margin-bottom: 8px;
}
.nav-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
}
.nav-section-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--purple);
}
.nav-section-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; font-size: 11px; font-weight: 600;
  background: var(--purple-dim); color: var(--purple);
}

.nav-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 20px; margin: 2px 8px; border-radius: 8px;
  color: var(--text); font-size: 14px; font-weight: 500;
  transition: all 0.15s; border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-item.active {
  background: var(--purple-dim);
  border-left-color: var(--purple);
  color: var(--purple);
}
.nav-item-icon {
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0; margin-top: 2px;
}
.nav-item-content { flex: 1; min-width: 0; }
.nav-item-label { display: block; line-height: 1.3; }
.nav-item-desc {
  display: block; font-size: 12px; font-weight: 400;
  color: var(--text-muted); line-height: 1.3; margin-top: 2px;
}
.nav-item.active .nav-item-desc { color: var(--purple); opacity: 0.7; }

/* ============================================================================
   MAIN CONTENT
   ============================================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  padding: 28px 32px;
  min-height: calc(100vh - var(--header-height));
}

/* Page header */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.page-header-left { }
.page-title { font-size: 24px; font-weight: 700; color: var(--text); }
.page-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 2px; }
.page-actions { display: flex; align-items: center; gap: 8px; }

/* ============================================================================
   CARDS
   ============================================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.card-glass {
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* ============================================================================
   SEARCH & FILTER BAR
   ============================================================================ */
.search-filter-bar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.search-input-wrap {
  flex: 1; min-width: 200px; position: relative;
}
.search-input-wrap .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 14px; pointer-events: none;
}
.search-input {
  width: 100%; padding: 10px 12px 10px 36px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; color: var(--text); background: var(--bg-card);
  outline: none; transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--purple); }
.search-input::placeholder { color: var(--text-muted); }

.filter-select {
  padding: 10px 14px; border-radius: 8px; font-size: 13px;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text);
  cursor: pointer; outline: none; min-width: 100px;
}
.filter-select:focus { border-color: var(--purple); }
.filter-label { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.filter-group { display: flex; flex-direction: column; }

/* ============================================================================
   TABLES
   ============================================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; padding: 12px 16px;
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-muted);
  border-bottom: 2px solid var(--border); background: #fafbfc;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border-light); }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: #f8f9fb; }
tbody tr:last-child td { border-bottom: none; }

/* Table info row */
.table-info {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; color: var(--text-muted); font-size: 13px;
}
.table-info-title { font-size: 16px; font-weight: 600; color: var(--text); }
.table-info-count { color: var(--text-muted); font-size: 13px; }

/* ============================================================================
   BADGES
   ============================================================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600;
}
.badge-pass { background: var(--green-dim); color: var(--green); }
.badge-fail { background: var(--red-dim); color: var(--red); }
.badge-warn { background: var(--amber-dim); color: var(--amber); }
.badge-info { background: var(--purple-dim); color: var(--purple); }
.badge-na { background: #f0f0f4; color: var(--text-muted); }
.badge-escalate { background: var(--amber-dim); color: var(--amber); }
.badge-skipped { background: #f0f0f4; color: var(--text-muted); }
.badge-processing { background: var(--blue-dim); color: var(--blue); }
.badge-completed { background: var(--green-dim); color: var(--green); }
.badge-queued { background: #f0f0f4; color: var(--text-muted); }
.badge-ursa5 { background: var(--purple-dim); color: var(--purple); }
.badge-ofact1 { background: var(--blue-dim); color: var(--blue); }
.badge-critical { background: var(--red-dim); color: var(--red); }
.badge-major { background: var(--amber-dim); color: var(--amber); }
.badge-minor { background: #f0f0f4; color: var(--text-muted); }

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  text-decoration: none; cursor: pointer; border: none;
  transition: all 0.15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--purple); color: white; }
.btn-primary:hover { background: var(--purple-light); }
.btn-secondary { background: #f0f0f4; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e8e8ed; }
.btn-outline { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-outline:hover { background: #f5f7f9; color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { font-size: 15px; }

/* ============================================================================
   METRICS
   ============================================================================ */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 20px; text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.metric-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 8px; }
.metric-value { font-size: 28px; font-weight: 700; }
.metric-value.purple { color: var(--purple); }
.metric-value.green { color: var(--green); }
.metric-value.red { color: var(--red); }
.metric-value.blue { color: var(--blue); }
.metric-value.amber { color: var(--amber); }

/* Pipeline bars */
.pipeline-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.pipeline-label { width: 100px; font-size: 13px; color: var(--text-muted); text-align: right; }
.pipeline-track { flex: 1; height: 28px; background: #f0f0f4; border-radius: 6px; overflow: hidden; position: relative; }
.pipeline-fill { height: 100%; border-radius: 6px; display: flex; align-items: center; padding-left: 10px; font-size: 12px; font-weight: 600; color: #fff; min-width: 28px; transition: width 0.5s; }
.pipeline-fill.processing { background: linear-gradient(90deg, var(--amber), #f59e0b); }
.pipeline-fill.completed { background: linear-gradient(90deg, var(--green), #10b981); }
.pipeline-fill.failed { background: linear-gradient(90deg, var(--red), #ef4444); }

/* ============================================================================
   FORMS
   ============================================================================ */
.eval-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
@media (max-width: 900px) { .eval-grid { grid-template-columns: 1fr; } }

.eval-form { margin-top: 16px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 4px; }
.form-input {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); font-size: 14px; outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--purple); }

/* ============================================================================
   PAGINATION
   ============================================================================ */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border-light);
}
.page-info { font-size: 13px; color: var(--text-muted); }

/* ============================================================================
   ALERTS
   ============================================================================ */
.alert { padding: 12px 20px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ============================================================================
   UTILITY
   ============================================================================ */
.text-pass { color: var(--green); }
.text-fail { color: var(--red); }
.text-warn { color: var(--amber); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

/* Progress bar */
.progress-bar { display: inline-block; width: 80px; height: 8px; background: #e8e8ed; border-radius: 4px; margin-right: 8px; vertical-align: middle; }
.progress-fill { height: 100%; border-radius: 4px; }
.bg-pass { background: var(--green); }
.bg-fail { background: var(--red); }
.bg-warn { background: var(--amber); }

/* Meta row */
.meta-row { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; padding: 12px 16px; background: var(--bg-card); border-radius: 8px; border: 1px solid var(--border); }
.meta-row.compact { gap: 12px; padding: 8px 12px; font-size: 12px; }
.meta-item { font-size: 13px; color: var(--text-muted); }
.meta-item strong { color: var(--text); }

/* Back link */
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.back-link:hover { color: var(--text); text-decoration: none; }

/* Stats row */
.stats-row { display: flex; gap: 12px; margin-bottom: 16px; }
.stat-chip { flex: 1; padding: 12px; border-radius: 8px; text-align: center; background: var(--bg-card); border: 1px solid var(--border); }
.stat-chip-value { font-size: 20px; font-weight: 700; }
.stat-chip-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* Filter bar (legacy) */
.filter-bar { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }

/* ============================================================================
   SPLIT VIEW / DETAIL PAGE
   ============================================================================ */
.split-view { display: grid; grid-template-columns: 55% 45%; gap: 20px; min-height: 70vh; }
@media (max-width: 1024px) { .split-view { grid-template-columns: 1fr; } }
.panel-left { }
.panel-right { position: sticky; top: 28px; align-self: start; max-height: calc(100vh - 56px); overflow-y: auto; }
.panel-right::-webkit-scrollbar { width: 4px; }
.panel-right::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 4px; }

.detail-split { display: grid; grid-template-columns: 45% 55%; gap: 24px; }
@media (max-width: 900px) { .detail-split { grid-template-columns: 1fr; } }
.detail-image { position: sticky; top: 20px; align-self: start; }
.detail-image .label-img { width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.no-image { padding: 60px; text-align: center; color: var(--text-muted); background: var(--bg-card); border-radius: 8px; }

/* Label tabs */
.label-tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 12px; margin-bottom: 16px; }
.label-tab {
  padding: 8px 16px; border-radius: 8px;
  font-size: 13px; white-space: nowrap; cursor: pointer;
  background: transparent; border: 1px solid transparent;
  color: var(--text-muted); transition: all 0.15s;
}
.label-tab:hover { background: var(--bg-card-hover); color: var(--text); text-decoration: none; }
.label-tab.active { background: var(--purple-dim); color: var(--purple); border-color: rgba(75,0,130,0.15); }

/* Image viewer */
.image-viewer { background: #f0f0f4; border-radius: 8px; padding: 16px; text-align: center; min-height: 400px; display: flex; align-items: center; justify-content: center; }
.image-viewer img { max-width: 100%; max-height: 70vh; object-fit: contain; border-radius: 4px; }

/* Verdict banner */
.verdict-banner { padding: 16px 20px; border-radius: 10px; margin-bottom: 16px; display: flex; align-items: center; gap: 12px; }
.verdict-banner.pass { background: var(--green-dim); border: 1px solid rgba(22,163,74,0.2); }
.verdict-banner.fail { background: var(--red-dim); border: 1px solid rgba(220,38,38,0.2); }
.verdict-banner.escalate { background: var(--amber-dim); border: 1px solid rgba(217,119,6,0.2); }
.verdict-banner.skipped { background: #f0f0f4; border: 1px solid rgba(0,0,0,0.08); }
.verdict-icon { font-size: 24px; }
.verdict-text { font-size: 18px; font-weight: 700; }
.verdict-banner.pass .verdict-text { color: var(--green); }
.verdict-banner.fail .verdict-text { color: var(--red); }
.verdict-banner.escalate .verdict-text { color: var(--amber); }
.verdict-banner.skipped .verdict-text { color: var(--text-muted); }

/* Rule results */
.rule-section { margin-bottom: 16px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.rule-section-title { font-size: 14px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.rule-section-header { padding: 12px 16px; background: #fafbfc; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.rule-section-header:hover { background: var(--bg-card-hover); }
.rule-count { font-size: 12px; color: var(--text-muted); }
.rule-list { padding: 8px; }
.rule-item { padding: 10px 12px; border-radius: 6px; margin-bottom: 6px; border-left: 3px solid transparent; }
.rule-correct { border-left-color: var(--green); background: rgba(22, 163, 74, 0.03); }
.rule-incorrect { border-left-color: var(--red); background: rgba(220, 38, 38, 0.03); }
.rule-unknown { border-left-color: var(--border); }
.rule-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.rule-id { font-weight: 600; font-size: 13px; }
.rule-text { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.rule-expected { font-size: 12px; color: var(--red); margin-bottom: 4px; }
.rule-details { font-size: 12px; color: var(--text-muted); font-style: italic; padding: 6px 8px; background: #f5f7f9; border-radius: 4px; margin-top: 4px; }
.rule-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border-light); font-size: 13px; }
.rule-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.rule-icon.pass { color: var(--green); }
.rule-icon.fail { color: var(--red); }
.rule-icon.na { color: var(--text-muted); }
.rule-name { font-weight: 600; color: var(--text); }
.rule-meta { display: flex; gap: 6px; margin-top: 4px; }
.score-icon { font-size: 16px; color: var(--green); font-weight: 700; }
.score-icon.score-wrong { color: var(--red); }
.no-rules { padding: 40px; text-align: center; color: var(--text-muted); }

/* Compare grid */
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
@media (max-width: 900px) { .compare-grid { grid-template-columns: 1fr; } }

/* Diagnostics — tabbed layout */
.diag-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.diag-item { padding: 10px; border-radius: 6px; background: #f5f7f9; font-size: 12px; }
.diag-label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; }
.diag-value { font-weight: 600; margin-top: 2px; }

.diag-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border, #e0e0e0); margin-bottom: 12px; }
.diag-tab { background: none; border: none; padding: 8px 16px; font-size: 13px; font-weight: 500; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color 0.15s, border-color 0.15s; }
.diag-tab:hover { color: var(--text-primary, #333); }
.diag-tab.active { color: var(--blue, #3b82f6); border-bottom-color: var(--blue, #3b82f6); }

.diag-panel { display: none; }
.diag-panel.active { display: block; }

.diag-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.diag-table th { text-align: left; padding: 6px 10px; background: var(--bg-secondary, #f5f7f9); color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; border-bottom: 1px solid var(--border, #e0e0e0); }
.diag-table td { padding: 6px 10px; border-bottom: 1px solid var(--border-light, #f0f0f0); vertical-align: top; }
.diag-table td.diag-key { color: var(--text-muted); white-space: nowrap; width: 35%; }
.diag-table td.diag-val { font-weight: 500; word-break: break-all; }

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 16px; margin-top: var(--header-height); }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .split-view { grid-template-columns: 1fr; }
  .eval-grid { grid-template-columns: 1fr; }
}
