/* ============================================================
   CompanyDetailPage – Tabbed Layout
   ============================================================ */

.backLink {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  transition: color 0.15s;
}

.backLink:hover {
  color: var(--color-primary);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.headerLeft {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.name {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  color: var(--color-text);
}

.industryBadge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: white;
}

/* ============================================================
   Tab Bar
   ============================================================ */

.tabBar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.tab:hover {
  color: var(--color-text);
}

.tabActive {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.tabContent {
  min-height: 200px;
}

/* ============================================================
   Tab 1: Unternehmensdaten – 2-Spalten Grid
   ============================================================ */

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

@media (max-width: 900px) {
  .overviewGrid {
    grid-template-columns: 1fr;
  }
}

.rightStack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

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

.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  padding: 1.5rem;
}

.cardTitle {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
  color: var(--color-text);
}

.cardTitleRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.cardTitleRow h2 {
  margin: 0;
}

/* ============================================================
   Info Grid (Stammdaten)
   ============================================================ */

.infoGrid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.5rem 0.75rem;
  font-size: 0.8125rem;
}

.infoLabel {
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 0.8125rem;
}

.infoValue {
  color: var(--color-text);
  word-break: break-word;
  font-size: 0.8125rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.tag {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  font-size: 0.6875rem;
  color: var(--color-text-secondary);
}

.notesSection {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.notesText {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  white-space: pre-wrap;
  line-height: 1.5;
  margin: 0;
}

/* ============================================================
   Lexware Verknuepfungs-Info (in Stammdaten-Card)
   ============================================================ */

.lexwareInfo {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.lexwareStatusRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.lexwareBadge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.lexwareBadgeLinked {
  background: #d1fae5;
  color: #065f46;
}

.lexwareBadgeNotLinked {
  background: var(--color-bg);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

:global([data-theme='dark']) .lexwareBadgeLinked {
  background: #064e3b;
  color: #6ee7b7;
}

.lexwareActions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.lexwareActionBtn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lexwareActionBtn:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.lexwareActionBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.lexwareActionBtnPrimary {
  composes: lexwareActionBtn;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.lexwareActionBtnPrimary:hover {
  background: var(--color-primary);
  color: white;
}

.lexwareActionBtnDanger {
  composes: lexwareActionBtn;
  border-color: #fecaca;
  color: var(--color-error);
}

.lexwareActionBtnDanger:hover {
  background: #fef2f2;
  color: #dc2626;
}

:global([data-theme='dark']) .lexwareActionBtnDanger:hover {
  background: #450a0a;
  color: #fca5a5;
}

/* ============================================================
   Compact Table (Kontakte in Stammdaten-Tab)
   ============================================================ */

.compactTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.compactTable th {
  text-align: left;
  padding: 0.375rem 0;
  font-size: 0.6875rem;
  text-transform: uppercase;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  font-weight: 500;
}

.compactTable td {
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--color-border);
}

.compactTable tr:last-child td {
  border-bottom: none;
}

.compactTable tr[data-clickable='true'] {
  cursor: pointer;
}

.compactTable tr[data-clickable='true']:hover td {
  background: var(--color-bg);
}

/* ============================================================
   Tab 3: Vorgaenge — Kombinierte Deals + Vouchers Tabelle
   ============================================================ */

.vorgaengeHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filterRow {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.filterSelect {
  padding: 0.375rem 0.625rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  background: var(--color-bg-card);
  color: var(--color-text);
  outline: none;
  cursor: pointer;
}

.filterSelect:focus {
  border-color: var(--color-primary);
}

.refreshBtn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.refreshBtn:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.refreshBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.vorgaengeTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.vorgaengeTable th {
  text-align: left;
  padding: 0.625rem 0.75rem;
  font-size: 0.6875rem;
  text-transform: uppercase;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  font-weight: 500;
  background: var(--color-bg);
}

.vorgaengeTable td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

.vorgaengeTable tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}

.vorgaengeTable tbody tr:hover {
  background: var(--color-bg);
}

.vorgaengeTableCard {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

/* Lexware-Zeilen farblich hervorheben */
.lexwareRow {
  background: rgba(99, 102, 241, 0.03);
  border-left: 3px solid rgba(99, 102, 241, 0.4);
}

.lexwareRow:hover {
  background: rgba(99, 102, 241, 0.07) !important;
}

:global([data-theme='dark']) .lexwareRow {
  background: rgba(99, 102, 241, 0.06);
  border-left-color: rgba(129, 140, 248, 0.4);
}

:global([data-theme='dark']) .lexwareRow:hover {
  background: rgba(99, 102, 241, 0.12) !important;
}

/* Quell-Badges */
.sourceBadge {
  display: inline-block;
  padding: 0.0625rem 0.375rem;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.sourceBadgeCrm {
  background: var(--color-bg);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.sourceBadgeLexware {
  background: #e0e7ff;
  color: #4338ca;
}

:global([data-theme='dark']) .sourceBadgeLexware {
  background: #312e81;
  color: #a5b4fc;
}

/* Leerer Zustand in Tabelle */
.emptyRow {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-style: italic;
}

/* ============================================================
   Activity Feed — von ActivityFeed.tsx genutzt
   ============================================================ */

.feedContainer {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.feedInputArea {
  margin-bottom: 1rem;
}

.feedTabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.75rem;
}

.feedTab {
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.feedTab:hover {
  color: var(--color-text);
}

.feedTabActive {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.feedForm {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.feedSubjectInput {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  outline: none;
  background: var(--color-bg-card);
  color: var(--color-text);
}

.feedSubjectInput:focus {
  border-color: var(--color-primary);
}

.feedTextarea {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  outline: none;
  resize: vertical;
  min-height: 60px;
  background: var(--color-bg-card);
  color: var(--color-text);
}

.feedTextarea:focus {
  border-color: var(--color-primary);
}

.feedSubmitRow {
  display: flex;
  justify-content: flex-end;
}

.feedSubmitBtn {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.15s;
}

.feedSubmitBtn:hover {
  opacity: 0.9;
}

.feedSubmitBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.feedList {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 600px;
  overflow-y: auto;
}

.feedItem {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}

.feedItem:last-child {
  border-bottom: none;
}

.feedIcon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
}

.feedContent {
  flex: 1;
  min-width: 0;
}

.feedSubject {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
}

.feedMeta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.125rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.feedViaBadge {
  display: inline-block;
  padding: 0 0.375rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  background: #e0e7ff;
  color: #3730a3;
  font-weight: 500;
}

:global([data-theme='dark']) .feedViaBadge {
  background: #312e81;
  color: #c7d2fe;
}

.feedDesc {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  margin-top: 0.375rem;
  white-space: pre-wrap;
}

.feedEmpty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* ============================================================
   Relationships Card
   ============================================================ */

.relationItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border);
}

.relationItem:last-child {
  border-bottom: none;
}

.relationInfo {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.relationName {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-primary);
  cursor: pointer;
}

.relationName:hover {
  text-decoration: underline;
}

.relationTypeBadge {
  display: inline-block;
  padding: 0 0.375rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

.relationDeleteBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.relationDeleteBtn:hover {
  background: #fef2f2;
  color: #dc2626;
}

:global([data-theme='dark']) .relationDeleteBtn:hover {
  background: #450a0a;
  color: #fca5a5;
}

/* ============================================================
   Placeholder Card
   ============================================================ */

.placeholderCard {
  opacity: 0.6;
  text-align: center;
  padding: 1.5rem;
}

.placeholderCard p {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  margin: 0;
}

/* ============================================================
   Small Add Button in Cards
   ============================================================ */

.smallAddBtn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-primary);
  background: transparent;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.smallAddBtn:hover {
  background: var(--color-primary);
  color: white;
}
