/* ==========================================================================
   КАЗАРМЫ — раскладка, расположения (этажи), школы, сводка
   ========================================================================== */

.barracks-container {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: start;
}

.barracks-sidebar,
.barracks-main,
.barracks-info-panel {
  background: var(--c-surface, #fff);
  border: 1px solid var(--c-border, #e6eaf2);
  border-radius: 14px;
  padding: 16px;
}

/* ---------- Сайдбар ---------- */
.select-collection { margin-bottom: 14px; }
.select-collection label {
  display: block; margin-bottom: 6px;
  font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--c-muted, #7c8798);
}
.barracks-collection-select { width: 100%; font-size: .82rem; }

.barracks-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 6px 0 12px;
}
.barracks-header h3 { margin: 0; font-size: 1.05rem; font-weight: 700; }

.add-barrack-btn, .add-location-btn {
  border: none; cursor: pointer;
  background: var(--c-brand, #2563eb); color: #fff;
  border-radius: 9px; padding: 8px 12px;
  font: inherit; font-size: .82rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 2px 8px -2px rgba(37, 99, 235, .5);
}
.add-barrack-btn:hover, .add-location-btn:hover { background: var(--c-brand-2, #1d4ed8); }
.add-location-btn { box-shadow: none; }

.barracks-list, .locations-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.barrack-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--c-surface-2, #f8fafc);
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.barrack-item:hover { background: var(--c-brand-soft, #eff4ff); border-color: rgba(37, 99, 235, .25); }
.barrack-item.active { background: var(--c-brand, #2563eb); color: #fff; }
.barrack-name { flex: 1; min-width: 0; font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barrack-actions, .location-actions { display: flex; gap: 2px; flex: 0 0 auto; }

/* Иконки-действия */
.edit-barrack, .edit-location, .delete-barrack, .delete-location {
  width: 28px; height: 28px; border: none; border-radius: 7px;
  background: transparent; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .82rem;
  transition: background .15s ease, color .15s ease;
  color: var(--c-text-2, #475569);
}
.edit-barrack:hover, .edit-location:hover { background: var(--c-surface, #fff); color: var(--c-brand, #2563eb); }
.delete-barrack:hover, .delete-location:hover { background: rgba(220, 38, 38, .12); color: var(--c-danger, #dc2626); }
.barrack-item.active .edit-barrack,
.barrack-item.active .delete-barrack,
.location-item.active .edit-location,
.location-item.active .delete-location { color: rgba(255, 255, 255, .9); }
.barrack-item.active .edit-barrack:hover,
.location-item.active .edit-location:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.barrack-item.active .delete-barrack:hover,
.location-item.active .delete-location:hover { background: rgba(255, 255, 255, .18); color: #fff; }

/* ---------- Основная область ---------- */
.barracks-main { display: flex; flex-direction: column; gap: 14px; }
.barrack-title h2 { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }

.locations-header, .schools-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 4px 0 8px;
}
.locations-header h3, .schools-header h3 { margin: 0; font-size: .95rem; font-weight: 700; }

.location-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--c-surface-2, #f8fafc);
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.location-item:hover { background: var(--c-brand-soft, #eff4ff); border-color: rgba(37, 99, 235, .25); }
.location-item.active { background: var(--c-brand, #2563eb); color: #fff; }
.location-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .88rem; min-width: 0; }
.location-name i { opacity: .7; font-size: .8rem; }
.location-meta { display: flex; gap: 5px; margin-left: auto; }
.location-chip {
  font-size: .7rem; font-weight: 700;
  background: var(--c-surface, #fff); color: var(--c-text-2, #475569);
  border-radius: 99px; padding: 2px 8px; white-space: nowrap;
}
.location-item.active .location-chip { background: rgba(255, 255, 255, .22); color: #fff; }

/* ---------- Школы ---------- */
.schools-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.assigned-schools, .unassigned-schools { min-width: 0; }
.assigned-schools h4, .unassigned-schools h4 {
  margin: 0 0 8px; padding-bottom: 6px;
  font-size: .8rem; font-weight: 700;
  color: var(--c-text-2, #475569);
  border-bottom: 1px solid var(--c-border, #e6eaf2);
  display: flex; align-items: center; gap: 7px;
}
.schools-count-chip {
  margin-left: auto;
  font-size: .68rem; font-weight: 700;
  background: var(--c-surface-2, #f1f5f9); color: var(--c-muted, #7c8798);
  border-radius: 99px; padding: 2px 8px; white-space: nowrap;
}
.schools-empty {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 10px; font-size: .78rem; color: var(--c-muted, #7c8798);
  background: var(--c-surface-2, #f8fafc); border: 1px dashed var(--c-border, #e6eaf2);
  border-radius: 10px; list-style: none;
}
.schools-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow-y: auto; }
.schools-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--c-surface, #fff);
  border: 1px solid var(--c-border, #e6eaf2);
  border-radius: 10px;
  transition: border-color .15s ease, background .15s ease;
}
.schools-list li:hover { border-color: rgba(37, 99, 235, .3); background: var(--c-brand-soft, #eff4ff); }
.schools-list li span { flex: 1; min-width: 0; font-size: .82rem; font-weight: 500; line-height: 1.3; }
.schools-list li span span { color: var(--c-muted, #7c8798); font-weight: 600; }

.assign-school, .unassign-school {
  width: 30px; height: 30px; flex: 0 0 30px;
  border: none; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .8rem;
  transition: background .15s ease, color .15s ease;
}
.assign-school { background: rgba(5, 150, 105, .12); color: #047857; }
.assign-school:hover { background: rgba(5, 150, 105, .22); }
.unassign-school { background: rgba(220, 38, 38, .1); color: #b91c1c; }
.unassign-school:hover { background: rgba(220, 38, 38, .2); }

/* ---------- Правая сводка ---------- */
.barracks-info-panel { display: flex; flex-direction: column; gap: 12px; }
.barracks-info-panel h3 {
  margin: 0; padding-bottom: 10px;
  font-size: .95rem; font-weight: 700;
  border-bottom: 1px solid var(--c-border, #e6eaf2);
  display: flex; align-items: center; gap: 8px;
}
.barracks-info-panel h3 i { color: var(--c-brand, #2563eb); }

.info-list { display: flex; flex-direction: column; gap: 10px; }
.info-barrack-card {
  background: var(--c-surface-2, #f8fafc);
  border: 1px solid var(--c-border, #e6eaf2);
  border-radius: 12px;
  padding: 12px;
}
.info-barrack-title {
  display: flex; align-items: center; gap: 8px;
  font-size: .85rem; font-weight: 700;
  padding-bottom: 8px; margin-bottom: 8px;
  border-bottom: 1px dashed var(--c-border, #e6eaf2);
}
.info-barrack-title i { color: var(--c-brand, #2563eb); }
.info-location-card {
  background: var(--c-surface, #fff);
  border: 1px solid var(--c-border, #e6eaf2);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
}
.info-location-card:last-child { margin-bottom: 0; }
.info-location-title {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: .8rem; font-weight: 600; color: var(--c-brand, #2563eb);
  margin-bottom: 8px;
}
.info-total-people { margin-left: auto; font-size: .72rem; font-weight: 700; color: var(--c-success, #059669); }
.info-schools-list { display: flex; flex-direction: column; gap: 5px; }
.info-school-item {
  display: flex; align-items: center; gap: 7px;
  font-size: .76rem; padding: 5px 7px;
  background: var(--c-surface-2, #f8fafc);
  border-radius: 7px;
}
.info-school-item i { color: var(--c-muted, #7c8798); font-size: .72rem; }
.school-count {
  margin-left: auto; font-size: .68rem; font-weight: 700;
  background: rgba(37, 99, 235, .1); color: var(--c-brand, #2563eb);
  padding: 1px 6px; border-radius: 99px;
}
.info-empty { text-align: center; font-size: .74rem; color: var(--c-muted, #7c8798); padding: 6px; }
.info-placeholder { text-align: center; color: var(--c-muted, #7c8798); font-size: .85rem; padding: 30px 12px; }
.info-placeholder i { display: block; font-size: 1.6rem; opacity: .45; margin-bottom: 8px; }

/* ---------- Адаптив ---------- */
@media (max-width: 1400px) {
  .barracks-container { grid-template-columns: 240px minmax(0, 1fr); }
  .barracks-info-panel { grid-column: 1 / -1; }
}
@media (max-width: 1000px) {
  .barracks-container { grid-template-columns: 1fr; }
  .schools-columns { grid-template-columns: 1fr; }
  .schools-list { max-height: none; }
}
