/* Глобальные настройки и стили сброса */
:root {
  --bg-color: #0b0f19;
  --panel-bg: rgba(17, 24, 39, 0.7);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  
  /* Цветовые палитры для каналов */
  --accent-tg: #24A1DE;
  --accent-wa: #25D366;
  --accent-vk: #0077FF;
  --accent-max: #ff3366;
  
  --status-active: #10b981;
  --status-active-glow: rgba(16, 185, 129, 0.4);
  --status-disconnected: #ef4444;
  --status-disconnected-glow: rgba(239, 68, 68, 0.4);
  
  /* Системный премиальный стек шрифтов (без обращений к внешним CDN/Google Fonts) */
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* Динамический градиентный фон с эффектом свечения */
.glass-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  background: 
    radial-gradient(circle at 10% 20%, rgba(36, 161, 222, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(255, 51, 102, 0.12) 0%, transparent 40%),
    #090d16;
  filter: blur(40px);
}

/* Экран авторизации */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(20px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: var(--transition);
}

.auth-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 40px;
  width: 100%;
  max-width: 450px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.4s ease-out;
}

.error-text {
  color: var(--status-disconnected);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
}

/* Кнопка выхода */
.logout-btn {
  background: rgba(239, 68, 68, 0.1);
  color: var(--status-disconnected);
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 10px;
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
}

/* Основной контейнер */
.app-container {
  width: 100%;
  max-width: 1200px;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  animation: fadeIn 0.5s ease-out;
}

/* Шапка сайта */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #ffffff 30%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo .icon {
  font-size: 1.8rem;
  animation: pulse 2s infinite ease-in-out;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 300;
  width: 100%;
}

/* Сетка карточек каналов */
.grid-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 25px;
}

@media (max-width: 600px) {
  .grid-layout {
    grid-template-columns: 1fr;
  }
}

/* Карточки с эффектом Glassmorphism */
.channel-card {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.channel-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: transparent;
  transition: var(--transition);
}

/* Индивидуальные подсветки карт */
#tg-card:hover { border-color: rgba(36, 161, 222, 0.4); }
#tg-card::before { background: var(--accent-tg); }

#wa-card:hover { border-color: rgba(37, 211, 102, 0.4); }
#wa-card::before { background: var(--accent-wa); }

#max-card:hover { border-color: rgba(255, 51, 102, 0.4); }
#max-card::before { background: var(--accent-max); }

#vk-card:hover { border-color: rgba(0, 119, 255, 0.4); }
#vk-card::before { background: var(--accent-vk); }

/* Шапка карточки */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 15px;
}

.channel-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.channel-icon {
  font-size: 1.6rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.tg-color { color: var(--accent-tg); box-shadow: 0 0 10px rgba(36, 161, 222, 0.1); }
.wa-color { color: var(--accent-wa); box-shadow: 0 0 10px rgba(37, 211, 102, 0.1); }
.max-color { color: var(--accent-max); box-shadow: 0 0 10px rgba(255, 51, 102, 0.1); }
.vk-color { color: var(--accent-vk); box-shadow: 0 0 10px rgba(0, 119, 255, 0.1); }

.card-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Статус-бейджи */
.status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-badge.active {
  background: rgba(16, 185, 129, 0.1);
  color: var(--status-active);
  box-shadow: 0 0 10px var(--status-active-glow);
}

.status-badge.active::before {
  background: var(--status-active);
  box-shadow: 0 0 8px var(--status-active);
  animation: pulse 1.5s infinite alternate;
}

.status-badge.disconnected {
  background: rgba(239, 68, 68, 0.1);
  color: var(--status-disconnected);
  box-shadow: 0 0 10px var(--status-disconnected-glow);
}

.status-badge.disconnected::before {
  background: var(--status-disconnected);
}

/* Тело карточки */
.card-body {
  display: flex;
  flex-direction: column;
  gap: 15px;
  flex-grow: 1;
}

.card-body.centered {
  align-items: center;
}

.description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
  font-weight: 300;
}

/* Контейнеры QR-кодов */
.qr-container {
  width: 220px;
  height: 220px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  margin: 10px 0;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
  transition: var(--transition);
}

.qr-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

#max-qr-container {
  width: min(92vw, 460px);
  height: min(92vw, 460px);
}

#max-qr-img {
  cursor: zoom-in;
}

.qr-placeholder {
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-align: center;
  padding: 20px;
  animation: blink 2s infinite ease-in-out;
}

/* Формы и поля ввода */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  animation: fadeIn 0.4s ease-out;
}

.form-group label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.input-with-button {
  display: flex;
  gap: 10px;
  width: 100%;
}

input {
  flex-grow: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: var(--transition);
}

input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.03);
}

/* Кнопки */
button {
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:active {
  transform: scale(0.97);
}

.primary-btn {
  background: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.primary-btn:hover {
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
  filter: brightness(1.1);
}

.success-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.success-btn:hover {
  filter: brightness(1.1);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Оповещения */
.info-alert, .success-alert {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  margin-top: 5px;
}

.info-alert {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.success-alert {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.15);
  color: #a7f3d0;
}

/* Футер */
.main-footer {
  text-align: center;
  margin-top: 20px;
  color: rgba(255, 255, 255, 0.25);
  font-size: 0.8rem;
  font-weight: 300;
}

/* Полезные классы скрытия */
.hidden {
  display: none !important;
}

/* Анимации */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
  }
}

@keyframes blink {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
