/* Базовые стили для всего приложения */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
  padding-bottom: 20px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Стили для навигации */
.navbar {
  background-color: #075e54;
  color: white;
  padding: 15px 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.nav-title {
  font-size: 22px;
  font-weight: bold;
}

.nav-links {
  display: flex;
  list-style: none;
}

.nav-links li {
  margin-left: 20px;
}

.nav-links a {
  color: white;
  text-decoration: none;
  font-size: 16px;
}

.nav-links a:hover {
  text-decoration: underline;
}

/* Стили для карточек */
.card {
  background-color: white;
  border-radius: 5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 20px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 20px;
  margin-bottom: 15px;
  color: #075e54;
}

/* Стили для кнопок */
.btn {
  display: inline-block;
  padding: 8px 16px;
  background-color: #128c7e;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
  transition: background-color 0.3s;
}

.btn:hover {
  background-color: #0f7a6c;
}

.btn-danger {
  background-color: #e74c3c;
}

.btn-danger:hover {
  background-color: #c0392b;
}

.btn-secondary {
  background-color: #95a5a6;
}

.btn-secondary:hover {
  background-color: #7f8c8d;
}

/* Формы */
.form-group {
  margin-bottom: 15px;
}

.form-control {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
}

/* Таблицы */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

table th,
table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #ddd;
}

table th {
  background-color: #f8f8f8;
  font-weight: 600;
}

table tr:hover {
  background-color: #f5f5f5;
}

/* Уведомления */
.alert {
  padding: 15px;
  border-radius: 4px;
  margin-bottom: 20px;
}

.alert-success {
  background-color: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
}

.alert-danger {
  background-color: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
}

.alert-info {
  background-color: #d1ecf1;
  border: 1px solid #bee5eb;
  color: #0c5460;
}

/* Статусы */
.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.status-connected {
  background-color: #d4edda;
  color: #155724;
}

.status-disconnected {
  background-color: #f8d7da;
  color: #721c24;
}

.status-connecting {
  background-color: #fff3cd;
  color: #856404;
}

.status-qr-received {
  background-color: #d1ecf1;
  color: #0c5460;
}

/* QR код */
.qr-container {
  text-align: center;
  margin: 20px 0;
}

.qr-image {
  padding: 20px;
  background-color: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  max-width: 100%;
}

/* Flexbox утилиты */
.flex {
  display: flex;
}

.justify-between {
  justify-content: space-between;
}

.items-center {
  align-items: center;
}

/* Общие утилиты */
.mb-20 {
  margin-bottom: 20px;
}

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

.hidden {
  display: none;
}

.loading-spinner {
  border: 4px solid rgba(0, 0, 0, 0.1);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border-left-color: #09f;
  margin: 20px auto;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Стили для пагинации */
.pagination {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.pagination-controls {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.pagination-info {
  font-size: 14px;
  color: #666;
}

.btn-pagination {
  padding: 5px 10px;
  background-color: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.btn-pagination.active {
  background-color: #128c7e;
  color: white;
  border-color: #128c7e;
}

.btn-pagination.disabled {
  background-color: #f5f5f5;
  color: #aaa;
  cursor: not-allowed;
}

.btn-pagination:hover:not(.disabled):not(.active) {
  background-color: #e5e5e5;
}

/* Утилиты */
.ml-10 {
  margin-left: 10px;
}

.mt-10 {
  margin-top: 10px;
}

.flex-grow {
  flex-grow: 1;
}

/* Уведомления с анимацией */
.alert-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
}

.alert {
  padding: 12px 20px;
  margin-bottom: 10px;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s, transform 0.3s;
}

.alert.show {
  opacity: 1;
  transform: translateX(0);
}

/* Адаптивный дизайн */
@media (max-width: 768px) {
  .nav-container {
    flex-direction: column;
  }

  .nav-links {
    margin-top: 10px;
  }

  .nav-links li {
    margin-left: 10px;
    margin-right: 10px;
  }
}

.contact-last-activity {
  display: block;
  font-size: 11px;
  color: #888;
  margin-top: 3px;
}

.contact-item.unread {
  background-color: #e7f3ef;
}

.contact-item.unread::after {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #25d366;
  position: absolute;
  top: 10px;
  right: 10px;
}

.contact-item {
  position: relative;
  transition: background-color 0.2s;
}

.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Состояние загрузки для кнопок */
.btn-loading {
  position: relative;
  color: transparent !important;
}

.btn-loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s infinite linear;
}

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

/* Оптимизация для мобильных */
@media (max-width: 768px) {
  .chat-container {
    flex-direction: column;
    height: auto;
  }

  .contacts-panel,
  .chat-panel {
    width: 100%;
    height: 300px;
  }

  .chat-panel {
    border-top: 1px solid #ddd;
  }
}

/* Анимация новых сообщений */
@keyframes highlight {
  0% {
    background-color: rgba(37, 211, 102, 0.2);
  }
  100% {
    background-color: transparent;
  }
}

.message-new {
  animation: highlight 2s ease-out;
}
