/**
 * TASKMATE - Kontakte Styles
 * ==========================
 * Styles für das Kontaktmanagement-Modul
 */

/* =============================================================================
   LAYOUT
   ============================================================================= */

.contacts-layout {
  display: flex;
  height: 100%;
  gap: var(--spacing-4);
}

/* =============================================================================
   HEADER FILTER BUTTONS
   ============================================================================= */

.header-center {
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: center;
}

.filter-buttons {
  display: flex;
  gap: var(--spacing-2);
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: var(--radius-lg);
}

.filter-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  padding: var(--spacing-2) var(--spacing-3);
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.filter-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.filter-btn.active {
  background: var(--bg-primary);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
}

.filter-btn.active .filter-badge {
  background: var(--primary);
  color: white;
}


/* =============================================================================
   MAIN CONTENT
   ============================================================================= */

.contacts-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-default);
  overflow: hidden;
}

.contacts-main.full-width {
  width: 100%;
}

.contacts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-5);
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-secondary);
  gap: var(--spacing-4);
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: var(--spacing-3);
}

.contacts-header h2 {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
}

.contact-count {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  gap: var(--spacing-3);
}

/* =============================================================================
   CONTACT LIST
   ============================================================================= */

.contacts-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-5);
}

.contacts-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-6);
}

.contact-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-3);
}

.group-letter {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  margin: 0;
  padding: 0 var(--spacing-2);
  text-transform: uppercase;
}

.contact-cards {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
}

/* =============================================================================
   CONTACT CARD
   ============================================================================= */

.contact-card {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-4);
  padding: var(--spacing-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.contact-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.contact-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-semibold);
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}

.contact-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.contact-avatar svg {
  stroke: white;
}

.contact-info {
  flex: 1;
  min-width: 0;
}

.contact-name {
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin: 0 0 var(--spacing-1) 0;
}

.contact-position,
.contact-industry {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: 0 0 var(--spacing-2) 0;
}

.contact-details {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-3);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.detail-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-1);
}

.detail-item .icon {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}

.contact-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-1);
  margin-top: var(--spacing-2);
}

.contact-tags .tag {
  font-size: var(--text-xs);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: var(--font-medium);
}

.contact-type {
  position: absolute;
  top: var(--spacing-4);
  right: var(--spacing-4);
}

.type-badge {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
}

.type-badge.type-person {
  background: #1a1a1a15;
  color: #1a1a1a;
}

.type-badge.type-company {
  background: #6b728015;
  color: #6b7280;
}

/* =============================================================================
   EMPTY STATE
   ============================================================================= */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--spacing-8);
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  opacity: 0.2;
  margin-bottom: var(--spacing-4);
}

.empty-state h3 {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0 0 var(--spacing-2) 0;
}

.empty-state p {
  margin: 0;
  color: var(--text-secondary);
}

/* =============================================================================
   DETAIL VIEW
   ============================================================================= */

.contact-detail {
  padding: var(--spacing-6);
  max-width: 800px;
  margin: 0 auto;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-5);
  margin-bottom: var(--spacing-6);
  padding-bottom: var(--spacing-6);
  border-bottom: 1px solid var(--border-default);
}

.detail-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: white;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.detail-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-upload {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-fast);
  cursor: pointer;
}

.detail-avatar:hover .avatar-upload {
  opacity: 1;
}

.avatar-upload .icon {
  color: white;
}

.detail-info {
  flex: 1;
}

.detail-name {
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0 0 var(--spacing-2) 0;
}

.detail-subtitle {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin: 0 0 var(--spacing-4) 0;
}

.detail-actions {
  display: flex;
  gap: var(--spacing-2);
  flex-wrap: wrap;
}

/* Detail Sections */
.detail-section {
  margin-bottom: var(--spacing-6);
}

.section-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 var(--spacing-3) 0;
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
}

.section-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--spacing-4);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-4);
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-1);
}

.info-label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-tertiary);
  text-transform: uppercase;
}

.info-value {
  font-size: var(--text-sm);
  color: var(--text-primary);
}

/* Contact Details List */
.details-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-3);
}

.detail-entry {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
}

.detail-entry .icon {
  width: 20px;
  height: 20px;
  color: var(--text-tertiary);
}

.detail-content {
  flex: 1;
}

.detail-value {
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.detail-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

/* Interactions */
.interactions-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
}

.interaction-item {
  padding: var(--spacing-3);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  display: flex;
  gap: var(--spacing-3);
  align-items: flex-start;
}

.interaction-icon {
  width: 32px;
  height: 32px;
  background: var(--bg-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.interaction-content {
  flex: 1;
}

.interaction-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--spacing-1);
}

.interaction-title {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

.interaction-time {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.interaction-body {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* =============================================================================
   FORM
   ============================================================================= */

.modal .contact-form-container {
  background: var(--bg-primary);
  max-width: 900px;
  width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.contact-form-container {
  background: var(--bg-primary);
  max-width: 800px;
  margin: 0 auto;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.contact-form {
  padding: var(--spacing-6);
  overflow-y: auto;
  max-height: calc(90vh - 150px);
}

.form-header {
  margin-bottom: var(--spacing-6);
  text-align: center;
}

.form-title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
}

.form-section {
  margin-bottom: var(--spacing-6);
}

.form-section-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 var(--spacing-4) 0;
}

/* Contact Type Toggle */
.contact-type-toggle {
  display: flex;
  gap: var(--spacing-2);
  margin-bottom: var(--spacing-6);
  background: var(--bg-secondary);
  padding: var(--spacing-1);
  border-radius: var(--radius-lg);
}

.type-option {
  flex: 1;
  padding: var(--spacing-3);
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.type-option.active {
  background: var(--bg-primary);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Form Fields */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-4);
  margin-bottom: var(--spacing-4);
}

.form-group.full-width {
  grid-column: 1 / -1;
}

/* Contact Details Fields */
.contact-details-fields {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-3);
}

.detail-field-group {
  display: flex;
  gap: var(--spacing-2);
  align-items: flex-end;
}

.detail-field-group .form-group {
  flex: 1;
  margin-bottom: 0;
}

.detail-field-group .form-group:first-child {
  flex: 0 0 120px;
}

.btn-remove-detail {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  color: var(--danger);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-remove-detail:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-add-detail {
  align-self: flex-start;
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 1024px) {
  .contacts-header {
    flex-wrap: wrap;
  }
  
  .header-center {
    order: 3;
    width: 100%;
    margin-top: var(--spacing-3);
  }
  
  .filter-buttons {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .contacts-header {
    flex-direction: column;
    gap: var(--spacing-3);
    align-items: stretch;
  }

  .header-left {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-1);
  }

  .header-actions {
    width: 100%;
  }

  .header-actions .btn {
    flex: 1;
    justify-content: center;
  }

  .detail-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .detail-actions {
    justify-content: center;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
  
  .detail-field-group {
    flex-wrap: wrap;
  }
  
  .detail-field-group .form-group:first-child {
    flex: 1 1 100%;
  }
}

/* =============================================================================
   ADDITIONAL STYLES
   ============================================================================= */

/* Detail View Styles */
.btn-back {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  padding: var(--spacing-2);
  margin-left: calc(var(--spacing-2) * -1);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.btn-back:hover {
  background: var(--bg-secondary);
  color: var(--primary);
}

.detail-content {
  display: flex;
  gap: var(--spacing-6);
  margin-top: var(--spacing-6);
}

.detail-main {
  flex: 1;
  min-width: 0;
}

.detail-sidebar {
  width: 300px;
  flex-shrink: 0;
}

.contact-header-detail {
  display: flex;
  align-items: center;
  gap: var(--spacing-5);
  margin-bottom: var(--spacing-6);
  padding-bottom: var(--spacing-6);
  border-bottom: 1px solid var(--border-default);
}

.avatar-large {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.contact-title h1 {
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  margin: 0 0 var(--spacing-2) 0;
  color: var(--text-primary);
}

.contact-title .subtitle {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin: 0;
}

/* Details Grid */
.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--spacing-4);
}

.detail-item {
  display: flex;
  gap: var(--spacing-3);
  align-items: flex-start;
}

.detail-icon {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.detail-content {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-1);
  flex: 1;
}

.detail-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-value {
  font-size: var(--text-sm);
  color: var(--text-primary);
}

/* Info List */
.info-list {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: var(--spacing-3) var(--spacing-4);
  margin: 0;
}

.info-list dt {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  font-weight: var(--font-medium);
}

.info-list dd {
  font-size: var(--text-sm);
  color: var(--text-primary);
  margin: 0;
}

.info-list dd a {
  color: var(--primary);
  text-decoration: none;
}

.info-list dd a:hover {
  text-decoration: underline;
}

/* Notes */
.notes-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--spacing-4);
  font-size: var(--text-sm);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Meta List */
.meta-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-3);
  margin: 0;
}

.meta-list dt {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: var(--font-medium);
  text-transform: uppercase;
  margin-bottom: var(--spacing-1);
}

.meta-list dd {
  font-size: var(--text-sm);
  color: var(--text-primary);
  margin: 0 0 var(--spacing-3) 0;
}

.meta-list dd:last-child {
  margin-bottom: 0;
}

/* Form Styles */
.form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-5);
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-secondary);
}

.form-header h2 {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--spacing-2);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.btn-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.radio-group {
  display: flex;
  gap: var(--spacing-4);
}

.radio-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  cursor: pointer;
}

.radio-item input[type="radio"] {
  margin: 0;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  cursor: pointer;
  padding: var(--spacing-2);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

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

.checkbox-item input[type="checkbox"] {
  margin: 0;
}

/* Detail Controls */
.detail-controls {
  display: flex;
  gap: var(--spacing-2);
  align-items: center;
  margin-bottom: var(--spacing-3);
}

.detail-controls .form-control {
  flex: 1;
}

.detail-type {
  flex: 0 0 120px;
}

.detail-label {
  flex: 0 0 120px;
}

.detail-value {
  flex: 2;
}

.checkbox-primary {
  display: flex;
  align-items: center;
  gap: var(--spacing-1);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--spacing-2);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger)10;
}

.btn-remove-detail {
  flex-shrink: 0;
}

.details-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
}

/* Interactions */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-3);
}

.interactions-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-3);
}

.interaction-item {
  display: flex;
  gap: var(--spacing-3);
  padding: var(--spacing-3);
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
}

.interaction-icon {
  width: 36px;
  height: 36px;
  background: var(--bg-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.interaction-content {
  flex: 1;
  min-width: 0;
}

.interaction-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--spacing-1);
}

.interaction-type {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
}

.interaction-date {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.interaction-content h4 {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin: var(--spacing-1) 0;
}

.interaction-content p {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: var(--spacing-1) 0;
  line-height: 1.5;
}

.interaction-author {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--spacing-2);
}

.text-muted {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  font-style: italic;
}

/* Tags List */
.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-2);
}

.sidebar-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--spacing-4);
  margin-bottom: var(--spacing-4);
}

.sidebar-section h4 {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0 0 var(--spacing-3) 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-3);
  padding: var(--spacing-4);
  border-top: 1px solid var(--border-default);
  background: var(--bg-secondary);
  margin: var(--spacing-6) calc(var(--spacing-6) * -1) calc(var(--spacing-6) * -1);
}

.required {
  color: var(--danger);
}