/* ===========================================
   Buchhaltung - Glasmorphism Styling
   JAVY 5 Design System
   =========================================== */

/* --- App Shell --- */

.bh-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.bh-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--glass-bg);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  flex-shrink: 0;
}

.bh-title {
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

/* --- Tab Navigation --- */

.bh-tabs {
  display: flex;
  gap: var(--space-xs);
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-lg);
  padding: 3px;
}

.bh-tab {
  padding: var(--space-sm) var(--space-lg);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--font-sm);
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}

.bh-tab:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.06);
}

.bh-tab.active {
  color: var(--text-primary);
  background: var(--gradient-primary);
  box-shadow: var(--shadow-sm);
}

/* --- Content Area --- */

.bh-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
}

/* --- Toolbar --- */

.bh-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.bh-filter-bar {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  flex-wrap: wrap;
  flex: 1;
}

.bh-filter-input {
  padding: var(--space-sm) var(--space-md);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-sm);
  min-width: 100px;
}

.bh-filter-input:focus {
  outline: none;
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 2px var(--accent-purple-muted);
}

/* --- Buttons --- */

.bh-btn {
  padding: var(--space-sm) var(--space-lg);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.bh-btn-primary {
  background: var(--gradient-primary);
  color: var(--text-primary);
}

.bh-btn-primary:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.bh-btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
}

.bh-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--glass-border-hover);
}

.bh-btn-small {
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-xs);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}

.bh-btn-small:hover {
  background: rgba(255, 255, 255, 0.12);
}

.bh-btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-xs);
  font-size: var(--font-md);
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.bh-btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
}

.bh-btn-icon:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* --- Tables --- */

.bh-table-wrap {
  overflow-x: auto;
}

.bh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-sm);
}

.bh-table thead th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--font-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
}

.bh-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: var(--transition-fast);
}

.bh-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.bh-table td {
  padding: var(--space-sm) var(--space-md);
  color: var(--text-secondary);
  vertical-align: middle;
}

.bh-col-nr { width: 80px; }
.bh-col-type { width: 100px; }
.bh-col-saldo { width: 120px; text-align: right; font-variant-numeric: tabular-nums; }
.bh-col-actions { width: 80px; text-align: center; }
.bh-col-date { width: 100px; }
.bh-col-ref { width: 110px; }
.bh-col-amount { width: 120px; text-align: right; font-variant-numeric: tabular-nums; }

.bh-negative {
  color: var(--color-error) !important;
}

/* --- Group Headers --- */

.bh-group {
  margin-bottom: var(--space-xl);
}

.bh-group-header {
  font-size: var(--font-md);
  font-weight: 700;
  color: var(--accent-purple);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-sm);
  border-left: 3px solid var(--accent-purple);
  background: var(--accent-purple-muted);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* --- Badges --- */

.bh-badge {
  display: inline-block;
  padding: 2px var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--font-xs);
  font-weight: 600;
}

.bh-badge-asset { background: var(--accent-cyan-muted); color: var(--accent-cyan); }
.bh-badge-liability { background: var(--accent-pink-muted); color: var(--accent-pink); }
.bh-badge-equity { background: var(--accent-purple-muted); color: var(--accent-purple); }
.bh-badge-income { background: var(--color-success-bg); color: var(--color-success); }
.bh-badge-expense { background: var(--color-error-bg); color: var(--color-error); }
.bh-badge-storno {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  font-size: 10px;
}

/* --- Storno Row --- */

.bh-storno td {
  opacity: 0.6;
  text-decoration: line-through;
}

.bh-storno .bh-col-actions {
  text-decoration: none;
  opacity: 1;
}

.bh-storno .bh-badge-storno {
  text-decoration: none;
}

/* --- Soll/Haben Labels --- */

.bh-soll-label {
  color: var(--accent-cyan);
  font-weight: 600;
  font-size: var(--font-xs);
}

.bh-haben-label {
  color: var(--accent-pink);
  font-weight: 600;
  font-size: var(--font-xs);
}

/* --- Empty State --- */

.bh-empty {
  text-align: center;
  padding: var(--space-3xl);
  color: var(--text-muted);
  font-size: var(--font-md);
}

/* --- Forms --- */

.bh-form {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  backdrop-filter: var(--glass-blur);
}

.bh-form-title {
  font-size: var(--font-md);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 var(--space-lg) 0;
}

.bh-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.bh-form-field-wide {
  grid-column: 1 / -1;
}

.bh-form-field label {
  display: block;
  font-size: var(--font-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.bh-form-field input,
.bh-form-field select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-sm);
  box-sizing: border-box;
}

.bh-form-field input:focus,
.bh-form-field select:focus {
  outline: none;
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 2px var(--accent-purple-muted);
}

.bh-form-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

/* --- Buchungszeilen --- */

.bh-lines-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.bh-lines-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.bh-line {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.5fr auto;
  gap: var(--space-sm);
  align-items: center;
}

.bh-line select,
.bh-line input {
  padding: var(--space-sm) var(--space-md);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-sm);
  box-sizing: border-box;
}

.bh-line select:focus,
.bh-line input:focus {
  outline: none;
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 2px var(--accent-purple-muted);
}

.bh-btn-remove-line {
  background: none;
  border: none;
  color: var(--color-error);
  cursor: pointer;
  padding: var(--space-xs);
  font-size: var(--font-md);
  border-radius: var(--radius-sm);
}

.bh-btn-remove-line:hover {
  background: var(--color-error-bg);
}

/* --- Differenz-Anzeige --- */

.bh-diff-display {
  margin-bottom: var(--space-lg);
}

.bh-diff-row {
  display: flex;
  gap: var(--space-xl);
  padding: var(--space-sm) var(--space-md);
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  color: var(--text-secondary);
}

.bh-diff-row strong {
  color: var(--text-primary);
}

.bh-balanced {
  color: var(--color-success);
  font-weight: 600;
}

.bh-unbalanced {
  color: var(--color-error);
  font-weight: 600;
}

/* --- Responsive --- */

@media (max-width: 600px) {
  .bh-header {
    flex-direction: column;
    gap: var(--space-sm);
  }

  .bh-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .bh-filter-bar {
    flex-direction: column;
  }

  .bh-line {
    grid-template-columns: 1fr;
  }

  .bh-form-grid {
    grid-template-columns: 1fr;
  }
}
