/**
 * Partner Map Plugin Styles
 * Version: 1.0.0
 */

/* CSS Variables */
.partner-map-container {
  --primary-color: #dc2626;
  --primary-hover: #b91c1c;
  --primary-light: #fee2e2;
  --secondary-color: #ef4444;
  --background: #ffffff;
  --surface: #f9fafb;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Base Styles */
.partner-map-container * {
  box-sizing: border-box;
}

/* Глобальная стилизация скроллбара */
.partner-map-container *::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.partner-map-container *::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.partner-map-container *::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
  transition: background 0.3s ease;
}

.partner-map-container *::-webkit-scrollbar-thumb:hover {
  background: var(--primary-hover);
}

.partner-map-container *::-webkit-scrollbar-corner {
  background: #f1f1f1;
}

/* Для Firefox */
.partner-map-container * {
  scrollbar-width: thin;
  scrollbar-color: var(--primary-color) #f1f1f1;
}

.partner-map-container {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  width: 100%;
  position: relative;
  background: var(--background);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin: 20px 0;
}

/* Loading */
.partner-map-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--background);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  min-height: 400px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--primary-light);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s ease-in-out infinite;
  margin-bottom: 16px;
}

.loading-text {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Map Section */
.map-section {
  position: relative;
  width: 100%;
}

.map-container {
  position: relative;
  display: flex;
  width: 100%;
  height: 800px;
  background: var(--surface);
}

/* Sidebar */
.sidebar {
  width: 350px;
  background: var(--background);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
  z-index: 10;
  position: relative;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--secondary-color)
  );
  color: white;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.15);
}

.sidebar-title {
  flex: 1;
}

.sidebar-title h3 {
  margin: 0 0 4px 0 !important;
  font-size: 16px;
  color: #fff;

  font-weight: 700;
}

.partner-count {
  font-size: 12px;
  opacity: 0.9;
}

/* Search */
.sidebar-search {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--background);
  position: sticky;
  top: 89px;
  z-index: 15;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.search-wrapper {
  position: relative;
}

.search-input {
  width: 100%;
  padding: 10px 40px 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E")
    no-repeat center;
  mask-size: contain;
}

/* Partners List */
.partners-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* Стилизация скроллбара для партнеров */
.partners-list::-webkit-scrollbar {
  width: 8px;
}

.partners-list::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.partners-list::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
  transition: background 0.3s ease;
}

.partners-list::-webkit-scrollbar-thumb:hover {
  background: var(--primary-hover);
}

/* Для Firefox */
.partners-list {
  scrollbar-width: thin;
  scrollbar-color: var(--primary-color) #f1f1f1;
}

.partner-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.partner-item:hover {
  background: var(--surface);
}

.partner-item.active {
  background: var(--primary-light);
  border-left: 4px solid var(--primary-color);
}

.partner-city {
  font-weight: 600;
  color: var(--primary-color);
  font-size: 14px;
  margin-bottom: 4px;
}

.partner-name {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 13px;
  margin-bottom: 6px;
  line-height: 1.3;
}

.partner-address {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 8px;
}

.partner-contacts {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.contact-item svg {
  fill: var(--primary-color);
  flex-shrink: 0;
}

.contact-item a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

.contact-item a:hover {
  text-decoration: underline;
}

/* Map Wrapper */
.map-wrapper {
  flex: 1;
  position: relative;
  min-width: 0;
  transition: all 0.2s ease;
}

.yandex-map {
  width: 100%;
  height: 100%;
}

/* Map Controls */
.map-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.map-control {
  width: 44px;
  height: 44px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
}

.map-control:hover {
  background: var(--surface);
  border-color: var(--primary-color);
  transform: translateY(-1px);
}

.map-control svg {
  fill: var(--text-secondary);
  transition: var(--transition);
}

.map-control:hover svg {
  fill: var(--primary-color);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal.show {
  opacity: 1;
  visibility: visible;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content-map {
  position: relative;
  background: var(--background);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 85vw;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(20px);
  transition: var(--transition);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  background: var(--surface);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  z-index: 1;
}

.modal-close:hover {
  background: var(--border);
}

.modal-close svg {
  fill: var(--text-secondary);
}

.modal-body {
  padding: 32px;
}

/* Partner Details */
.partner-details-header h3 {
  color: var(--primary-color);
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px 0;
}

.partner-details-business {
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 24px;
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section h4 {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 6px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-section p {
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.detail-section a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

.detail-section a:hover {
  text-decoration: underline;
}

.detail-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.action-btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
}

.action-btn.primary {
  background: var(--primary-color);
  color: white;
}

.action-btn.primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.action-btn.secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.action-btn.secondary:hover {
  background: var(--border);
  transform: translateY(-1px);
}

/* Error Content */
.error-content {
  text-align: center;
  padding: 40px 20px;
}

.error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.error-message {
  color: var(--primary-color);
  font-weight: 600;
  margin-bottom: 16px;
  font-size: 16px;
}

.error-button {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
}

.error-button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

/* Balloon Styles */
.balloon-content {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  max-width: 280px;
}

.balloon-header {
  font-weight: 700;
  color: var(--primary-color);
  font-size: 16px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--primary-light);
}

.balloon-business {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 8px;
}

.balloon-address {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 10px;
}

.balloon-address svg {
  color: var(--primary-color);
  margin-top: 2px;
  flex-shrink: 0;
}

.balloon-contacts {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.balloon-contact {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.balloon-contact svg {
  color: var(--primary-color);
  flex-shrink: 0;
}

.balloon-contact a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

.balloon-contact a:hover {
  text-decoration: underline;
}

.balloon-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.balloon-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
}

.balloon-btn:hover {
  background: var(--primary-hover);
}

/* Responsive Design */
@media (max-width: 768px) {
  .partner-map-container {
    margin: 10px 0;
    border-radius: var(--radius);
  }

  .map-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: 450px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .partners-list {
    min-height: 240px;
  }

  .map-controls {
    top: 8px;
    right: 8px;
  }

  .map-control {
    width: 36px;
    height: 36px;
  }

  .modal-content-map {
    width: 95%;
    margin: 0 !important;
  }

  .modal-body {
    padding: 24px;
  }

  .detail-actions {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .sidebar-header {
    padding: 12px;
    position: sticky;
    top: 0;
  }

  .sidebar-search {
    padding: 8px 12px;
    position: sticky;
    top: 65px;
  }

  .partner-item {
    padding: 12px;
  }
}
