/**
 * Audit log drawer — full-screen panel (mobile + desktop)
 */

.audit-log-drawer {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  flex-direction: column;
  background: #f1f5f9;
  transform: translateX(100%);
  transition: transform 0.24s ease, visibility 0.24s;
  visibility: hidden;
  pointer-events: none;
}

.audit-log-drawer.is-open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

body.audit-log-drawer-open {
  overflow: hidden;
}

.audit-log-drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.audit-log-back {
  width: 40px;
  height: 40px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  font-size: 1.125rem;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  color: #0f172a;
  flex-shrink: 0;
}

.audit-log-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
  color: #0f172a;
}

.audit-log-filters {
  padding: 8px 10px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.audit-log-period {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 8px;
}

.audit-log-period-btn {
  min-height: 32px;
  padding: 4px 6px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #64748b;
  font-size: 0.6875rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.audit-log-period-btn.active {
  background: var(--accent, #2563eb);
  border-color: var(--accent, #2563eb);
  color: #fff;
}

.audit-log-filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.audit-log-filter-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.625rem;
  font-weight: 600;
  color: #64748b;
  min-width: 0;
}

.audit-log-filter-label select {
  height: 36px;
  min-height: 36px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  padding: 0 8px;
  font-size: 0.75rem;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
}

.audit-log-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px 0;
}

.audit-log-drawer.is-empty .audit-log-scroll {
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
  padding-bottom: 0;
}

.audit-log-drawer.is-empty .audit-log-summary {
  margin-top: 20px;
}

.audit-log-timeline {
  display: flex;
  flex-direction: column;
}

.audit-log-date-divider {
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748b;
  margin: 12px 0 6px;
  padding-left: 22px;
}

.audit-log-date-divider:first-child {
  margin-top: 0;
}

.audit-log-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.audit-log-item:last-child {
  border-bottom: none;
}

.audit-log-item-rail {
  display: flex;
  justify-content: center;
  padding-top: 4px;
}

.audit-log-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  flex-shrink: 0;
}

.audit-log-item-datetime,
.audit-log-item-user,
.audit-log-item-meta,
.audit-log-item-field,
.audit-log-item-change {
  margin: 0;
  line-height: 1.35;
}

.audit-log-item-datetime {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #0f172a;
}

.audit-log-item-user {
  margin-top: 4px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #0f172a;
}

.audit-log-item-meta {
  margin-top: 2px;
  font-size: 0.8125rem;
  color: #64748b;
}

.audit-log-item-field {
  margin-top: 8px;
  font-size: 0.75rem;
  color: #64748b;
}

.audit-log-item-change {
  margin-top: 2px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #0f172a;
}

.audit-log-item-compact {
  display: none;
}

.audit-log-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 16px 4px;
  gap: 6px;
}

.audit-log-empty-icon {
  width: 48px;
  height: 48px;
  color: #94a3b8;
  margin-bottom: 4px;
}

.audit-log-empty-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #0f172a;
}

.audit-log-empty-hint {
  margin: 0;
  font-size: 0.8125rem;
  color: #64748b;
  line-height: 1.45;
  max-width: 280px;
}

.audit-log-loading {
  margin: 0;
  padding: 20px 8px 8px;
  text-align: center;
  font-size: 0.875rem;
  color: #64748b;
}

.audit-log-more {
  width: 100%;
  min-height: 40px;
  margin-top: 8px;
  margin-bottom: 8px;
  border-radius: 10px;
}

.audit-log-more[hidden] {
  display: none !important;
}

.audit-log-summary {
  flex: 0 0 auto;
  flex-shrink: 0;
  padding: 14px 16px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  box-sizing: border-box;
}

.audit-log-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.75rem;
  color: #64748b;
}

.audit-log-summary-row strong {
  color: #0f172a;
  font-size: 0.8125rem;
}

#page-sold .sold-history-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 46px;
  height: 46px;
  padding: 0 10px;
  border-radius: 13px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #0f172a;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  font-family: inherit;
  box-sizing: border-box;
  align-self: end;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#page-sold .sold-history-btn:active {
  background: #f8fafc;
}

#page-sold .sold-history-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: #64748b;
}

@media (max-width: 768px) {
  #page-sold .sold-filter-bar {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 4px;
    align-items: end;
  }

  #page-sold .sold-filter-bar label {
    min-width: 0;
  }

  #page-sold .sold-filter-bar select {
    width: 100%;
    min-height: 46px;
    height: 46px;
    font-size: 0.75rem;
    border-radius: 13px;
  }

  #page-sold .sold-history-btn {
    min-height: 46px;
    height: 46px;
    padding: 0 8px;
    font-size: 0.6875rem;
    border-radius: 13px;
  }

  #page-sold .sold-history-icon {
    width: 15px;
    height: 15px;
  }

  .audit-log-item-datetime,
  .audit-log-item-user,
  .audit-log-item-meta,
  .audit-log-item-field,
  .audit-log-item-change {
    display: none;
  }

  .audit-log-item-compact {
    display: block;
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.4;
    color: #0f172a;
  }

  .audit-log-item-time {
    display: block;
    font-weight: 700;
    font-size: 0.8125rem;
    color: #0f172a;
    margin-bottom: 2px;
  }

  .audit-log-item-action {
    display: block;
    font-weight: 600;
    margin-bottom: 2px;
  }

  .audit-log-item-meta-inline {
    display: block;
    font-size: 0.8125rem;
    color: #64748b;
    margin-bottom: 2px;
  }

  .audit-log-item-change-inline {
    display: block;
    font-weight: 600;
    font-size: 0.9375rem;
  }
}

@media (min-width: 769px) {
  #page-sold .sold-filter-bar {
    grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) auto auto;
  }

  #page-sold .sold-filter-actions {
    display: flex;
    gap: 6px;
    align-items: flex-end;
  }
}
