/**
 * TASKMATE - Modernes Kontaktmanagement Styles
 * =============================================
 * Lead-Management inspiriertes Design
 */

/* Container */
.contacts-modern {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-secondary);
}

/* Header */
.contacts-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  padding: var(--spacing-4);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-4);
  flex-wrap: wrap;
}

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

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

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

/* Controls */
.contacts-controls {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  min-width: 300px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-card);
}

.filter-select {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  cursor: pointer;
}

/* List Container */
.contacts-list-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-4);
}

/* List Items */
.contacts-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.contact-list-item {
  background: var(--bg-card);
  padding: var(--spacing-3) var(--spacing-4);
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.contact-list-item:first-child {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.contact-list-item:last-child {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Avatar */
.contact-avatar {
  position: relative;
  flex-shrink: 0;
}

.contact-avatar img {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.avatar-initials {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-medium);
  font-size: var(--text-md);
}

.avatar-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
}

.status-inactive {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background: var(--danger);
  border: 2px solid var(--bg-card);
  border-radius: var(--radius-full);
}

/* Contact Info */
.contact-info {
  flex: 1;
  min-width: 0;
}

.contact-name {
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin-bottom: 2px;
}

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

/* Contact Meta */
.contact-meta {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-left: auto;
}

/* Contact Actions */
.contact-actions {
  display: flex;
  gap: var(--spacing-2);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.contact-list-item:hover .contact-actions {
  opacity: 1;
}

/* Detail View */
.contact-detail-view {
  background: var(--bg-secondary);
}

.detail-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  padding: var(--spacing-4);
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
}

.btn-back-to-list {
  background: none;
  border: none;
  padding: var(--spacing-2);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.detail-title {
  flex: 1;
}

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

.detail-title .subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

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

/* Detail Content */
.detail-content {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--spacing-4);
  padding: var(--spacing-4);
}

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

.detail-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--spacing-4);
}

.detail-section h3 {
  margin: 0 0 var(--spacing-3);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

/* Detail Items */
.detail-grid {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-3);
}

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

.detail-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  padding: 10px;
  color: var(--text-secondary);
}

.detail-content {
  flex: 1;
}

.detail-label {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

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

/* Sidebar */
.detail-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-4);
}

.sidebar-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--spacing-4);
}

.sidebar-section h4 {
  margin: 0 0 var(--spacing-3);
  font-size: var(--text-md);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.info-list {
  display: grid;
  gap: var(--spacing-2);
}

.info-list dt {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.info-list dd {
  margin: 0 0 var(--spacing-3);
  color: var(--text-primary);
}

.info-list.small dt,
.info-list.small dd {
  font-size: var(--text-xs);
}

/* Tags */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-1);
}

.tag {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

/* Forms */
.contact-type-selector {
  display: flex;
  gap: var(--spacing-3);
  margin-bottom: var(--spacing-4);
  padding: var(--spacing-3);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
}

.type-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-2);
  padding: var(--spacing-3);
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.type-option input {
  display: none;
}

.type-option.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.type-option svg {
  color: var(--text-secondary);
}

.type-option.active svg {
  color: var(--primary);
}

/* Modern Form */
.modern-contact-form {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-4);
}

.form-section {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-4);
}

.form-section h3 {
  margin: 0 0 var(--spacing-3);
  font-size: var(--text-md);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

/* Form Grid */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-3);
}

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

.form-field.small {
  max-width: 150px;
}

.form-field.large {
  grid-column: span 2;
}

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

.form-field label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

/* Form Controls - Einheitliche Größe */
.form-control {
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: inherit;
  transition: all var(--transition-fast);
  width: 100%;
  box-sizing: border-box;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.form-control::placeholder {
  color: var(--text-tertiary);
}

/* Select einheitlich */
select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  padding-right: 32px;
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  cursor: pointer;
  font-size: var(--text-sm);
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}

/* Contact Details Container */
.contact-details-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-4);
}

.empty-details-prompt {
  text-align: center;
  padding: var(--spacing-4);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 2px dashed var(--border-light);
}

.empty-details-prompt p {
  margin: 0 0 var(--spacing-3);
  color: var(--text-secondary);
}

/* Detail Type Buttons */
.detail-type-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-2);
  justify-content: center;
}

.btn-add-detail {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-1);
  padding: var(--spacing-2) var(--spacing-3);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.detail-type-buttons.small .btn-add-detail {
  padding: 6px 10px;
  font-size: var(--text-xs);
}

/* Detail Groups */
.detail-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
}

.detail-group h4 {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

/* Detail Field Group */
.detail-field-group {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--spacing-3);
}

.detail-field-row {
  display: grid;
  grid-template-columns: 140px 1fr auto auto;
  gap: var(--spacing-2);
  align-items: center;
}

.detail-field-row:not(:last-child) {
  margin-bottom: var(--spacing-2);
}

.detail-field-row:last-child {
  grid-template-columns: 1fr;
}

/* Kleine Select-Boxen */
.form-control.small {
  max-width: 140px;
}

/* Remove Button */
.btn-remove {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  color: var(--text-tertiary);
}

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

/* Detail Add Section */
.detail-add-section {
  padding: var(--spacing-3);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  text-align: center;
}

.detail-add-section p {
  margin: 0 0 var(--spacing-2);
}

/* Institution Card */
.institution-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--spacing-3);
  margin-bottom: var(--spacing-2);
}

.institution-card h4 {
  margin: 0 0 var(--spacing-1);
  font-size: var(--text-md);
  font-weight: var(--font-medium);
}

.institution-card p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

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

.empty-state svg {
  color: var(--text-tertiary);
  margin-bottom: var(--spacing-4);
}

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

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

/* Text Utilities */
.text-muted {
  color: var(--text-tertiary);
}

/* Icons */
.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: var(--bg-hover);
}

/* Responsive */
@media (max-width: 1024px) {
  .detail-content {
    grid-template-columns: 1fr;
  }
  
  .detail-sidebar {
    order: -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
}

@media (max-width: 768px) {
  .contacts-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .contacts-controls {
    flex-direction: column;
  }
  
  .search-box {
    min-width: auto;
    width: 100%;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .form-field.small,
  .form-field.large {
    max-width: none;
    grid-column: 1;
  }
  
  .detail-field-row {
    grid-template-columns: 1fr;
    gap: var(--spacing-2);
  }
  
  .detail-field-row > * {
    width: 100% !important;
  }
}