/* ============================================================
   KSeF Viewer — Styles
   ============================================================ */

:root {
  --bg: #f0f4f8;
  --card: #ffffff;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --accent: #7c3aed;
  --row-hover: #f8fafc;
  --header-bg: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

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

/* Header */
.header {
  background: var(--header-bg);
  color: white;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-logo svg { flex-shrink: 0; }
.header-title { font-size: 20px; font-weight: 700; }
.header-sub { font-size: 12px; opacity: .75; margin-top: 1px; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.header-right a { color: rgba(255,255,255,.85); font-size: 13px; }
.header-right a:hover { color: white; text-decoration: none; }
.sync-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.15); padding: 4px 12px; border-radius: 20px;
  font-size: 12px;
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; }
.sync-dot.error { background: #f87171; }
.sync-dot.running { background: #fbbf24; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.4; } }

/* Container */
.container { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border-radius: 12px;
  padding: 18px 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat-value.primary { color: var(--primary); }
.stat-value.success { color: var(--success); }
.stat-value.accent { color: var(--accent); }
.stat-value.danger { color: var(--danger); }
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar input, .toolbar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--card);
  outline: none;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.toolbar-search { min-width: 250px; }
.toolbar-right { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: none; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--row-hover); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Table */
.table-card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  overflow: hidden;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead { background: #f8fafc; }
th {
  padding: 12px 14px; text-align: left; font-weight: 600;
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
th a { color: var(--text-muted); text-decoration: none; display: flex; align-items: center; gap: 4px; }
th a:hover { color: var(--primary); }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
tr:hover td { background: var(--row-hover); }
tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: 'SF Mono', Consolas, monospace; font-size: 12px; }

/* Badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; letter-spacing: .3px;
}
.badge-vat { background: #dbeafe; color: #1e40af; }
.badge-kor { background: #fef3c7; color: #92400e; }
.badge-zal { background: #d1fae5; color: #065f46; }
.badge-other { background: #f1f5f9; color: #475569; }

/* Action buttons in table */
.action-btn {
  background: none; border: none; color: var(--primary);
  cursor: pointer; padding: 4px 8px; border-radius: 4px; font-size: 12px;
  white-space: nowrap;
}
.action-btn:hover { background: var(--primary-light); }

/* Pagination */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; padding: 16px; border-top: 1px solid var(--border);
}
.pagination a, .pagination span {
  padding: 6px 12px; border-radius: 6px; font-size: 13px; min-width: 36px;
  text-align: center; display: inline-block;
}
.pagination a { color: var(--text); text-decoration: none; }
.pagination a:hover { background: var(--primary-light); color: var(--primary); }
.pagination .current { background: var(--primary); color: white; font-weight: 600; }
.pagination .disabled { color: var(--border); cursor: default; }

/* Invoice detail */
.detail-card {
  background: var(--card);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  margin-bottom: 20px;
}
.detail-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.detail-title { font-size: 20px; font-weight: 700; }
.detail-section { margin-bottom: 24px; }
.detail-section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-muted);
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px 28px;
}
.detail-field .lbl { font-size: 12px; color: var(--text-muted); }
.detail-field .val { font-size: 14px; font-weight: 500; margin-top: 1px; }

.items-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.items-table th {
  padding: 8px 10px; text-align: left; font-size: 11px;
  background: #f8fafc; border: 1px solid var(--border); text-transform: uppercase;
}
.items-table td { padding: 8px 10px; border: 1px solid var(--border); font-size: 13px; }

/* Alerts */
.alert {
  padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px;
}
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* Logs */
.log-entry { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.log-entry:last-child { border: none; }
.log-level { font-weight: 600; font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.log-level.INFO { background: #dbeafe; color: #1e40af; }
.log-level.WARNING { background: #fef3c7; color: #92400e; }
.log-level.ERROR { background: #fecaca; color: #991b1b; }
.log-time { color: var(--text-muted); font-size: 12px; font-family: monospace; }

/* Empty state */
.empty-state {
  text-align: center; padding: 60px 24px; color: var(--text-muted);
}
.empty-state h3 { color: var(--text); margin: 12px 0 4px; }

/* Responsive */
@media (max-width: 768px) {
  .container { padding: 16px; }
  .header { padding: 12px 16px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-search { min-width: 100%; }
  .toolbar-right { margin-left: 0; }
  .detail-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
}
