/* Contacts Manager Styles */

.contacts-body {
  background: linear-gradient(135deg, #0b1120 0%, #1a1f35 100%);
  color: #e0e6f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding: 2rem 1rem;
}

.contacts-main {
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* Header */
.contacts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.contacts-header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
  color: #fff;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-export {
  padding: 0.625rem 1.25rem;
  border-radius: 6px;
  font-size: 0.9375rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
  color: #fff;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #357abd 0%, #2869a8 100%);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #e0e6f0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background: linear-gradient(135deg, #e24a4a 0%, #bd3535 100%);
  color: #fff;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #bd3535 0%, #a82828 100%);
}

.btn-close {
  background: none;
  border: none;
  color: #999;
  font-size: 2rem;
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.btn-close:hover {
  color: #fff;
}

/* Search & Controls */
.contacts-controls {
  margin-bottom: 1.5rem;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: #e0e6f0;
  font-size: 1rem;
}

.search-input:focus {
  outline: none;
  border-color: #4a90e2;
  background: rgba(255, 255, 255, 0.08);
}

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.tag-filter {
  padding: 0.375rem 0.75rem;
  border-radius: 20px;
  background: rgba(74, 144, 226, 0.1);
  color: rgba(74, 144, 226, 0.8);
  font-size: 0.875rem;
  border: 1px solid rgba(74, 144, 226, 0.3);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tag-filter:hover {
  background: rgba(74, 144, 226, 0.2);
  border-color: rgba(74, 144, 226, 0.5);
  transform: translateY(-1px);
}

.tag-filter.active {
  background: #4a90e2;
  border-color: #4a90e2;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

.tag-filter.active::after {
  content: " ✕";
  opacity: 0.8;
  margin-left: 0.25rem;
}

/* Contacts Grid */
.contacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  min-height: 200px;
}

.contact-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.contact-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(74, 144, 226, 0.4);
  transform: translateY(-2px);
}

.contact-card-header {
  margin-bottom: 1rem;
}

.contact-card-name {
  font-size: 1.25rem;
  font-weight: 600;
  color: #fff;
  margin: 0 0 0.25rem 0;
}

.contact-card-title {
  font-size: 0.9375rem;
  color: #4a90e2;
  margin: 0;
}

.contact-card-org {
  font-size: 0.875rem;
  color: #999;
  margin: 0.25rem 0 0 0;
}

.contact-card-body {
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: #ccc;
}

.contact-card-body p {
  margin: 0.375rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.contact-card-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.contact-tag {
  padding: 0.25rem 0.625rem;
  border-radius: 12px;
  background: rgba(74, 144, 226, 0.15);
  color: #4a90e2;
  font-size: 0.75rem;
  border: 1px solid rgba(74, 144, 226, 0.25);
}

.contact-tag.ai-transcribed {
  background: rgba(147, 51, 234, 0.15);
  color: #a855f7;
  border-color: rgba(147, 51, 234, 0.25);
}

/* AI Match Badge */
.ai-match-badge {
  background: linear-gradient(135deg, #4a90e2 0%, #a855f7 100%);
  color: #fff;
  padding: 0.5rem;
  border-radius: 8px 8px 0 0;
  margin: -1rem -1rem 0.5rem -1rem;
  font-size: 0.8rem;
}

.match-score {
  font-weight: 700;
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.match-reason {
  display: block;
  opacity: 0.9;
  font-size: 0.75rem;
  font-style: italic;
}

.contacts-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #666;
  font-size: 1.125rem;
  padding: 3rem 1rem;
}

/* Modals */
.contact-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.contact-modal .modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.contact-modal .modal-container {
  position: relative;
  z-index: 1;
  border: none;
  border-radius: 16px;
  background: #1a1f35;
  color: #e0e6f0;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.contact-modal::backdrop {
  display: none;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  background: #1a1f35;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.5rem;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  background: #1a1f35;
}

/* Form Styles */
.contact-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #ccc;
}

.form-group input,
.form-group textarea {
  padding: 0.625rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: #e0e6f0;
  font-size: 0.9375rem;
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #4a90e2;
  background: rgba(255, 255, 255, 0.08);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.ai-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-section details summary {
  cursor: pointer;
  font-weight: 500;
  padding: 0.5rem;
  border-radius: 6px;
}

.ai-section details summary:hover {
  background: rgba(255, 255, 255, 0.05);
}

.ai-options {
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-divider {
  text-align: center;
  color: #666;
  font-size: 0.875rem;
  position: relative;
  margin: 0.5rem 0;
}

.form-divider::before,
.form-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}

.form-divider::before {
  left: 0;
}

.form-divider::after {
  right: 0;
}

/* Export Modal */
.export-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.btn-export {
  padding: 1rem;
  background: rgba(74, 144, 226, 0.1);
  color: #4a90e2;
  border: 2px solid rgba(74, 144, 226, 0.3);
  font-size: 1rem;
}

.btn-export:hover {
  background: rgba(74, 144, 226, 0.2);
  border-color: #4a90e2;
}

/* View Details Modal */
.view-dialog .modal-body {
  line-height: 1.6;
}

.detail-row {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  font-weight: 600;
  color: #4a90e2;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
}

.detail-value {
  color: #e0e6f0;
}

.detail-value a {
  color: #4a90e2;
  text-decoration: none;
}

.detail-value a:hover {
  text-decoration: underline;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.25rem;
}

.detail-notes {
  white-space: pre-wrap;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.detail-metadata {
  background: rgba(255, 255, 255, 0.03);
  padding: 0.75rem;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.875rem;
  overflow-x: auto;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  color: #fff;
}

.loading-overlay[hidden] {
  display: none;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #4a90e2;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive */
@media (max-width: 768px) {
  .contacts-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .contacts-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .export-options {
    grid-template-columns: 1fr;
  }

  .contact-modal .modal-container {
    width: 95vw;
    max-height: 95vh;
  }
}

/* Duplicate Detection */
.duplicate-alert {
  background: linear-gradient(135deg, rgba(74, 144, 226, 0.2), rgba(168, 85, 247, 0.2));
  border: 1px solid rgba(74, 144, 226, 0.4);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  margin: 0 0 1.5rem 0;
  display: flex;
  align-items: center;
}

.alert-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  width: 100%;
}

.alert-icon {
  font-size: 1.5rem;
}

.alert-text {
  flex: 1;
  min-width: 200px;
}

.alert-text strong {
  color: #4a90e2;
  font-size: 1.1rem;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-text {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: underline;
}

.btn-text:hover {
  color: #fff;
}

/* Merge Review */
.duplicate-review {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.review-header {
  text-align: center;
}

.review-info {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 0.5rem;
}

.match-score {
  display: inline-block;
  background: linear-gradient(135deg, #4a90e2, #a855f7);
  color: #fff;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-weight: 600;
  margin-left: 0.5rem;
}

.match-reason {
  font-style: italic;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
}

.contact-comparison {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.compare-contact {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 1.5rem;
}

.compare-contact h3 {
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
  color: #4a90e2;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 0.5rem;
}

.contact-details p {
  margin: 0.5rem 0;
  line-height: 1.6;
}

.contact-details strong {
  color: rgba(255, 255, 255, 0.6);
  font-weight: 500;
  display: inline-block;
  min-width: 100px;
}

.compare-divider {
  font-size: 1.2rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.3);
  text-align: center;
  padding: 0.75rem 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.2);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
}

.merge-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
  .merge-actions {
    flex-direction: column;
  }
  
  .alert-content {
    flex-direction: column;
    align-items: stretch;
  }
}
