/* NextModal - Compact Card-based Design System */

:root {
  /* Compact Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-10: 2.5rem;

  /* Compact Typography */
  --text-xs: 0.7rem;
  --text-sm: 0.75rem;
  --text-base: 0.8rem;
  --text-lg: 0.85rem;

  /* Font weights */
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* Border radius */
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;

  /* Colors */
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --primary-500: #3b82f6;

  /* Transitions */
  --transition-fast: 150ms;
}

/* Modal Header - Compact */
.contact-modal-header {
  text-align: center;
  margin-bottom: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid #333333;
  position: relative;
}

.contact-modal-title {
  font-size: 0.85rem;
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin: 0 0 var(--space-1) 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
}

.contact-modal-title i {
  color: var(--primary-500);
  font-size: 0.8rem;
}

.contact-modal-subtitle {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin: 0;
}

/* Found Contacts Button */
.found-contacts-toggle {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Form Container - Compact */
.contact-form-container {
  max-width: 800px;
  margin: 0 auto;
}

.modern-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Basic Information Card - Compact */
.form-section:has(#name) {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.form-section:has(#name):hover {
  border-color: #007bff;
  background: #e3f2fd;
}

.form-section:has(#name) .section-title {
  color: #495057;
}

.form-section:has(#name) .section-title::before {
  content: "🆔";
  font-size: 14px;
  margin-right: var(--space-1);
}

/* Phone Numbers Card - Compact */
.form-section:has(.phone-group) {
  background: #e8f5e8;
  border: 1px solid #c3e6c3;
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.form-section:has(.phone-group):hover {
  border-color: #28a745;
  background: #d4edda;
}

.form-section:has(.phone-group) .section-title {
  color: #155724;
}

.form-section:has(.phone-group) .section-title::before {
  content: "📞";
  font-size: 14px;
  margin-right: var(--space-1);
}

/* Location Search Card - Compact */
.address-search-section {
  background: #fff3cd;
  border: 1px solid #ffeaa7;
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.address-search-section:hover {
  border-color: #fd7e14;
  background: #fff8e1;
}

.address-search-section .section-title {
  color: #856404;
}

.address-search-section .section-title::before {
  content: "🗺️";
  font-size: 14px;
  margin-right: var(--space-1);
}

/* Address Details Card - Compact */
.form-section:has(#address) {
  background: #f3e8ff;
  border: 1px solid #ddd6fe;
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.form-section:has(#address):hover {
  border-color: #8b5cf6;
  background: #ede9fe;
}

.form-section:has(#address) .section-title {
  color: #6b21a8;
}

.form-section:has(#address) .section-title::before {
  content: "🏠";
  font-size: 14px;
  margin-right: var(--space-1);
}

/* Section Titles - Compact */
.section-title {
  font-size: 0.85rem;
  font-weight: var(--font-semibold);
  margin: 0 0 var(--space-1) 0;  /* Reduced gap */
  display: flex;
  align-items: center;
}

/* Form Rows and Groups - Compact */
.form-row {
  display: flex;
  gap: var(--space-2);
  align-items: end;
}

.form-group {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Form Controls - Compact */
.form-control,
.form-select {
  width: 100%;
  padding: var(--space-1) var(--space-2);
  border: 1px solid #ced4da;
  border-radius: var(--radius-md);
  background: white;
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: var(--font-medium);
  transition: all var(--transition-fast) ease;
  box-sizing: border-box;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

/* Phone Group - Compact */
.phone-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.phone-row {
  display: flex;
  gap: var(--space-2);
  align-items: end;
}

.phone-type-select {
  min-width: 120px;
  flex-shrink: 0;
}

.phone-input {
  flex: 1;
}

.additional-phone {
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.add-phone-btn {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: #28a745;
  color: white;
  border: 1px solid #28a745;
  border-radius: var(--radius-md);
  font-weight: var(--font-medium);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition-fast) ease;
  min-width: auto;
  flex-shrink: 0;
}

.add-phone-btn:hover {
  background: #218838;
  border-color: #218838;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Search Container - Compact */
.search-container {
  margin-bottom: var(--space-2);
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  padding: var(--space-1) var(--space-2) var(--space-1) 2rem;
  border: 1px solid #ffeaa7;
  border-radius: var(--radius-md);
  background: white;
  font-size: 0.75rem;
  font-weight: var(--font-medium);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.search-input:focus {
  border-color: #fd7e14;
  box-shadow: 0 0 0 2px rgba(253, 126, 20, 0.1);
}

.search-icon {
  position: absolute;
  left: var(--space-2);
  color: #856404;
  pointer-events: none;
  font-size: 0.8rem;
}

/* Map Container - Compact */
.map-container {
  margin: var(--space-2) 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid #ffeaa7;
}

.map-view {
  height: 200px;
  width: 100%;
}

#infowindow-content {
  display: none;
}

/* Google Maps autocomplete dropdown fix */
.pac-container {
  z-index: 10000 !important;
  border-radius: var(--radius-md);
  margin-top: 2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  font-family: inherit;
}

.pac-item {
  padding: var(--space-2);
  font-size: 0.75rem;
  cursor: pointer;
}

.pac-item:hover {
  background: #f0f0f0;
}

/* Select2 styles */
.select2-container {
  min-width: 120px;
}

.select2-container .select2-selection--single {
  height: auto;
  padding: var(--space-1) var(--space-2);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: normal;
  padding: 0;
  font-size: 0.75rem;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 100%;
}

.select2-dropdown {
  border-radius: var(--radius-md);
  font-size: 0.75rem;
}

.select2-results__option {
  padding: var(--space-2);
  font-size: 0.75rem;
}

/* Address Fields - Compact */
.address-fields .form-row {
  margin-bottom: var(--space-2);
}

.address-fields .form-row:last-child {
  margin-bottom: 0;
}

.flex-2 { flex: 2; }
.flex-1 { flex: 1; }

/* Existing Contacts Panel - Compact */
.existing-contacts-panel {
  background: #e1f5fe;
  border: 1px solid #b3e5fc;
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  margin-bottom: var(--space-2);
  display: none;
}

.existing-contacts-panel.show {
  display: block;
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Validation Message - Compact */
.validation-message {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-2);
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.75rem;
}

.validation-message i {
  color: #dc3545;
  font-size: 0.8rem;
}

/* Button Styles - Compact */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-weight: var(--font-medium);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition-fast) ease;
  text-decoration: none;
  justify-content: center;
}

.btn-outline-primary {
  background: transparent;
  color: #007bff;
  border-color: #007bff;
}

.btn-outline-primary:hover {
  background: #007bff;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.btn-sm {
  padding: var(--space-1) var(--space-2);
  font-size: 0.7rem;
}

/* Responsive Design - Compact */
@media (max-width: 768px) {
  /* Phone rows vertical on mobile */
  .phone-row {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }

  .phone-type-select {
    min-width: auto;
  }

  .add-phone-btn {
    align-self: center;
    min-width: 100px;
  }

  /* Keep address fields horizontal even on mobile */
  .address-fields .form-row {
    flex-direction: row !important;
  }

  .search-input {
    padding-left: 2rem;
  }

  .contact-modal-header {
    text-align: left;
  }

  .found-contacts-toggle {
    position: static;
    margin-top: var(--space-2);
  }
}