/* ═══════════════════════════════════════════════════════
   PeppolFlow Dashboard — Premium Dark UI
   ═══════════════════════════════════════════════════════ */
:root {
  --bg:        #0a0d14;
  --bg2:       #0f1520;
  --bg3:       #151d2e;
  --card:      #111827;
  --card2:     #1a2235;
  --border:    #1e2d42;
  --border2:   #243350;
  --primary:   #3b82f6;
  --primary-d: #2563eb;
  --accent:    #8b5cf6;
  --success:   #10b981;
  --danger:    #ef4444;
  --warning:   #f59e0b;
  --text:      #e2e8f0;
  --text2:     #94a3b8;
  --text3:     #64748b;
  --mono:      'JetBrains Mono', monospace;
  --sans:      'Inter', sans-serif;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
}

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

html { font-size: 14px; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 0 20px rgba(59,130,246,0.3);
}
.logo-title { display: block; font-size: 15px; font-weight: 700; color: var(--text); }
.logo-sub   { display: block; font-size: 11px; color: var(--text3); margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.2s;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(59,130,246,0.15), rgba(139,92,246,0.08));
  color: var(--primary);
  border-left: 2px solid var(--primary);
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.api-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text3); }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text3);
  animation: pulse 2s infinite;
}
.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--danger); animation: none; }
.docs-link { font-size: 12px; color: var(--primary); text-decoration: none; }
.docs-link:hover { text-decoration: underline; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ── Main ────────────────────────────────────────────── */
.main-content {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  position: sticky; top: 0; z-index: 50;
}
.page-title { font-size: 22px; font-weight: 700; }
.page-sub   { font-size: 12.5px; color: var(--text3); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.badge {
  padding: 4px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.5px;
}
.badge-live { background: rgba(16,185,129,0.15); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }

/* ── Pages ───────────────────────────────────────────── */
.page { display: none; padding: 32px; animation: fadeIn 0.2s ease; }
.page.active { display: block; }

@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }

/* ── Stat Cards ──────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card.success { border-color: rgba(16,185,129,0.3); background: linear-gradient(135deg, var(--card), rgba(16,185,129,0.05)); }
.stat-card.danger  { border-color: rgba(239,68,68,0.3);  background: linear-gradient(135deg, var(--card), rgba(239,68,68,0.05)); }
.stat-card.accent  { border-color: rgba(139,92,246,0.3); background: linear-gradient(135deg, var(--card), rgba(139,92,246,0.05)); }
.stat-icon { font-size: 28px; }
.stat-value { font-size: 28px; font-weight: 800; }
.stat-label { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* ── Flow Row ────────────────────────────────────────── */
.flow-row {
  display: flex; gap: 24px; margin-bottom: 28px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  align-items: center; justify-content: center;
}
.flow-card { text-align: center; flex: 1; }
.flow-label { font-size: 12px; color: var(--text3); margin-bottom: 8px; }
.flow-count { font-size: 36px; font-weight: 800; color: var(--primary); }
.flow-arrow { font-size: 20px; color: var(--text3); margin-top: 4px; }
.flow-divider { width: 1px; height: 60px; background: var(--border); }

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.card-desc  { font-size: 13px; color: var(--text2); margin-bottom: 20px; line-height: 1.6; }

/* ── Two-col ─────────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }

/* ── Forms ───────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }

.select, .textarea, input[type=text] {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  font-family: var(--sans);
  outline: none;
  transition: border-color 0.2s;
}
.select:focus, .textarea:focus { border-color: var(--primary); }
.textarea { resize: vertical; }
.textarea.mono { font-family: var(--mono); font-size: 12px; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600;
  border: none; cursor: pointer;
  transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-d); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59,130,246,0.4); }
.btn-accent   { background: var(--accent); color: #fff; }
.btn-accent:hover   { filter: brightness(1.1); }
.btn-secondary{ background: var(--bg3); color: var(--text); border: 1px solid var(--border2); }
.btn-secondary:hover{ background: var(--border2); }
.btn-block    { width: 100%; justify-content: center; margin-top: 8px; }
.btn-row      { display: flex; gap: 10px; margin-top: 12px; }

.btn-sm { padding: 5px 10px; font-size: 11.5px; border-radius: 6px; }

/* ── Drop Zone ───────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 16px;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(59,130,246,0.05);
}
.drop-icon { font-size: 36px; margin-bottom: 10px; }
.drop-text { font-size: 13.5px; color: var(--text2); }
.link { color: var(--primary); text-decoration: underline; cursor: pointer; }

/* ── Tables ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.data-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table th {
  background: var(--bg3); color: var(--text3);
  padding: 11px 14px; text-align: left;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.empty-row { color: var(--text3); text-align: center; padding: 32px !important; }

/* ── Status Badges ───────────────────────────────────── */
.pill {
  display: inline-block; padding: 3px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.pill-valid   { background: rgba(16,185,129,0.15); color: var(--success); }
.pill-invalid { background: rgba(239,68,68,0.15);  color: var(--danger); }
.pill-high    { background: rgba(16,185,129,0.15); color: var(--success); }
.pill-medium  { background: rgba(245,158,11,0.15); color: var(--warning); }
.pill-low     { background: rgba(239,68,68,0.15);  color: var(--danger); }

/* ── Tabs ────────────────────────────────────────────── */
.tab-bar { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.tab {
  padding: 8px 16px; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: none; border: none; cursor: pointer;
  color: var(--text3); font-size: 13px; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Code block ──────────────────────────────────────── */
.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: var(--mono);
  font-size: 12px;
  color: #7dd3fc;
  overflow: auto;
  max-height: 400px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Result header ───────────────────────────────────── */
.result-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.result-badges { display: flex; gap: 8px; }

/* ── Section header ──────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; margin-top: 8px;
}
.section-header h2 { font-size: 16px; font-weight: 700; }

/* ── Mapper info cards ───────────────────────────────── */
.mapper-info { display: flex; flex-direction: column; gap: 10px; justify-content: center; }
.info-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13px;
}
.info-card.warning { border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.05); }
.info-card.danger  { border-color: rgba(239,68,68,0.3);  background: rgba(239,68,68,0.05); }
.info-icon { font-size: 18px; }

/* ── Layers row ──────────────────────────────────────── */
.layers-row {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; margin-bottom: 20px;
}
.layer-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; text-align: center;
}
.layer-icon { font-size: 32px; margin-bottom: 8px; }
.layer-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.layer-status { font-size: 12px; font-weight: 700; }
.layer-status.pass { color: var(--success); }
.layer-status.fail { color: var(--danger); }

/* ── Error list ──────────────────────────────────────── */
.error-item {
  background: var(--bg3); border-left: 3px solid var(--danger);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 16px; margin-bottom: 10px;
}
.error-item .error-code { font-family: var(--mono); font-size: 11px; color: var(--danger); font-weight: 600; }
.error-item .error-msg  { font-size: 13px; margin-top: 4px; }
.error-item .error-bt   { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .two-col { grid-template-columns: 1fr; }
  .layers-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
}
