/* CRM Settings Page */

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

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

.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;
  margin-bottom: 1.5rem;
}

.cardTitle {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
}

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

/* Module list */
.moduleList {
  display: flex;
  flex-direction: column;
  gap: 0;
}

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

.moduleItem:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.moduleItem:first-child {
  padding-top: 0;
}

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

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

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

/* Toggle switch */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggleTrack {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle input:checked + .toggleTrack {
  background: var(--color-primary);
}

.toggleTrack::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle input:checked + .toggleTrack::after {
  transform: translateX(20px);
}

.toggle input:focus-visible + .toggleTrack {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Warning */
.warning {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem;
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: #92400e;
  margin-top: 1.25rem;
}

/* Dark mode override for warning */
:global([data-theme='dark']) .warning {
  background: #422006;
  border-color: #854d0e;
  color: #fde68a;
}

/* ============================================================ */
/*  Config Lists (Industries, AccountTypes, RelationshipTypes)   */
/* ============================================================ */

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

.configHeader h2 {
  margin: 0;
}

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

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

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

.configTable th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.configTable td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

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

.colorDot {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  vertical-align: middle;
}

.actionsCell {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  justify-content: flex-end;
}

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

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

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

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

/* Inline edit row */
.inlineForm {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.inlineInput {
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.15s;
}

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

.inlineInput::placeholder {
  color: var(--color-text-muted);
}

.colorInput {
  width: 32px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
}

.colorInput::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.colorInput::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}

.saveBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: white;
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.15s;
}

.saveBtn:hover {
  opacity: 0.9;
}

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

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

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

.emptyRow {
  color: var(--color-text-muted);
  font-style: italic;
  text-align: center;
}

.sortBtns {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sortBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 14px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 0.5rem;
  line-height: 1;
}

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

.sortBtn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

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

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

.settingsTab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

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

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

/* Disabled hint (e.g. Lexware module not active) */
.disabledHint {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  color: var(--color-text-muted);
}

.disabledHint svg {
  flex-shrink: 0;
  margin-top: 0.125rem;
}
