/* ===== style.css - Исправленное отображение десктопа ===== */
:root {
  --blue-deep: #0a2a5a;
  --blue-main: #1560BD;
  --blue-medium: #4D94EB;
  --blue-light: #5eaaff;
  --blue-pale: #d0e4ff;
  --blue-ghost: #eaf2ff;
  --white: #ffffff;
  --gray-light: #f5f7fa;
  --gray-text: #6b7a90;
  --red-status: #e53e3e;
  --green-status: #38a169;
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.08);
  --radius-card: 24px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --transition: 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(180deg, #e8eef4 0%, #f0f4f8 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px;
  color: var(--blue-deep);
  line-height: 1.5;
}

/* ===== LOADING ===== */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-screen.hidden {
  display: none;
}

.loading-spinner {
  width: 56px;
  height: 56px;
  border: 4px solid var(--blue-pale);
  border-top-color: var(--blue-main);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  margin-top: 20px;
  font-size: 17px;
  color: var(--gray-text);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== HEADER ===== */
.header {
  width: 100%;
  max-width: 700px;
  text-align: center;
  margin-bottom: 32px;
}

.header__logo-wrap {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header__logo-wrap img {
  width: 100%;
  height: auto;
}

.header__title {
  font-size: 28px;
  font-weight: 700;
  color: var(--blue-deep);
  margin-bottom: 6px;
}

.header__subtitle {
  font-size: 18px;
  color: var(--gray-text);
}

/* ===== CARD ===== */
.card {
  width: 100%;
  max-width: 700px;
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.card__banner {
  background: linear-gradient(135deg, #1560BD 0%, #4D94EB 100%);
  padding: 28px 32px;
  min-height: 100px;
  display: flex;
  align-items: center;
}

.card__banner-text {
  color: var(--white);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.card__body {
  padding: 32px;
  display: flex;
  gap: 28px;
}

/* ===== PHOTO ===== */
.card__photo-wrap {
  flex-shrink: 0;
  width: 180px;
  text-align: center;
}

.card__photo {
  width: 180px;
  height: 240px;
  border-radius: var(--radius-sm);
  background: var(--gray-light);
  border: 4px solid var(--blue-pale);
  overflow: hidden;
  margin-bottom: 12px;
  position: relative;
}

.card__photo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue-ghost);
}

.card__photo-placeholder svg {
  width: 72px;
  height: 72px;
  fill: var(--blue-light);
  opacity: 0.5;
}

.card__photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.card__photo img.loaded {
  display: block;
}

.card__photo img.loaded + .card__photo-placeholder {
  display: none;
}

.card__member-id {
  font-size: 14px;
  color: var(--gray-text);
  font-weight: 500;
}

.card__member-id span {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--blue-main);
  margin-top: 4px;
}

/* ===== INFO ===== */
.card__info {
  flex: 1;
  min-width: 0;
}

.card__name {
  font-size: 26px;
  font-weight: 700;
  color: var(--blue-deep);
  margin-bottom: 14px;
  line-height: 1.3;
}

.card__status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
}

.card__status--active {
  background: rgba(56, 161, 105, 0.12);
  color: var(--green-status);
}

.card__status--excluded {
  background: rgba(229, 62, 62, 0.12);
  color: var(--red-status);
}

/* ===== STATUS INDICATOR ===== */
.card__status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green-status); /* По умолчанию зеленый */
  animation: pulse 2s ease-in-out infinite; /* Мигание */
  flex-shrink: 0;
}

/* 🔥 ДОБАВИТЬ: Красный индикатор для исключенных (наследует мигание) */
.card__status--excluded .card__status-indicator {
  background: var(--red-status);
}

.card__divider {
  width: 100%;
  height: 1px;
  background: var(--blue-pale);
  margin: 20px 0;
}

/* ===== DETAILS — ИСПРАВЛЕННОЕ ВЫРАВНИВАНИЕ ДАТ ===== */
.card__details {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card__detail {
  background: var(--gray-light);
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card__detail-label {
  font-size: 12px;
  color: var(--gray-text);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.card__detail-value {
  font-size: 17px;
  color: var(--blue-deep);
  font-weight: 600;
  line-height: 1.5;
}

/* Ряд из двух полей на десктопе */
.card__details-row {
  display: flex;
  gap: 14px;
}

.card__details-row .card__detail {
  flex: 1;
}

.card__detail--region {
  background: linear-gradient(135deg, var(--blue-pale) 0%, var(--blue-ghost) 100%);
}

.card__detail--region .card__detail-value {
  color: var(--blue-main);
  font-weight: 700;
  font-size: 17px;
}

/* ===== QR CODE ===== */
.card__qr {
  padding: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: var(--gray-light);
  border-top: 1px solid var(--blue-pale);
}

.card__qr-code {
  width: 200px;
  height: 200px;
  background: var(--white);
  padding: 15px;
  border-radius: var(--radius-xs);
  border: 2px solid var(--blue-pale);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card__qr-code canvas {
  width: 150% !important;
  height: 150% !important;
  border-radius: 4px;
}

.card__qr-text {
  font-size: 15px;
  color: var(--gray-text);
  max-width: 240px;
  line-height: 1.5;
  text-align: center;
}

/* ===== FOOTER ===== */
.card__footer {
  padding: 24px 32px;
  text-align: center;
  background: rgba(245, 247, 250, 0.8);
  border-top: 1px solid var(--blue-pale);
}

.card__footer-text {
  font-size: 14px;
  color: var(--gray-text);
  margin-bottom: 8px;
}

.card__footer-update {
  font-size: 14px;
  color: var(--blue-main);
  font-weight: 600;
  margin-bottom: 10px;
}

.card__footer-link {
  font-size: 15px;
  color: var(--blue-main);
  text-decoration: none;
  font-weight: 600;
}

.card__footer-link:hover {
  text-decoration: underline;
}

/* ===== SEARCH SECTION ===== */
.search-section {
  width: 100%;
  max-width: 700px;
}

.search-card {
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 40px 32px;
  text-align: center;
}

.search-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--blue-deep);
  margin-bottom: 28px;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.search-input {
  width: 100%;
  max-width: 340px;
  padding: 16px 20px;
  font-size: 18px;
  border: 2px solid var(--blue-pale);
  border-radius: var(--radius-xs);
  outline: none;
  text-align: center;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--blue-main);
  box-shadow: 0 0 0 4px rgba(0, 98, 204, 0.1);
}

.search-input::placeholder {
  color: var(--gray-text);
}

.search-btn {
  width: 100%;
  max-width: 340px;
  padding: 16px 28px;
  font-size: 18px;
  font-weight: 600;
  color: var(--white);
  background: linear-gradient(135deg, var(--blue-main) 0%, var(--blue-medium) 100%);
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 98, 204, 0.3);
  transition: var(--transition);
}

.search-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 98, 204, 0.4);
}

.search-btn:active {
  transform: translateY(0);
}

.search-hint {
  font-size: 15px;
  color: var(--gray-text);
  line-height: 1.5;
}

.search-hint strong {
  color: var(--blue-main);
}

.search-error {
  display: none;
  color: var(--red-status);
  font-size: 15px;
  margin: 14px 0;
  font-weight: 600;
}

.search-error.visible {
  display: block;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 42, 90, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 24px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.modal__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--blue-deep);
  margin-bottom: 14px;
}

.modal__text {
  font-size: 16px;
  color: var(--gray-text);
  margin-bottom: 24px;
  line-height: 1.5;
}

.modal__input {
  width: 100%;
  padding: 16px 20px;
  font-size: 18px;
  border: 2px solid var(--blue-pale);
  border-radius: var(--radius-xs);
  outline: none;
  text-align: center;
  margin-bottom: 16px;
}

.modal__input:focus {
  border-color: var(--blue-main);
}

.modal__error {
  display: none;
  color: var(--red-status);
  font-size: 14px;
  margin-bottom: 16px;
  font-weight: 600;
}

.modal__error.visible {
  display: block;
}

.modal__btns {
  display: flex;
  gap: 14px;
}

.modal__btn {
  flex: 1;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: var(--transition);
}

.modal__btn--confirm {
  background: linear-gradient(135deg, var(--blue-main) 0%, var(--blue-medium) 100%);
  color: var(--white);
}

.modal__btn--cancel {
  background: var(--gray-light);
  color: var(--gray-text);
}

/* ===== MOBILE ADAPTATION ===== */
@media (max-width: 768px) {
  body {
    padding: 20px 16px;
  }

  .header {
    margin-bottom: 24px;
  }

  .header__logo-wrap {
    width: 64px;
    height: 64px;
    margin-bottom: 12px;
  }

  .header__title {
    font-size: 22px;
  }

  .header__subtitle {
    font-size: 16px;
  }

  .card {
    border-radius: 20px;
  }

  .card__banner {
    padding: 20px 20px;
  }

  .card__banner-text {
    font-size: 13px;
  }

  .card__body {
    flex-direction: column;
    align-items: center;
    padding: 24px 20px;
    gap: 20px;
  }

  .card__photo-wrap {
    width: 100%;
    max-width: 160px;
  }

  .card__photo {
    width: 160px;
    height: 200px;
  }

  .card__info {
    width: 100%;
    text-align: center;
  }

  .card__name {
    font-size: 22px;
  }

  .card__status {
    margin: 0 auto 16px;
  }

  .card__details {
    width: 100%;
  }

  /* На мобильных два поля в ряд */
  .card__details-row {
    flex-direction: row;
    gap: 12px;
  }

  .card__detail {
    padding: 16px 16px;
    text-align: center;
  }

  .card__qr {
    flex-direction: column;
    padding: 24px 20px;
    gap: 16px;
  }

  .card__qr-code {
    width: 150px;
    height: 150px;
  }

  .card__qr-text {
    font-size: 14px;
  }

  .search-card {
    padding: 32px 20px;
    border-radius: 20px;
  }

  .search-input,
  .search-btn {
    max-width: 100%;
  }

  .modal {
    padding: 28px 20px;
  }

  .modal__btns {
    flex-direction: column;
  }
}

/* ===== VERY SMALL DEVICES ===== */
@media (max-width: 480px) {
  body {
    padding: 16px 12px;
  }

  .header__title {
    font-size: 20px;
  }

  .header__subtitle {
    font-size: 15px;
  }

  .card {
    border-radius: 16px;
  }

  .card__body {
    padding: 20px 16px;
  }

  .card__name {
    font-size: 20px;
  }

  .card__detail-value {
    font-size: 16px;
  }

  .card__qr-code {
    width: 120px;
    height: 120px;
  }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}



/* Добавьте в конец CSS файла */

/* ===== QR CODE MODAL ===== */
.card__qr-code {
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card__qr-code:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 24px rgba(0, 98, 204, 0.2);
}

.qr-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 42, 90, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

.qr-modal-overlay.active {
  display: flex;
}

.qr-modal {
  background: var(--white);
  border-radius: var(--radius-card);
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: scaleIn 0.3s ease;
  max-width: 90vw;
  max-height: 90vh;
}

.qr-modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  background: var(--white);
  border: none;
  border-radius: 50%;
  font-size: 24px;
  color: var(--gray-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.qr-modal__close:hover {
  background: var(--gray-light);
  color: var(--blue-deep);
  transform: rotate(90deg);
}

.qr-modal__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--blue-deep);
  margin-bottom: 24px;
  text-align: center;
}

.qr-modal__code {
  width: 300px;
  height: 300px;
  background: var(--white);
  padding: 20px;
  border-radius: var(--radius-sm);
  border: 3px solid var(--blue-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.qr-modal__code canvas {
  width: 100% !important;
  height: 100% !important;
}

.qr-modal__hint {
  font-size: 15px;
  color: var(--gray-text);
  text-align: center;
  margin-top: 20px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { 
    opacity: 0;
    transform: scale(0.9);
  }
  to { 
    opacity: 1;
    transform: scale(1);
  }
}

/* Mobile adaptation for QR modal */
@media (max-width: 768px) {
  .qr-modal {
    padding: 32px 24px;
  }
  
  .qr-modal__code {
    width: 240px;
    height: 240px;
  }
}

/* ===== АНИМАЦИЯ МИГАНИЯ ИНДИКАТОРА ===== */
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.2); }
}

@media (max-width: 480px) {
  .qr-modal {
    padding: 28px 20px;
  }
  
  .qr-modal__code {
    width: 200px;
    height: 200px;
  }
  
  .qr-modal__title {
    font-size: 18px;
  }
}

/* ===== BACK BUTTON ===== */
.back-button {
  position: fixed;
  top: 24px;
  left: 24px;
  width: 48px;
  height: 48px;
  background: var(--white);
  border: none;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: none; /* Скрыта на главной */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  transition: var(--transition);
  color: var(--blue-main);
  -webkit-tap-highlight-color: transparent; /* Убирает синий блик при тапе */
}
.back-button:hover {
  transform: scale(1.1);
  background: var(--blue-ghost);
}
.back-button:active {
  transform: scale(0.95); /* Эффект нажатия */
}
.back-button svg {
  width: 24px;
  height: 24px;
  stroke-width: 3; /* Чуть жирнее линия для читаемости */
}

/*  АДАПТАЦИЯ ДЛЯ МОБИЛЬНЫХ */
@media (max-width: 768px) {
  .back-button {
    /* Отступ сверху с учетом "чёлки" iPhone */
    top: calc(12px + env(safe-area-inset-top)); 
    left: 16px;
    width: 44px; /* Минимальный удобный размер для пальца (44x44) */
    height: 44px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  }
  
  /* На маленьких экранах делаем иконку чуть компактнее */
  .back-button svg {
    width: 20px;
    height: 20px;
  }
}