/* Share links, access rules and link analytics. */

/* Access choice cards */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.choice {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 11px 32px 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.12s var(--ease-out);
}

.choice:active {
  transform: scale(0.99);
}

.choice.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

.choice svg {
  margin-bottom: 3px;
  color: var(--muted);
}

.choice.active svg {
  color: var(--brand);
}

.choice-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.choice-desc {
  font-size: 12px;
  line-height: 1.4;
}

.choice-mark {
  position: absolute;
  top: 10px;
  right: 10px;
  display: none;
  color: var(--brand);
}

.choice.active .choice-mark {
  display: inline-flex;
}

.toggle-stack {
  border-top: 1px solid var(--line);
}

/* Link list */
.links-toolbar .search-box {
  flex: 1 1 240px;
  max-width: 380px;
}

.links-toolbar .search-box .input {
  padding-right: 40px;
}

.links-toolbar .search-box .input::-webkit-search-cancel-button {
  display: none;
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  transform: translateY(-50%);
}

.search-clear::before {
  content: "";
  position: absolute;
  inset: -4px;
}

.search-box .search-clear svg {
  position: static;
  width: 14px;
  height: 14px;
  color: var(--muted);
  transform: none;
}

.filter-count {
  margin-left: 6px;
  color: var(--muted-light);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.filter-chip.active .filter-count {
  color: rgba(255, 255, 255, 0.72);
}

.links-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.links-summary {
  color: var(--muted);
  font-size: 12px;
}

.links-table td {
  vertical-align: top;
}

.links-table .cell-primary {
  min-width: 180px;
}

.links-table .actions-cell {
  width: 1%;
  text-align: right;
}

.links-table .link-name {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.links-table .link-name .panel-title {
  max-width: 230px;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.links-table .link-token {
  color: var(--muted-light);
  font-size: 12px;
}

.link-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.link-tag {
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
}

.recipient-cell {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.recipient-email {
  display: block;
  max-width: 190px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipient-more {
  color: var(--muted);
  font-size: 12px;
}

.space-link {
  display: inline-block;
  max-width: 160px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

.status-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.status-note {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.engagement {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 7px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.engagement strong {
  color: var(--ink-soft);
  font-weight: 600;
}

.eng-sep {
  color: var(--muted-light);
}

.last-viewed {
  color: var(--ink-soft);
  font-size: 12px;
  white-space: nowrap;
}

.last-viewed.is-empty {
  color: var(--muted-light);
}

.link-row-actions {
  display: flex;
  max-width: 230px;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin-left: auto;
}

.link-row-actions .btn {
  flex: none;
}

/* Link detail */
.link-page .breadcrumb {
  flex-wrap: wrap;
}

.link-page .breadcrumb span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.link-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.link-head-main {
  min-width: 0;
}

.link-head h1 {
  overflow-wrap: anywhere;
}

.link-head-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 7px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
}

.link-head-meta a {
  color: var(--brand-ink);
}

.link-head-recipient {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-dot {
  color: var(--muted-light);
}

.link-head-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.link-expiry {
  color: var(--muted);
  font-size: 12px;
}

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

.link-head-actions .btn,
.link-head-actions .btn-sm {
  height: 38px;
}

.link-banner-space {
  display: none;
}

.link-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid;
  border-radius: 12px;
}

.link-banner .grow {
  min-width: 0;
}

.link-banner-title {
  font-size: 13px;
  font-weight: 600;
}

.link-banner p {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.5;
}

.link-banner-danger {
  border-color: var(--red-line);
  background: var(--red-soft);
  color: var(--red-ink);
}

.link-banner-warning {
  border-color: var(--amber-line);
  background: var(--amber-soft);
  color: var(--amber);
}

.link-banner .btn {
  flex: none;
}

.link-banner-icon {
  display: inline-flex;
  width: 30px;
  height: 30px;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.65);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px 18px;
}

.info-grid.single {
  grid-template-columns: minmax(0, 1fr);
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.info-label {
  color: var(--muted-light);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.info-value {
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.linkish {
  color: var(--brand-ink);
}

.email-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.email-list .tag {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-field {
  margin-top: 16px;
}

.access-share-field {
  margin-top: 0;
  margin-bottom: 16px;
}

.share-url-input {
  font-size: 13px;
}

.access-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

#access-rules {
  scroll-margin-top: 78px;
}

.access-edit .input,
.access-edit .choice {
  scroll-margin-top: 84px;
}

.access-head .section-title {
  margin-bottom: 0;
}

.access-edit {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.access-edit .form-grid {
  gap: 12px;
}

.access-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.date-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.date-row .input {
  flex: 1;
  min-width: 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: var(--muted);
  font-size: 12px;
}

.check-row input {
  width: 16px;
  height: 16px;
  flex: none;
  accent-color: var(--brand);
}

.form-error-hint {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  opacity: 0.85;
}

/* Email chips and entry */
.email-editor {
  display: flex;
  min-height: 40px;
  flex-direction: column;
  gap: 7px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.email-editor:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.email-editor.invalid {
  border-color: var(--red);
}

.email-editor.invalid:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

.email-editor .email-chips {
  margin-top: 0;
}

.email-chip {
  display: inline-flex;
  max-width: 100%;
  height: 26px;
  align-items: center;
  gap: 4px;
  padding: 0 4px 0 8px;
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 12px;
}

.email-chip-text {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-chip button {
  position: relative;
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: currentColor;
  opacity: 0.65;
}

.email-chip button::before {
  content: "";
  position: absolute;
  inset: -4px;
}

.email-entry {
  display: flex;
  align-items: center;
  gap: 6px;
}

.email-input {
  height: 30px;
  flex: 1;
  min-width: 0;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  outline: none;
}

.email-input::placeholder {
  color: var(--muted-light);
}

.email-entry .btn {
  flex: none;
}

/* Visitors table */
.visitor-cell {
  min-width: 0;
}

.visitor-identity {
  min-width: 0;
}

.visitor-email {
  max-width: 260px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visitors-table td {
  vertical-align: middle;
}

/* Secondary text inside this surface stays at 12px or larger. */
.links-table th,
.visitors-table th {
  font-size: 12px;
}

.links-page .badge,
.link-page .badge {
  height: 22px;
  font-size: 12px;
}

.link-page .event-title {
  font-size: 13px;
}

.link-page .event-meta,
.link-page .event-agent {
  font-size: 12px;
}

.link-page .doc-cell .sub {
  font-size: 12px;
}

.link-page .avatar {
  font-size: 12px;
}

.email-list .tag {
  font-size: 12px;
}

/* Hover states */
@media (hover: hover) and (pointer: fine) {
  .choice:hover {
    border-color: var(--brand);
  }

  .links-table .link-name:hover .panel-title {
    color: var(--brand-ink);
  }

  .links-table .space-link:hover {
    color: var(--brand-ink);
    text-decoration: underline;
  }

  .email-chip button:hover {
    background: var(--brand-soft);
    opacity: 1;
  }

  .linkish:hover {
    text-decoration: underline;
  }

  .link-head-meta a:hover {
    text-decoration: underline;
  }
}

/* Responsive */
@media (max-width: 860px) {
  .links-table thead {
    display: none;
  }

  .links-table,
  .links-table tbody,
  .links-table tr,
  .links-table td {
    display: block;
    width: 100%;
  }

  .links-table tr {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
  }

  .links-table tr:last-child {
    border-bottom: 0;
  }

  .links-table td {
    padding: 0;
    border: 0;
  }

  .links-table td.actions-cell {
    width: auto;
  }

  .links-table td + td {
    margin-top: 8px;
  }

  .links-table td[data-label] {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
  }

  .links-table td[data-label]::before {
    content: attr(data-label);
    padding-top: 1px;
    color: var(--muted-light);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .links-table .recipient-email,
  .links-table .space-link,
  .links-table .link-name .panel-title,
  .link-head-recipient {
    max-width: 100%;
  }

  .links-table .space-link {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
  }

  .status-note,
  .last-viewed,
  .engagement {
    white-space: normal;
  }

  .link-row-actions {
    max-width: none;
    justify-content: flex-start;
    margin-top: 12px;
    margin-left: 0;
  }

  .link-row-actions .btn {
    min-height: 40px;
  }

  .toggle-row .switch::before {
    content: "";
    position: absolute;
    inset: -9px;
  }

  .email-add,
  .date-row .btn,
  .access-head .btn {
    min-height: 40px;
  }

  .email-input {
    height: 40px;
  }

  .email-chip {
    height: 40px;
    padding-right: 0;
  }

  .email-chip button {
    width: 40px;
    height: 40px;
  }

  .links-page .notice .icon-btn,
  .link-page .notice .icon-btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
  }

  .links-page .notice {
    flex-wrap: wrap;
  }

  .links-page .notice .btn {
    min-height: 40px;
  }

  .links-toolbar .filter-chip {
    min-height: 40px;
  }

  .link-head {
    flex-direction: column;
    gap: 14px;
  }

  .link-head-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .link-head-actions .btn,
  .link-head-actions .btn-sm {
    min-height: 40px;
  }

  .link-banner {
    flex-wrap: wrap;
  }

  .link-banner .btn {
    width: 100%;
    min-height: 40px;
  }
}

@media (max-width: 760px) {
  .visitors-table thead {
    display: none;
  }

  .visitors-table,
  .visitors-table tbody,
  .visitors-table tr,
  .visitors-table td {
    display: block;
    width: 100%;
  }

  .visitors-table tr {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
  }

  .visitors-table tr:last-child {
    border-bottom: 0;
  }

  .visitors-table td {
    padding: 0;
    border: 0;
  }

  .visitors-table td + td {
    margin-top: 6px;
  }

  .visitors-table td[data-label] {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
  }

  .visitors-table td[data-label]::before {
    content: attr(data-label);
    color: var(--muted-light);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .visitor-email {
    max-width: 100%;
  }

  .access-card .info-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .links-toolbar .search-box {
    max-width: none;
    flex-basis: 100%;
  }

  .link-head h1 {
    font-size: 22px;
  }
}

@media (max-width: 560px) {
  .link-form .choice-grid,
  .access-edit .choice-grid,
  .link-form .form-grid,
  .access-edit .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .link-form .modal-footer,
  .link-success-actions,
  .access-actions {
    flex-wrap: wrap;
  }

  .link-form .modal-footer .btn,
  .link-success-actions .btn,
  .access-actions .btn {
    flex: 1 1 auto;
    min-height: 40px;
  }

  .email-chip-text {
    max-width: 160px;
  }

  .link-head-actions .btn,
  .link-head-actions .btn-sm {
    flex: 1 1 auto;
  }
}

@media (max-width: 480px) {
  .share-field .copy-field {
    flex-wrap: wrap;
  }

  .share-field .copy-field .input {
    flex-basis: 100%;
  }

  .share-field .copy-field .btn {
    width: 100%;
    min-height: 40px;
  }

  .link-form .copy-field .btn {
    min-height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .choice,
  .email-editor {
    transition: none;
  }

  .choice:active {
    transform: none;
  }
}
