/* Admin panel + login */

/* --- Login -------------------------------------------------------------- */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 18px;
}
.login-card { width: min(400px, 100%); padding: 32px 28px; }
.login-brand { margin-bottom: 22px; }
.login-title { font-size: 24px; margin-bottom: 6px; }
.login-sub { color: var(--text-muted); font-size: 14px; margin: 0 0 24px; }

.form-error {
  margin: 16px 0 0;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: rgba(255, 68, 68, 0.12);
  border: 1px solid rgba(255, 68, 68, 0.3);
  color: #ff9999;
  font-size: 13px;
}

/* --- Top bar ------------------------------------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 15, 15, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 13px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.topbar-tag {
  margin-left: 10px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--line-mid);
}
.topbar-actions { display: flex; gap: 9px; align-items: center; }

.shell { max-width: 1180px; margin: 0 auto; padding: 26px 20px 80px; }

/* --- Stats -------------------------------------------------------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat { padding: 16px 18px; border-radius: var(--radius-md); }
.stat-label {
  margin: 0 0 6px;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.stat-value {
  margin: 0;
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 700;
  color: var(--text-strong);
}

/* --- Toolbar ------------------------------------------------------------ */
.toolbar {
  display: grid;
  grid-template-columns: 1fr 190px 170px;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  margin-bottom: 18px;
}
@media (max-width: 760px) {
  .toolbar { grid-template-columns: 1fr; }
}

/* --- Link cards --------------------------------------------------------- */
.link-list { display: grid; gap: 12px; }

.link-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-panel);
  border: 1px solid var(--line-soft);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.link-card:hover { border-color: rgba(255, 255, 255, 0.18); }
.link-card.is-disabled { opacity: 0.62; }

.link-cover {
  width: 56px; height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: #282828;
  border: none;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 20px;
}

.link-main { min-width: 0; }
.link-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-strong);
  margin: 0 0 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.link-artist { margin: 0 0 8px; font-size: 13px; color: var(--text-muted); }
.link-meta { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-mid);
  color: var(--text-base);
  background: rgba(255, 255, 255, 0.03);
}
.chip-slug { font-family: var(--font-mono); color: var(--accent-2); border-color: rgba(255, 78, 69, 0.3); }
.chip-country { color: #e0e0e0; border-color: rgba(255, 255, 255, 0.15); background: rgba(255, 255, 255, 0.05); }

.link-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line-mid);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-base);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 15px;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.09); color: var(--text-strong); }
.icon-btn.danger:hover { color: var(--danger); border-color: rgba(251, 113, 133, 0.4); background: rgba(251, 113, 133, 0.12); }

@media (max-width: 720px) {
  .link-card { grid-template-columns: 52px minmax(0, 1fr); }
  .link-cover { width: 52px; height: 52px; }
  .link-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* --- Empty state -------------------------------------------------------- */
.empty { text-align: center; padding: 54px 24px; border-radius: var(--radius-lg); }
.empty-icon { font-size: 42px; margin: 0 0 8px; color: var(--accent); }
.empty h2 { font-size: 20px; margin-bottom: 6px; }
.empty p { color: var(--text-muted); margin: 0 0 18px; }

/* --- Modal -------------------------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 18px; }
.modal[hidden] { display: none; }
.toast[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); }
.modal-card {
  position: relative;
  width: min(620px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  padding: 0;
  animation: modal-in 0.22s ease both;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line-soft);
  position: sticky; top: 0;
  background: rgba(33, 33, 33, 0.95);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-head h2 { font-size: 18px; }
.modal-body { padding: 20px 22px 22px; display: grid; gap: 15px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding-top: 6px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }
.tracking-interval-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tracking-interval-row .input { width: 70px; }
.tracking-interval-row span { font-size: 13px; color: var(--text-muted); }

.slug-row { display: flex; align-items: stretch; }
.slug-prefix {
  display: inline-flex; align-items: center;
  padding: 0 11px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-mid);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  white-space: nowrap;
}
.slug-row .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-family: var(--font-mono); }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; padding-top: 6px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 44px; height: 25px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line-mid);
  position: relative;
  transition: background 0.2s ease;
  flex: none;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: transparent; }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(19px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--accent-soft); }
.switch-text { font-size: 13.5px; color: var(--text-base); }

/* Preview */
.preview {
  display: flex; align-items: center; gap: 14px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--line-mid);
  background: rgba(255, 255, 255, 0.02);
}
.preview img { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; }
.preview-title { margin: 0; font-weight: 600; color: var(--text-strong); font-size: 14px; }
.preview-artist { margin: 0; font-size: 12.5px; color: var(--text-muted); }

/* Toast */
.toast {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 11px 20px;
  border-radius: var(--radius-pill);
  background: #323232;
  border: 1px solid var(--line-mid);
  color: var(--text-strong);
  font-size: 13px;
  box-shadow: var(--shadow-soft);
  animation: toast-in 0.2s ease both;
}
.toast.error { border-color: rgba(255, 68, 68, 0.45); color: #ff9999; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* --- Tabs --------------------------------------------------------------- */
.tab-content { display: none; }
.tab-content.is-active { display: block; }
.tab-btn.is-active { color: #ffffff; border-color: var(--accent); background: rgba(255, 0, 0, 0.12); }

/* --- Visitor table ------------------------------------------------------ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); }
.vtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--bg-panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
}
.vtable th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--line-mid);
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}
.vtable td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-base);
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vtable tr:last-child td { border-bottom: none; }
.vtable tr:hover td { background: rgba(255, 255, 255, 0.03); }

.outcome-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
}
.outcome-allowed { color: var(--ok); background: rgba(52, 211, 153, 0.12); }
.outcome-blocked { color: var(--danger); background: rgba(251, 113, 133, 0.12); }
.outcome-vpn_blocked { color: var(--warn); background: rgba(251, 191, 36, 0.12); }

.vpn-yes { color: var(--danger); font-weight: 600; }
.vpn-no { color: var(--text-muted); }

.vtable tr { cursor: pointer; }
.vtable tr:active td { background: rgba(255, 255, 255, 0.06); }

/* --- Visitor detail modal ----------------------------------------------- */
.modal-wide { width: min(720px, 100%); }

.detail-loading { text-align: center; color: var(--text-muted); padding: 30px; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 560px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-section {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.02);
}

.detail-section-title {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 5px 0;
  gap: 10px;
}

.detail-label {
  font-size: 12px;
  color: var(--text-muted);
  flex: none;
  min-width: 90px;
}

.detail-value {
  font-size: 12.5px;
  color: var(--text-strong);
  text-align: right;
  word-break: break-all;
  max-width: 280px;
}

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

.detail-ua {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-base);
  word-break: break-all;
  line-height: 1.5;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
}

/* --- Country multi-select checklist ------------------------------------ */
.country-checklist {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--line-mid);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 8px;
}
.country-checklist label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px;
  font-size: 13px;
  color: var(--text-base);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.country-checklist label:hover { background: rgba(255, 255, 255, 0.06); }
.country-checklist input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  flex: none;
}
