/* Основные стили */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: #f4f4f4;
  line-height: 1.6;
  color: #333;
}

/* Шапка */
.header {
  background-color: #fff;
  color: white;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: relative;
  flex-wrap: nowrap;   /* Предотвращаем перенос элементов */
}

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

.logo img {
  pointer-events: none;
  max-width: 100%;
  max-height: 100%;
}

.title {
  color:#1f2937;
  font-size: 1.25rem;
  font-weight: bold;
  flex-grow: 1;
}

.btn-add {
  background-color: transparent;
  color: #1f2937;
  border: 2px solid #1f2937;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Поиск и фильтрация */
.search-container {
  padding: 12px 16px;
  background-color: #212529;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.search-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input {
  width: 100%;
  padding: 10px 12px 10px 40px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
}

.filter-wrapper {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 150px;
}

.filter-label {
  color: white;
  font-size: 14px;
  white-space: nowrap;
}

.department-filter {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  min-width: 100px;
  flex-grow: 1;
}

/* Кнопки экспорта */
.export-container {
  padding: 16px;
  background-color: white;
  border-top: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
}

.section-title {
  font-weight: 600;
  color: #4b5563;
  margin-bottom: 8px;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  cursor: pointer;
}

.btn-upload {
  background-color: #a855f7;
}

.btn-download {
  background-color: #22c55e;
}

.btn-sync {
  background-color: #f59e0b;
  width: 100%;
  margin-top: 16px;
  padding: 8px;
}

.btn-sync.syncing {
  background-color: #fbbf24;
}

.btn-sync.success {
  background-color: #22c55e;
}

.btn-sync.error {
  background-color: #ef4444;
}

.icon {
  width: 16px;
  height: 16px;
}

.sync-icon {
  width: 18px;
  height: 18px;
}

.syncing .sync-icon {
  animation: spin 1s linear infinite;
}

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

/* Список контактов */
.contacts-container {
  background-color: white;
}

.contact-item {
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
  display: block;
  color: inherit;
}

.contact-item:hover {
  background-color: #f9fafb;
}

.contact-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 4px;
}

.contact-name {
  font-weight: 500;
  color: #1f2937;
}

.contact-phone {
  color: #2563eb;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
}

.contact-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.contact-department {
  margin-top: 4px;
  font-size: 14px;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 4px;
}

.contact-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.btn-edit, .btn-delete-contact {
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  transition: color 0.2s;
  padding: 4px;
}

.btn-edit:hover {
  color: #3b82f6;
}

.btn-delete-contact:hover {
  color: #ef4444;
}

/* Загрузка */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 128px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #166534;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.empty-message {
  padding: 16px;
  text-align: center;
  color: #6b7280;
}

/* Модальные окна */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  overflow: auto;
}

.modal-content {
  background-color: white;
  margin: 20px auto;
  padding: 20px;
  border-radius: 8px;
  max-width: 500px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  position: relative;
}

.close {
  position: absolute;
  right: 20px;
  top: 15px;
  font-size: 24px;
  cursor: pointer;
  color: #9ca3af;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
  color: #374151;
}

.form-group input {
  width: 100%;
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 16px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.btn-submit {
  background-color: #16a34a;
}

.btn-delete {
  background-color: #ef4444;
}

.btn-cancel {
  background-color: #9ca3af;
}
/* Добавляем новые стили для авторизации */

/* Класс для скрытия элементов */
.hidden {
  display: none !important;
}

/* Стили для кнопки авторизации */
.btn-auth {
  background-color: transparent;
  color: #1f2937;
  border: 2px solid #1f2937;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Индикатор состояния авторизации */
.auth-indicator {
  position: relative;  /* Было absolute */
  top: auto;           /* Сбрасываем старое позиционирование */
  right: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #1f2937;
  font-size: 14px;
  margin-left: 10px;   /* Добавляем отступ слева */
}

.auth-indicator .logout-btn {
  background-color: rgba(255, 255, 255, 0.2);
  color: #1f2937;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;  /* Предотвращаем перенос текста кнопки */
}

.auth-indicator .logout-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

/* Скрытые элементы редактирования для неадминов */
.contact-actions.guest-view {
  display: none;
}

/* Стили для состояния авторизации в шапке */

.header.admin-mode .btn-add {
  display: flex;
}

.header.admin-mode .btn-auth {
  display: none;
}
/* Группировка элементов в шапке */
.header-group {
  display: flex;
  align-items: center;
  gap: 12px;
}
/* Адаптивность для больших экранов */
@media (min-width: 1024px) {
  .container {
      max-width: 1024px;
      margin: 0 auto;
  }
  
  .header {
      justify-content: space-between;
      border-radius: 8px 8px 0 0;
      margin-top: 16px;
  }
  
  .contacts-container {
      border-radius: 0 0 8px 8px;
      margin-bottom: 16px;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  }
}
@media (max-width: 600px) {
  .search-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-wrapper {
    width: 100%;
  }
}