* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0c0f15;
  color: #f5f7fb;
}

/* универсално скриване (ползва се и за модала) */
.hidden { display: none !important; }

.admin-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #101522, #070910);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.logo { font-weight: 600; font-size: 20px; line-height: 1.2; }
.logo-main { display: block; letter-spacing: 0.08em; text-transform: uppercase; }
.logo-sub { display: block; font-size: 11px; color: #8b90a3; margin-top: 4px; }

.nav { display: flex; flex-direction: column; gap: 8px; }

.nav-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  text-align: left;
  background: transparent;
  color: #d6dbf5;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.05s;
}

.nav-btn:hover { background: rgba(255, 255, 255, 0.04); }
.nav-btn.active { background: linear-gradient(135deg, #4b6bff, #9b4bff); color: #fff; }

/* Main */
.main {
  flex: 1;
  padding: 20px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.main-header { display: flex; align-items: center; justify-content: space-between; }
.main-header h1 { margin: 0; font-size: 22px; }

.env-pill {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(155, 75, 255, 0.1);
  color: #d8c8ff;
}

/* Cards */
.cards-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: radial-gradient(circle at top left, #1c2340, #0d111b);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 14px 16px;
}

.card.wide { padding: 16px 18px; }
.view-subtitle { margin: 0 0 12px; font-size: 18px; }

.card-label {
  font-size: 12px;
  color: #9ca3c7;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.card-value { font-size: 22px; font-weight: 600; }
.card-sub { font-size: 12px; color: #9097b2; margin-top: 4px; }

/* Sections */
.view.hidden { display: none; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-header h2 { margin: 0; font-size: 18px; }

.filters-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
  font-size: 14px;
}

.filters-row select {
  background: #141827;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  padding: 6px 10px;
  color: #f5f7fb;
}

.filters-row input[type="text"],
.filters-row input[type="number"],
.filters-row input[type="email"],
.filters-row input[type="password"],
.filters-row input[type="date"],
.filters-row input[type="datetime-local"],
.form-row input,
.form-row textarea,
.filters-row textarea {
  background: #141827;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  padding: 8px 10px;
  color: #f5f7fb;
  font-size: 13px;
  outline: none;
  min-width: 220px;
}

.form-row textarea,
.filters-row textarea {
  width: 100%;
  min-height: 90px;
  resize: vertical;
}

.filters-row label,
.form-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.small-msg {
  margin-top: 10px;
  font-size: 12px;
  color: #9ca3c7;
}

.small-msg.success { color: #bbf7d0; }
.small-msg.error { color: #fca5a5; }

.muted {
  font-size: 12px;
  color: #9097b2;
}

.checkbox-inline,
label.inline {
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.primary-btn {
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #4b6bff, #9b4bff);
  color: #fff;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.primary-btn:hover { filter: brightness(1.05); }

/* (ако имаш вече secondary-btn в друг CSS – това няма да го счупи; ако нямаш, поне ще изглежда нормално) */
.secondary-btn {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.55);
  color: #e5e7eb;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}
.secondary-btn:hover { background: rgba(15, 23, 42, 0.9); }
.secondary-btn.small { padding: 6px 10px; font-size: 12px; }

/* Tables */
.table-wrapper {
  background: #0e121e;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 10px 12px;
  font-size: 13px;
  overflow-x: auto;
}

.table-wrapper.small { max-height: 280px; overflow: auto; }

table.admin-table { border-collapse: collapse; width: 100%; }

table.admin-table th, table.admin-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

table.admin-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3c7;
}

table.admin-table tr:hover td { background: rgba(255, 255, 255, 0.03); }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
}

.badge-status-live { background: rgba(74, 222, 128, 0.12); color: #bbf7d0; }
.badge-status-scheduled { background: rgba(59, 130, 246, 0.15); color: #bfdbfe; }
.badge-status-won_pending_payment { background: rgba(250, 204, 21, 0.15); color: #fef08a; }
.badge-status-won_paid, .badge-status-finished { background: rgba(148, 163, 184, 0.16); color: #e5e7eb; }

.action-btn {
  border-radius: 999px;
  border: none;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  margin-right: 4px;
}

.action-btn.pay { background: rgba(34, 197, 94, 0.16); color: #bbf7d0; }
.action-btn.relist { background: rgba(59, 130, 246, 0.16); color: #bfdbfe; }
.action-btn.disabled { opacity: 0.4; cursor: default; }

/* Loading */
.loading { padding: 40px; text-align: center; color: #9ca3c7; }

/* Toast */
.toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.95);
  color: #f9fafb;
  font-size: 13px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  max-width: 320px;
}

.toast.visible { opacity: 1; transform: translateY(0); }
.toast.hidden { display: none; }

/* Скриваме wholesale полето, но оставяме елемента */
.hidden-field { display: none !important; }

/* Layout за снимките в аукцион формата */
.image-upload-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.image-upload-block { display: flex; flex-direction: column; gap: 8px; }

.image-upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
}

.upload-btn {
  border-radius: 999px;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  padding: 6px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.6);
}

.upload-btn:hover { background: rgba(15, 23, 42, 0.9); }

.image-preview-wrapper {
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: #050816;
  padding: 6px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-preview-main {
  max-width: 100%;
  max-height: 180px;
  border-radius: 10px;
  object-fit: cover;
}

/* Преглед на галерията под формата на grid */
.gallery-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
}

.gallery-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.35);
  cursor: pointer;
}

.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* =======================
   Image library modal
   ======================= */

/* Контейнерът на модала */
#image-library-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 999999;
  display: none;              /* скрит по подразбиране */
  align-items: center;
  justify-content: center;
}

/* когато JS добави .is-open → показваме модала */
#image-library-modal.is-open {
  display: flex;
}

/* ако остане .hidden → насила го скриваме */
#image-library-modal.hidden {
  display: none !important;
}

.image-lib-dialog {
  background: #020617;
  border-radius: 16px;
  padding: 16px 18px;
  max-width: 900px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(148, 163, 184, 0.5);
}

.image-lib-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.image-lib-header h3 { margin: 0; font-size: 16px; }

.image-lib-body {
  margin-top: 12px;
  overflow: auto;
  max-height: 60vh;
}

/* grid за тъмбовете */
#image-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.image-lib-thumb {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.image-lib-thumb img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
}

.image-lib-thumb span {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 2px 6px;
  font-size: 10px;
  background: rgba(15, 23, 42, 0.7);
  border-radius: 999px;
}

.image-lib-thumb.selected {
  outline: 2px solid #22c55e;
  outline-offset: 2px;
}

.image-lib-footer {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Анимиран панел за детайли на потребител (Users & Wallets) */
#wallet-details {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.2s ease;
  padding-top: 0;
  padding-bottom: 0;
}

#wallet-details.active {
  max-height: 800px; /* достатъчно за таблиците */
  opacity: 1;
  padding-top: 10px;
  padding-bottom: 10px;
}

/* Profile details panel (бивш Wallet details) */
#wallet-details {
  max-height: 360px;        /* колко високо да стига панелът */
  overflow-y: auto;         /* вертикален скрол вътре в панела */
  padding: 8px 10px;
}

/* Вътрешен layout за информaцията в профил детайлите */
.profile-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
}

.profile-details-top {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.profile-details-block-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #9ca3c7;
  margin-bottom: 4px;
}

.profile-details-item {
  font-size: 13px;
  margin-bottom: 2px;
}

.profile-details-item span {
  color: #9ca3af;
}

.profile-details-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 4px;
}

.profile-details-table th,
.profile-details-table td {
  padding: 4px 6px;
  border-bottom: 1px solid rgba(148,163,184,0.25);
}

.profile-details-table th {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 11px;
  color: #9ca3c7;
}

#auction-edit-modal.hidden { display: none; }

#auction-edit-modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

#auction-edit-modal .image-lib-dialog {
  width: min(980px, 100%);
  max-height: 88vh;
  overflow: auto;
}

/* =========================
   ADMIN LOCK (NOT LOGGED)
   ========================= */

.admin-locked {
  display: none !important;
}

/* ===== Auctions layout fixes ===== */
html, body { max-width: 100%; overflow-x: hidden; }

/* ако layout-а ти е flex sidebar + main */
.admin-layout, .main, .view { min-width: 0; } /* ключово! */

/* Auctions form grid */
.auction-form-grid{
  display:grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
  min-width: 0;
}
.auction-form-grid .field{ min-width:0; }
.auction-form-grid input,
.auction-form-grid textarea,
.auction-form-grid select { width:100%; min-width:0; }

.field.full{ grid-column: 1 / -1; }
.field.span-2{ grid-column: span 2; }
.field.span-3{ grid-column: span 3; }

.hint{ font-size:12px; opacity:.7; margin-top:6px; }

/* responsive */
@media (max-width: 1100px){
  .auction-form-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field.span-2, .field.span-3{ grid-column: 1 / -1; }
}
@media (max-width: 640px){
  .auction-form-grid{ grid-template-columns: 1fr; }
}

/* Table scroll wrapper – само тук да има overflow */
.table-wrap{
  margin-top: 14px;
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(15,23,42,.45);
  min-width: 0;
}
.table-scroll{
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.table-scroll table{
  width: 100%;
  border-collapse: collapse;
  min-width: 980px; /* ако имаш много колони */
}

