/* Сброс и базовые стили */
*{
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body{
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f1f3f5;
  color: #111;
  line-height: 1.5;
}

/* Header */
header{
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: saturate(1.8) blur(20px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  header {
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }
}

/* Logo и описание */
.badge {
  font-size: 1.125rem;
  font-weight: 700;
  color: #111;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge b {
  color: #081349;
  font-weight: 800;
}

.badge::after {
  content: '— Доска рекламных объявлений';
  font-size: 0.875rem;
  font-weight: 400;
  color: #6b7280;
  margin-left: 0.5rem;
}

@media (max-width: 640px) {
  .badge::after {
    display: none;
  }
  .badge {
    font-size: 1rem;
  }
}

/* Элементы формы */
select, input, button {
  font: inherit;
  outline: none;
}

select, input {
  padding: 0.54rem 0.875rem;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: white;
  font-size: 0.975rem;
  /* font-weight: 500; */
  cursor: pointer;
  transition: all 0.2s ease;
  width: 190px;         /* фиксированная ширина */
  box-sizing: border-box;
  color: #111;
}

select:hover, input:hover {
  border-color: #d1d5db;
}

select:focus, input:focus {
  border-color: #081349;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input {
  cursor: text;
}

input::placeholder {
  color: #9ca3af;
}

/* Кнопки */
.btn {
  background: #081349;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.625rem 1rem;
  cursor: pointer;
  font-size: 0.975rem;
  font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn:hover {
  background: #000;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.icon-btn {
  padding: 0.625rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.moderation-toggle {
  font-size: 0.875rem;
}

.controls{
  display:flex;
  gap: .5rem;
  align-items:center;
  flex-wrap: wrap;
}

@media (max-width: 768px){
  .controls{
    flex: 1 1 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
    gap: .5rem;
  }

  .controls select,
  .controls input,
  .controls .btn{
    width: 100%;
    min-width: 0;
  }

  .controls select,
  .controls input{
    padding: .5rem .6rem;
    font-size: .9rem;
  }

  .controls .btn{
    padding: .5rem .6rem;
    font-size: .875rem;
    grid-column: 1 / -1;
  }

  .moderation-toggle,
  .controls select:last-of-type {
    grid-column: 1 / -1;
  }
}

/* Сетка баннеров */
/* Сетка баннеров: первый ряд + masonry */
.grid {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Первый ряд — аккуратная классическая сетка (одинаковая высота) */
/* .grid-first {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
} */

/* Мансорная сетка (как Pinterest) начиная со 2-й строки */
/* .grid-masonry {
  column-count: 3;
  column-gap: 1.25rem;
} */

.grid-masonry .card {
  break-inside: avoid;
  margin-bottom: 1.25rem;
}

@media (max-width: 1024px) {
  .grid {
    padding: 1.25rem;
  }
  .grid-first {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
  .grid-masonry {
    column-count: 2;
  }
}

@media (max-width: 768px) {
  .grid {
    padding: 1rem;
    gap: 1rem;
  }
  .grid-first {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
  }
  .grid-masonry {
    column-count: 1;
    column-gap: 0;
  }
  .grid-masonry .card {
    margin-bottom: 1rem;
  }
}


/* Карточка баннера */


.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
  border-color: #d1d5db;
}

/* Карточка в режиме модерации для админа */
.card.pending-admin {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  border-color: #93c5fd;
  cursor: pointer;
}

.card.pending-admin:hover {
  background: #fff;
  border-color: #60a5fa;
}

/* Изображение баннера */
/* Изображение баннера + skeleton + разные высоты */


/* skeleton до загрузки */
.thumb.thumb--loading {
  opacity: 1;
  animation: thumb-skeleton 1.2s ease-in-out infinite;
}

/* картинка загрузилась */
.thumb.thumb--loaded {
  opacity: 1;
  background: #f3f4f6;
  animation: none;
}



.thumb {
  /* display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  transition: opacity .3s ease; */
}

.thumb {
  width: 100%;
  display: block;
  object-fit: cover;
  background: linear-gradient(90deg, #f3f4f6 0%, #e5e7eb 50%, #f3f4f6 100%);
  background-size: 200% 100%;
  transition: transform 0.3s ease, opacity 0.3s ease, background-position 0.3s ease;
  opacity: 0; /* по умолчанию скрыта, покажем через классы */
}


.thumb--loading {
  opacity: 1;
}

.thumb--loaded {
  opacity: 1;
}



.thumb {
  width: 100%;
  height: auto;
  aspect-ratio: attr(data-w) / attr(data-h);
  object-fit: cover;
}


.card {
  break-inside: avoid;
  margin-bottom: 1.25rem;
}
#cards.grid-masonry  {
  position: relative;
  width: 100%;
  max-width: 1300px;   /* ширина, которую видишь на макете */
  margin: 0 auto;      /* центрирование */
  padding-top: 40px;   /* отступ сверху */
}
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  margin-bottom: 20px;
  margin-top: 20px;

}

.grid-masonry .card {
  position: absolute;
  transition: top .3s ease, left .3s ease, opacity .3s ease;
  width: 300px; /* фиксированная ширина, которая участвует в расчётах masonry */
}

/* варианты высоты для masonry (со 2-й строки и ниже) */
/* .thumb--h1 { aspect-ratio: 4 / 3; }
.thumb--h2 { aspect-ratio: 3 / 4; }
.thumb--h3 { aspect-ratio: 1 / 1; } */

@keyframes thumb-skeleton {
  0%   { background-position: 0% 0; }
  100% { background-position: -200% 0; }
}

.card:hover .thumb {
  transform: scale(1.02);
}


/* Метаданные */
.meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.875rem 1rem;
  gap: 0.75rem;
}

.title {
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.3;
  margin-bottom: 0.25rem;
  color: #111;
}

.location-price {
  color: #6b7280;
  font-size: 0.8125rem;
}

.meta-actions{ 
  display:flex; 
  align-items:center; 
  gap:.5rem; 
}

.views{
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  color: #b7cdda;
  font-size: .8125rem;
  line-height: 1;
}

.views svg{
  width: 16px;
  height: 16px;
  opacity: .7;
}

.views-num{ 
  opacity: .7; 
}

/* Status badges */
.status-badge{ display:none !important; }

/* Иконка удаления */
.icon {
  opacity: 0;
  color: #9ca3af;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0.25rem;
  font-size: 1.125rem;
  transition: all 0.2s ease;
  line-height: 1;
  flex-shrink: 0;
}

.card .icon {
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
}

.card:hover .icon { 
  opacity: 1; 
}

.card.owns .icon {
  opacity: 1 !important;
}

.icon { 
  -webkit-tap-highlight-color: transparent; 
}

@media (hover: none), (pointer: coarse) {
  .card.owns .icon {
    opacity: 1 !important;                  
  }
  .card .icon {
    padding: 0.5rem;             
    font-size: 1.25rem;          
  }
}

/* Диалог */
.dialog {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.panel {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: min(640px, 96vw);
  padding: 1.5rem;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.panel > .badge {
  font-size: 1.25rem;
  margin-bottom: 1.25rem;
  display: block;
}

.panel > .badge::after {
  content: '';
}

/* Зона загрузки */
.drop {
  border: 2px dashed #e5e7eb;
  border-radius: 12px;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #fafafa;
  padding: 1rem;
  text-align: center;
  overflow: hidden;
}

.drop:hover {
  border-color: #2563eb;
  background: #eff6ff;
  color: #2563eb;
}

.drop.dragging {
  border-color: #2563eb;
  background: #eff6ff;
  border-style: solid;
}

/* Превью изображения */
.preview {
  max-height: 300px;
  max-width: 100%;
  border-radius: 10px;
  display: block;
  object-fit: contain;
}

/* Форма */
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

.row input, 
.row select { 
  width: 100%; 
}

.row .full { 
  grid-column: 1 / -1; 
}

@media (max-width: 480px) {
  .row { 
    grid-template-columns: 1fr; 
  }
  .row .full { 
    grid-column: 1 / -1; 
  }
}

/* Footer */
footer {
  padding: 3rem 1rem;
  color: #9ca3af;
  text-align: center;
  font-size: 0.875rem;
}

/* Sentinel для infinite scroll */
#sentinel {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 0.875rem;
}

/* Loader */
.loader {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #e5e7eb;
  border-top-color: #111;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Анимации для уведомлений */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100px);
  }
}

/* Утилиты */
.hidden {
  display: none !important;
}

/* Уведомления */
.notification {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 10000;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.3s ease;
}

@media (max-width: 640px) {
  .notification {
    top: auto;
    bottom: 20px;
    right: 10px;
    left: 10px;
    max-width: none;
  }
}

/* Улучшение доступности */
*:focus-visible {
  outline: 2px solid #081349;
  outline-offset: 2px;
}

/* Плавная прокрутка */
html {
  scroll-behavior: smooth;
}

/* Скрытие скроллбара (опционально) */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f3f4f6;
}

::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* ====== RX Contact Modal ====== */
.rx-overlay{
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display:flex; align-items:center; justify-content:center;
  padding: 1rem;
}

@media (max-width: 640px){ 
  .rx-overlay{ 
    align-items: center;
    padding: 1rem;
  } 
}

.rx-modal{
  width: 100%; max-width: 420px;
  background: #fff; color: #0f172a;
  border: 1px solid rgba(15,23,42,.08);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  border-radius: 20px; overflow: hidden;
  transform: translateY(10px); animation: rx-pop .18s ease-out forwards;
}

@keyframes rx-pop{ to{ transform: translateY(0);} }

@media (max-width: 640px){
  .rx-modal{ 
    max-width: min(420px, 96vw);
    width: 100%;
  }
}

.rx-wrap{ padding: 1.5rem; display:flex; flex-direction:column; gap:14px; }
.rx-head{ display:flex; flex-direction:column; gap:8px; }

.rx-title{ font-size:18px; font-weight:600; letter-spacing:.01em; }

/* номер/ссылка */
.rx-number{
  display:flex; align-items:center; gap:10px; padding:10px 12px;
  background:#f8fafc; border:1px solid rgba(15,23,42,.08); border-radius: 14px;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
.rx-number__val{
  font-variant-numeric: tabular-nums; font-weight:500; color:#0f172a;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; flex: 1 1 auto;
}
.rx-copy{
  display:inline-grid; place-items:center; width:34px; height:34px; border-radius:10px;
  border:1px solid rgba(15,23,42,.08); background:#fff; color:#0f172a; opacity:.95; flex: 0 0 34px;
}
.rx-copy:hover{ opacity:1; }
.rx-copy svg{ width:18px; height:18px; display:block; shape-rendering: geometricPrecision; }

/* сетка кнопок */
.rx-actions{ display:grid; grid-template-columns: 1fr 1fr; gap:10px; }
@media (max-width: 420px){ .rx-actions{ grid-template-columns: 1fr; } }

/* кнопка */
.rx-btn{
  display:flex; align-items:center; justify-content:center; gap:10px;
  padding:14px 16px; border-radius:14px; border:1px solid rgba(15,23,42,.08);
  font-weight:600; letter-spacing:.01em; transition: transform .06s ease, opacity .12s ease;
  background:#ffffff; color:#0f172a; text-decoration:none;
  -webkit-tap-highlight-color: transparent;
}
.rx-btn:active{ transform: translateY(1px); }

/* единое качество иконок */
.rx-ico { 
  display:inline-flex; 
  width:20px; height:20px; 
  align-items:center; justify-content:center; 
  vertical-align:middle;
}
.rx-ico svg { 
  width:18px; height:18px; 
  display:block; 
  shape-rendering:geometricPrecision;
}
.rx-btn { gap: .5rem; }

/* варианты */
.rx-btn--call{
  background: #16a34a; 
  color:#fff; 
  border-color: #16a34a;
}
.rx-btn--call:hover{
  background: #15803d;
}

.rx-btn--wa{
  background: #22c55e; 
  color:#fff; 
  border-color: #22c55e;
}
.rx-btn--wa:hover{
  background: #16a34a;
}

.rx-btn--web{
  background: #3b82f6; 
  color:#fff; 
  border-color: #3b82f6;
}
.rx-btn--web:hover{
  background: #2563eb;
}

.rx-btn--tg{
  background: #0ea5e9; 
  color:#fff; 
  border-color: #0ea5e9;
}
.rx-btn--tg:hover{
  background: #0284c7;
}

.rx-btn--ghost{ 
  background:#fff; 
  color:#111; 
  border: 1px solid #e5e7eb;
}
.rx-btn--ghost:hover{
  background:#f9fafb;
}

.rx-btn--full{ grid-column: 1 / -1; }

@media (max-width: 640px) {
  .badge { display: none !important; }

  header { padding: 0.65rem 0.75rem; overflow-x: hidden; }

  .controls {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr;
    gap: .5rem;
    width: 100%;
    box-sizing: border-box;
  }

  .controls select:last-of-type { grid-column: auto !important; }

  .controls .btn { grid-column: auto !important; }

  .controls select,
  .controls .btn {
    min-width: 0;
    width: 100%;
    padding: 10px 12px;
    line-height: 1.2;
    min-height: 40px;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 12px 24px rgba(0,0,0,.2);
  transition: transform .15s ease, box-shadow .15s ease;
}
.fab:hover { transform: translateY(-1px); box-shadow: 0 14px 28px rgba(0,0,0,.25); }

.fab--search {
  background: #081349;
  color: #fff;
}
.fab--search svg { width: 20px; height: 20px; display:block; }

.dialog .panel input[type="search"] {
  margin-bottom: 0.5rem !important;
}
.dialog .panel > div[style*="justify-content: flex-end"] {
  margin-top: 0.5rem !important;
}

.rx-btn--primary{
  background:#081349;
  color:#fff;
  border-color:#081349;
}
.rx-btn--primary:hover{
  background:#000;
}

.rx-btn--ghost:focus,
.rx-btn--ghost:focus-visible{
  outline: none !important;
  box-shadow: none !important;
}

.fab--search{
  background: #f3f4f6 !important;
  color: #374151 !important;
  border: 1px solid #e5e7eb;
  box-shadow: 0 10px 20px rgba(0,0,0,.12);
}
.fab--search:hover{
  background: #e5e7eb !important;
  box-shadow: 0 12px 24px rgba(0,0,0,.16);
}
.fab--search:active{
  background: #dfe3e8 !important;  /* клик */
  box-shadow: 0 8px 16px rgba(0,0,0,.12);
}
.fab--search svg{
  width: 20px; height: 20px; display: block;
  stroke: currentColor; fill: none;
}

.panel input,
.panel select {
  font-size: 0.95rem;
}

.panel .row {
  margin-top: 0.875rem;
  gap: 0.75rem;
}

.panel .btn {
  border-radius: 10px;
}

.panel .drop {
  margin-bottom: 1rem;
}

@media (max-width: 640px) {
  header .badge { 
    display: none !important; 
  }

  .panel > .badge {
    display: block !important;
    margin-bottom: 1.25rem;
    font-size: 1.25rem;
  }

  .panel > .badge { 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.panel-actions{
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  margin-top: 14px !important;
}

.panel-actions .btn{
  height: 44px;
  min-width: 140px;
  padding: 0 16px;
  box-sizing: border-box;
  font-size: 0.95rem;
  line-height: 1;
}

@media (max-width: 360px){
  .panel-actions .btn{ min-width: 120px; }
}

.input-error {
  border-color: #e11d48 !important;
}












/* --- Admin Masonry --- */
#cards.grid-masonry {
    position: relative;
    width: 100%;
    max-width: 1400px;
    margin: 40px auto;
    padding: 0 20px;
}

.grid-masonry .card {
    position: absolute;
    transition: opacity .3s ease, transform .3s ease;
}

/* Чтобы карточки не прилипали к левому краю */
.admin-wrapper {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* отключаем глобальные Masonry-стили для админки */
body.admin-page .grid-masonry .card {
    position: static !important;
    left: unset !important;
    top: unset !important;
}

/* админ-сетка */
body.admin-page .grid-first,
body.admin-page .grid-masonry {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)) !important;
    gap: 20px !important;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

body.admin-page .card {
    width: 100% !important;
    margin: 0 !important;
}