/* ============================================================
   dashboard.css – Startseite / Übersichts-Dashboard
   ============================================================ */

/* ---- Header ---- */
.db-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.db-welcome {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}
.db-welcome-sub {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ---- Globale Suche ---- */
.db-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 2rem;
  width: 100%;
}
.db-search-icon {
  position: absolute;
  left: 1.1rem;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  z-index: 1;
}
/* input.db-search-input erhöht Spezifizität auf 0-1-1, gleich mit input[type="text"] – später geladen, gewinnt */
input.db-search-input {
  width: 100%;
  padding: 0.85rem 1rem 0.85rem 3rem;
  font-size: 0.95rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  transition: var(--transition);
  outline: none;
}
input.db-search-input::placeholder { color: var(--text-muted); }
input.db-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ---- Sektions-Header ---- */
.db-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  gap: 1rem;
}
.db-section-title {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.db-section-title i, .db-section-title svg { width: 15px; height: 15px; }
.db-section-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  transition: var(--transition);
  white-space: nowrap;
}
.db-section-link:hover { opacity: 0.75; }

/* ---- Empty Pending State ---- */
.db-empty-pending {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}
.db-empty-pending svg { color: var(--success); flex-shrink: 0; }
.db-empty-pending div { display: flex; flex-direction: column; gap: 0.15rem; }
.db-empty-pending strong { color: var(--text-primary); font-size: 0.9rem; }
.db-empty-pending span   { font-size: 0.83rem; }

/* ---- Action Table ---- */
.db-action-table {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.db-action-header,
.db-action-row {
  display: grid;
  grid-template-columns: 150px 90px 1fr 1fr 100px 70px 28px;
  gap: 0.75rem;
  align-items: center;
  padding: 0.6rem 1rem;
}
.db-action-header {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}
.db-action-row {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.db-action-row:last-child { border-bottom: none; }
.db-action-row:hover { background: var(--bg-elevated); }

.db-action-num,
.db-action-proj,
.db-action-customer,
.db-action-total,
.db-action-age {
  font-size: 0.83rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.db-action-num      { color: var(--text-secondary); font-weight: 600; font-size: 0.78rem; }
.db-action-total    { font-weight: 700; color: var(--text-primary); }
.db-action-age      { color: var(--text-muted); font-size: 0.78rem; }
.db-action-arrow    { color: var(--text-muted); display: flex; align-items: center; justify-content: flex-end; }
.db-action-row:hover .db-action-arrow { color: var(--accent); }

.db-action-more {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.db-text-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: inherit;
  font-weight: 600;
  padding: 0;
}
.db-text-btn:hover { opacity: 0.75; }

/* ---- Materialbedarf ---- */
.db-demand-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.db-demand-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.db-demand-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.db-demand-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.db-demand-copy {
  margin: 0.6rem 0 0.75rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.45;
}

.db-demand-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.db-demand-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.42rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.015);
}

.db-demand-material {
  color: var(--text-primary);
  font-size: 0.83rem;
  line-height: 1.35;
}

.db-demand-qty {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}

.db-demand-empty {
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.65rem 0.3rem;
}

/* ---- KPI-Konfiguration ---- */
.db-analytics-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.db-kpi-config-btn {
  width: auto;
  white-space: nowrap;
}
.db-kpi-config-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
}
.db-kpi-config-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}
.db-kpi-config-card p {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 0.85rem;
}
.db-kpi-config-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.65rem;
}
.db-kpi-config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.db-kpi-config-row label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  cursor: pointer;
}
.db-kpi-config-row span {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.db-kpi-config-order {
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted) !important;
  font-family: var(--font-display);
  font-size: 0.72rem !important;
}
.db-kpi-config-row i,
.db-kpi-config-row svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
/* ---- KPI Grid ---- */
.db-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.db-kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: var(--transition);
}
.db-kpi-card:hover { border-color: var(--border-bright); }
.db-kpi-card-tools {
  display: flex;
  justify-content: flex-end;
  margin: -0.35rem 0 0.35rem;
}
#page-dashboard:not(.is-kpi-edit-mode) .db-kpi-card-tools {
  display: none;
}
.db-kpi-drag-handle {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  width: auto;
  padding: 0.26rem 0.55rem;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  cursor: grab;
  transition: var(--transition);
  font-size: 0.72rem;
}
.db-kpi-drag-handle:active {
  cursor: grabbing;
}
.db-kpi-drag-handle:hover {
  border-color: rgba(213, 229, 58, 0.45);
  color: var(--text-primary);
  background: rgba(213, 229, 58, 0.08);
}
.db-kpi-card.is-dragging {
  opacity: 0.62;
  transform: scale(0.99);
}
.db-kpi-card.is-drag-over {
  border-color: rgba(213, 229, 58, 0.5);
  box-shadow: 0 0 0 1px rgba(213, 229, 58, 0.25);
}
body.light-theme .db-kpi-drag-handle {
  border-color: #d1d7e1;
  background: #ffffff;
  color: #50607a;
}
body.light-theme .db-kpi-drag-handle:hover {
  border-color: rgba(133, 145, 0, 0.38);
  color: #2e3b55;
  background: rgba(133, 145, 0, 0.08);
}
.db-kpi-icon { margin-bottom: 0.4rem; }
.db-kpi-icon i, .db-kpi-icon svg { width: 20px; height: 20px; }
.db-kpi-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}
.db-kpi-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}
.db-kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ---- Recent Orders Table ---- */
.db-recent {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.db-recent-title {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.db-table-wrap { overflow-x: auto; }
.db-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.db-table thead th {
  padding: 0.6rem 1rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.db-table tbody tr { border-bottom: 1px solid var(--border); transition: var(--transition); }
.db-table tbody tr:last-child { border-bottom: none; }
.db-table tbody tr:hover { background: var(--bg-elevated); }
.db-table td {
  padding: 0.65rem 1rem;
  color: var(--text-primary);
  vertical-align: middle;
  white-space: nowrap;
}
.db-table-amount { font-weight: 700; }
.db-table-date   { color: var(--text-muted); font-size: 0.8rem; }
.db-table-empty  { text-align: center; color: var(--text-muted); padding: 2rem 1rem !important; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .db-action-header,
  .db-action-row {
    grid-template-columns: 130px 80px 1fr 90px 60px 24px;
  }
  .db-action-customer { display: none; }
  .db-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .db-demand-grid { grid-template-columns: 1fr; }
  .db-analytics-actions { justify-content: flex-start; }
}
@media (max-width: 600px) {
  .db-welcome { font-size: 1.25rem; }
  .db-action-header,
  .db-action-row { grid-template-columns: 110px 1fr 80px 24px; }
  .db-action-num, .db-action-age { display: none; }
  .db-kpi-grid { grid-template-columns: 1fr 1fr; }
  .db-demand-row { flex-direction: column; align-items: flex-start; }
  .db-demand-qty { white-space: normal; }
  .db-analytics-actions { align-items: stretch; flex-direction: column; }
  .db-kpi-config-btn { width: 100%; }
}
