/* IPA Каталог — owner panel. Builds on site.css tokens. */

/* Login */

/* The login screen stands alone: no navigation bar above it. */
.admin-page:has(#login-panel:not([hidden])) .nav {
  display: none;
}

.login {
  display: grid;
  place-items: center;
  min-height: calc(100dvh - 48px);
  padding: 32px 0;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 36px 28px 28px;
  border-radius: var(--r-xl);
  text-align: center;
}

.login-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border-radius: 22.5%;
  box-shadow: 0 14px 30px -12px rgba(0, 85, 212, 0.6);
}

.login-card h1 {
  font-size: 28px;
  letter-spacing: -0.03em;
}

.login-sub {
  margin: 8px 0 24px;
  font-size: 15px;
  color: var(--ink-2);
}

.login-form {
  display: grid;
  gap: 12px;
}

.passkey-btn {
  gap: 8px;
}

.login-divider {
  margin: 20px 0 12px;
  font-size: 13px;
  color: var(--ink-3);
}

.passkey-panel .btn {
  margin-top: 14px;
}

.passkey-list {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.passkey-list:empty {
  display: none;
}

.passkey-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 0.5px solid var(--sep);
}

.passkey-item:first-child {
  border-top: 0;
}

.passkey-info {
  flex: 1;
  min-width: 0;
}

.passkey-name {
  font-size: 15px;
  font-weight: 600;
}

.passkey-meta {
  font-size: 13px;
  color: var(--ink-2);
}

.passkey-panel .passkey-item .btn {
  margin-top: 0;
}

.login-card .error {
  margin-top: 14px;
}

/* Dashboard header */

.admin-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px 16px;
  padding: 28px 0 20px;
}

.admin-head h1 {
  font-size: clamp(34px, 5vw, 48px);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.count {
  font-size: 15px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.admin-grid {
  display: grid;
  gap: 20px;
}

.admin-grid > * {
  min-width: 0;
}

.admin-side {
  display: grid;
  gap: 20px;
  align-content: start;
  min-width: 0;
}

@media (min-width: 960px) {
  .admin-grid {
    grid-template-columns: 360px minmax(0, 1fr);
    align-items: start;
  }
  .admin-side {
    position: sticky;
    top: 72px;
  }
}

.panel {
  padding: 20px;
  border-radius: var(--r-lg);
}

.panel h2 {
  font-size: 20px;
  letter-spacing: -0.025em;
}

.panel > p {
  margin-top: 6px;
  font-size: 15px;
  color: var(--ink-2);
}

.share-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.rotate-link {
  margin: 10px 0 -6px -12px;
}

.share-actions #copy-link,
.share-actions #copy-shared {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 16px;
}

@media (max-width: 360px) {
  .share-actions {
    flex-wrap: wrap;
  }
  .share-actions #copy-link,
  .share-actions #copy-shared {
    flex-basis: 100%;
  }
  .share-actions .btn-icon {
    flex: 1;
  }
}

@media (max-width: 480px) {
  .admin-page .nav-title {
    display: none;
  }
  .admin-page #logout {
    margin-left: auto;
  }
}

@media (max-width: 420px) {
  .panel {
    padding: 16px;
  }
  .admin-head {
    padding-top: 20px;
  }
}

/* Upload */

.dropzone {
  display: grid;
  justify-items: center;
  gap: 4px;
  margin-top: 14px;
  padding: 26px 16px;
  border: 1.5px dashed var(--fill-2);
  border-radius: var(--r-lg);
  background: var(--fill);
  text-align: center;
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.25s var(--ease-spring);
}

.dropzone svg {
  margin-bottom: 6px;
  color: var(--accent);
}

.dropzone strong {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}

.dropzone:hover,
.dropzone.dragging {
  border-color: var(--accent);
  background: var(--tint);
}

.dropzone.dragging {
  transform: scale(1.02);
}

.dropzone:focus-within {
  outline: 3px solid var(--tint-strong);
  outline-offset: 2px;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-form {
  margin-top: 16px;
}

.preview {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--fill);
}

.preview h3 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.022em;
  overflow-wrap: anywhere;
}

.preview p {
  font-size: 13px;
  color: var(--ink-2);
}

.form-label {
  display: block;
  margin: 16px 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.optional {
  font-weight: 400;
  color: var(--ink-3);
}

.icon-input {
  width: 100%;
  font-size: 13px;
  color: var(--ink-2);
}

.icon-input::file-selector-button {
  margin-right: 10px;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--fill);
  color: var(--accent);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.upload-form .hint {
  margin-top: 6px;
}

.account-form .form-label:first-child {
  margin-top: 4px;
}

.account-form .hint:not(:empty) {
  margin-top: 8px;
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.account-actions #save-account {
  flex: 1;
}

progress {
  width: 100%;
  height: 6px;
  margin-top: 16px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  appearance: none;
  background: var(--fill);
}

progress::-webkit-progress-bar {
  background: var(--fill);
}

progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}

progress::-moz-progress-bar {
  background: var(--accent);
}

.upload-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.upload-actions #publish {
  flex: 1;
}

#upload-status {
  margin-top: 12px;
}

/* List tools: search + segmented control */

.list-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.list-tools .search {
  flex: 1 1 220px;
}

@media (max-width: 560px) {
  .segmented,
  .account-pick {
    flex: 1 1 100%;
  }
}

.account-pick {
  flex: 0 1 240px;
  min-width: 0;
}

.account-pick:has(select[hidden]) {
  display: none;
}

.account-pick .field {
  min-height: 38px;
  border-radius: var(--r-sm);
  font-size: 15px;
  text-overflow: ellipsis;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 2px;
  border-radius: 9px;
  background: var(--fill);
}

.segment {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.segment[aria-pressed="true"] {
  background: var(--glass-strong);
  font-weight: 600;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}

.segment-count {
  margin-left: 5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* Bulk toolbar: whole-shelf actions until something is selected */

.bulk-toolbar {
  position: sticky;
  top: 62px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 12px;
  padding: 10px 12px 10px 16px;
  border-radius: var(--r-lg);
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.bulk-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bulk-toolbar:not(.has-selection) .bulk-selected,
.bulk-toolbar.has-selection .bulk-all {
  display: none;
}

/* iOS-style round checkbox */

.admin-page input[type="checkbox"] {
  appearance: none;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin: 0;
  border-radius: 50%;
  border: 1.5px solid var(--ink-3);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.admin-page input[type="checkbox"]::before {
  content: "";
  width: 5px;
  height: 10px;
  margin-top: -2px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  rotate: 45deg;
  scale: 0;
  transition: scale 0.25s var(--ease-spring);
}

.admin-page input[type="checkbox"]:checked,
.admin-page input[type="checkbox"]:indeterminate {
  background: var(--accent);
  border-color: var(--accent);
}

.admin-page input[type="checkbox"]:checked::before {
  scale: 1;
}

.admin-page input[type="checkbox"]:indeterminate::before {
  width: 10px;
  height: 0;
  margin: 0;
  border-width: 0 0 2px;
  rotate: 0deg;
  scale: 1;
}

.admin-page input[type="checkbox"]:disabled {
  opacity: 0.4;
  cursor: default;
}

/* App rows: an inset grouped list */

.admin-list {
  border-radius: var(--r-lg);
  overflow: hidden;
}

.admin-list:empty {
  display: none;
}

.app-row-admin {
  position: relative;
  display: grid;
  grid-template-columns: 22px 48px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  transition: background-color 0.2s ease;
}

.app-row-admin + .app-row-admin::before {
  content: "";
  position: absolute;
  top: 0;
  left: 116px;
  right: 0;
  border-top: 0.5px solid var(--sep);
}

.app-row-admin.is-selected {
  background: var(--tint);
}

.app-row-admin .app-icon {
  width: 48px;
  height: 48px;
}

.app-row-admin .icon-fallback {
  font-size: 21px;
}

.app-row-admin.is-off .app-icon {
  opacity: 0.45;
  filter: grayscale(1);
}

.app-info {
  min-width: 0;
}

.app-info h3 {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.022em;
  overflow-wrap: anywhere;
}

.app-info .app-meta {
  white-space: normal;
}

.app-account {
  margin-top: 1px;
  font-size: 12px;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

.app-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 12px;
  font-weight: 500;
  color: var(--green-ink);
}

.app-state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.app-state.off {
  color: var(--ink-3);
}

.rename-field {
  min-height: 36px;
  padding: 0 10px;
  font-size: 17px;
  font-weight: 600;
}

.row-actions {
  display: flex;
  align-items: center;
}

.row-more {
  display: none;
  width: 36px;
  min-height: 36px;
  color: var(--accent);
  background: var(--fill);
}

.row-actions .btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 15px;
  background: transparent;
  color: var(--accent);
}

.row-actions .btn-danger {
  color: var(--red-ink);
}

@media (hover: hover) and (pointer: fine) {
  .row-actions .btn:hover:not(:disabled) {
    background: var(--fill);
  }
}

/* On phones the three row actions collapse into one button that opens an action sheet. */
@media (max-width: 720px) {
  .app-row-admin {
    grid-template-columns: 22px 44px minmax(0, 1fr) 36px;
    gap: 12px;
    padding: 12px 14px;
  }
  .app-row-admin .app-icon {
    width: 44px;
    height: 44px;
  }
  .app-row-admin + .app-row-admin::before {
    left: 104px;
  }
  .row-actions {
    display: none;
  }
  .row-more {
    display: inline-flex;
  }
}

.row-sheet-title {
  margin-bottom: 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
}

.row-sheet-actions {
  display: grid;
  margin-bottom: 10px;
  border-radius: var(--r-md);
  background: var(--fill);
  overflow: hidden;
}

.sheet-action {
  min-height: 52px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 17px;
}

.sheet-action + .sheet-action {
  border-top: 0.5px solid var(--sep);
}

/* The group clips its children, so the focus ring is drawn inside the button. */
.sheet-action:focus-visible {
  outline-offset: -3px;
}

.sheet-action.danger {
  color: var(--red-ink);
}

.sheet-action:active {
  background: var(--fill);
}

.row-sheet-cancel {
  font-weight: 600;
}

.admin-list .empty {
  padding: 48px 20px;
}

.qr-dialog h2 {
  margin-top: 4px;
}
