/* ============================================================
   Design System – Lexoffice Artikel-Dashboard
   ============================================================ */

:root {
  /* Colors */
  --bg-primary: #0f1117;
  --bg-secondary: #161822;
  --bg-card: #1c1f2e;
  --bg-card-hover: #232639;
  --bg-input: #1a1d2e;

  --border: #2a2d3e;
  --border-focus: #6366f1;

  --text-primary: #f1f3f9;
  --text-secondary: #8b8fa7;
  --text-muted: #5c6078;

  --accent-primary: #6366f1;
  --accent-primary-hover: #818cf8;
  --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);

  --stat-quantity-bg: rgba(59, 130, 246, 0.08);
  --stat-quantity-border: rgba(59, 130, 246, 0.2);
  --stat-quantity-color: #60a5fa;

  --stat-revenue-bg: rgba(16, 185, 129, 0.08);
  --stat-revenue-border: rgba(16, 185, 129, 0.2);
  --stat-revenue-color: #34d399;

  --stat-invoices-bg: rgba(244, 114, 182, 0.08);
  --stat-invoices-border: rgba(244, 114, 182, 0.2);
  --stat-invoices-color: #f472b6;

  --success: #34d399;
  --warning: #fbbf24;
  --error: #f87171;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  /* Spacing */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  /* Transitions */
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   Reset & Base
   ============================================================ */

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

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================================
   Header
   ============================================================ */

.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(22, 24, 34, 0.85);
}

.header-content {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.logo {
  flex-shrink: 0;
}

.header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

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

.btn-sync:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
}

.btn-sync.syncing {
  pointer-events: none;
  opacity: 0.7;
}

.btn-sync.syncing .spin-icon {
  animation: spin 1.5s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.btn-icon {
  flex-shrink: 0;
}

/* ============================================================
   Sync Overlay
   ============================================================ */

.sync-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 17, 23, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.sync-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 90%;
  max-width: 520px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.sync-card h3 {
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
  font-weight: 600;
}

.progress-bar-container {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-bar {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 3px;
  width: 0%;
  transition: width 0.5s ease;
}

.sync-log {
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sync-log-entry {
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(42, 45, 62, 0.5);
}

.sync-log-entry.error {
  color: var(--error);
}

.sync-log-entry.success {
  color: var(--success);
}

.sync-log-entry.warning {
  color: var(--warning);
}

/* ============================================================
   Main
   ============================================================ */

.main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 1.5rem 2rem 3rem;
}

/* ============================================================
   Filter Section
   ============================================================ */

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

.filter-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
}

.filter-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 1rem;
  align-items: start;
}

.filter-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.filter-group input[type="text"],
.filter-group input[type="date"] {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  transition: border-color var(--transition);
  outline: none;
}

.filter-group input[type="text"]:focus,
.filter-group input[type="date"]:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.filter-group-wide {
  grid-column: 1 / 2;
}

.filter-action {
  padding-top: 1.35rem;
}

/* Multi-Select Container */
.multi-select-container {
  position: relative;
}

.article-search-input {
  width: 100%;
}

.article-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-xs) var(--radius-xs);
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.875rem;
  cursor: pointer;
  transition: background var(--transition);
}

.dropdown-item:hover {
  background: var(--bg-card-hover);
}

.dropdown-item-number {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent-primary-hover);
  min-width: 60px;
}

.dropdown-item-title {
  font-size: 0.8rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-empty {
  padding: 0.75rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Selected Article Tags */
.selected-articles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.article-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 100px;
  padding: 0.2rem 0.25rem 0.2rem 0.625rem;
  font-size: 0.75rem;
  color: var(--accent-primary-hover);
  animation: fadeIn 0.2s ease;
}

.tag-number {
  font-weight: 700;
}

.tag-title {
  color: var(--text-secondary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-primary-hover);
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  transition: all var(--transition);
}

.tag-remove:hover {
  background: rgba(248, 113, 113, 0.3);
  color: var(--error);
}

/* Article badge in table */
.article-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-primary-hover);
}

/* ============================================================
   Stats Cards
   ============================================================ */

.stats-section {
  margin-bottom: 1.5rem;
  animation: slideUp 0.4s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-quantity {
  border-color: var(--stat-quantity-border);
}

.stat-quantity .stat-icon {
  background: var(--stat-quantity-bg);
  color: var(--stat-quantity-color);
}

.stat-quantity .stat-value {
  color: var(--stat-quantity-color);
}

.stat-revenue {
  border-color: var(--stat-revenue-border);
}

.stat-revenue .stat-icon {
  background: var(--stat-revenue-bg);
  color: var(--stat-revenue-color);
}

.stat-revenue .stat-value {
  color: var(--stat-revenue-color);
}

.stat-invoices {
  border-color: var(--stat-invoices-border);
}

.stat-invoices .stat-icon {
  background: var(--stat-invoices-bg);
  color: var(--stat-invoices-color);
}

.stat-invoices .stat-value {
  color: var(--stat-invoices-color);
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ============================================================
   Table
   ============================================================ */

.table-section {
  animation: slideUp 0.5s ease;
}

.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.table-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.table-badge {
  background: var(--bg-input);
  color: var(--text-secondary);
  padding: 0.25rem 0.75rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  background: var(--bg-secondary);
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th.num,
td.num {
  text-align: right;
}

tbody tr {
  border-bottom: 1px solid rgba(42, 45, 62, 0.5);
  transition: background var(--transition);
}

tbody tr:hover {
  background: var(--bg-card-hover);
}

tbody td {
  padding: 0.75rem 1rem;
  white-space: nowrap;
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-paid,
.status-paidoff {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.status-open {
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
}

.status-draft {
  background: rgba(139, 143, 167, 0.1);
  color: var(--text-secondary);
}

.status-overdue {
  background: rgba(248, 113, 113, 0.1);
  color: var(--error);
}

.status-voided {
  background: rgba(139, 143, 167, 0.1);
  color: var(--text-muted);
}

/* ============================================================
   Empty State
   ============================================================ */

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-icon {
  color: var(--text-muted);
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 400px;
  margin: 0 auto;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
  .header {
    padding: 1rem;
  }

  .main {
    padding: 1rem;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .header-content {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 14px;
  }
}

/* ============================================================
   Scrollbar
   ============================================================ */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}