/* AIBuy report sheet — X-style two-step flow. Loaded last among report styles. */

.aibuy-sheet {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100% - 32px));
  max-height: min(var(--sheet-max, calc(100dvh - 24px)), 680px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--ui-line, #d7e1da);
  border-radius: 16px;
  background: var(--ui-surface, #fff);
  color: var(--ui-text, #23392d);
  box-shadow: 0 18px 50px #12271e33;
}

.aibuy-sheet::backdrop,
.aibuy-sheet-backdrop {
  background: #10271e66;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.aibuy-sheet[open],
.aibuy-sheet-overlay.is-open .aibuy-sheet {
  animation: aibuy-sheet-in .2s ease-out;
}

.aibuy-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #10271e66;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.aibuy-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: none;
  padding: 12px 16px 10px;
}

.aibuy-sheet-header.is-report {
  display: grid;
  grid-template-columns: 32px 1fr 32px;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
}

.aibuy-sheet-header h2,
.aibuy-sheet-header h3 {
  margin: 0;
  color: var(--ui-text, #23392d);
  font-size: 16px;
  line-height: 1.35;
  font-weight: 650;
}

.aibuy-sheet-header.is-report h2 {
  text-align: center;
}

.aibuy-sheet-header-slot {
  width: 32px;
  height: 32px;
}

.aibuy-sheet-close,
.aibuy-sheet-back {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ui-muted, #62766a);
  cursor: pointer;
}

.aibuy-sheet-close:hover:not(:disabled),
.aibuy-sheet-back:hover:not(:disabled) {
  background: var(--ui-secondary, #edf3ef);
  color: var(--ui-text, #23392d);
}

.aibuy-sheet-close:disabled,
.aibuy-sheet-back:disabled {
  opacity: .5;
  cursor: default;
}

.aibuy-sheet-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
}

.aibuy-sheet-stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.aibuy-sheet-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 16px 16px;
  -webkit-overflow-scrolling: touch;
}

.aibuy-sheet.is-report .aibuy-sheet-scroll {
  animation: aibuy-sheet-pane 220ms ease;
}

.aibuy-sheet.is-report .aibuy-sheet-scroll[data-dir="back"] {
  animation-name: aibuy-sheet-pane-back;
}

.aibuy-sheet-footer {
  flex: 0 0 auto;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--ui-surface, #fff);
  box-shadow: 0 -1px 0 var(--ui-line, #d7e1da);
}

.aibuy-sheet-target,
.aibuy-sheet-preview,
.aibuy-sheet-hint,
.aibuy-sheet-picked,
.aibuy-sheet-note-label {
  margin: 0;
  color: var(--ui-muted, #62766a);
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.aibuy-sheet-picked {
  margin: 0 0 10px;
  color: var(--ui-text, #23392d);
  font-size: 14px;
  font-weight: 600;
}

.aibuy-sheet-note-label {
  display: block;
  margin: 0 0 6px;
  font-size: 13px;
}

.aibuy-sheet-target strong {
  font-weight: 600;
  color: var(--ui-text, #23392d);
}

.aibuy-sheet-preview {
  max-height: 88px;
  margin-bottom: 10px;
  padding: 10px 12px;
  overflow: auto;
  border: 1px solid var(--ui-line, #d7e1da);
  border-radius: 10px;
  background: var(--ui-surface-raised, #f0f5f1);
}

.aibuy-sheet-preview strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ui-text, #23392d);
  font-size: 13px;
  font-weight: 600;
}

.aibuy-sheet-preview p {
  margin: 0;
  white-space: pre-wrap;
  color: var(--ui-muted, #62766a);
  font-size: 12px;
  line-height: 1.55;
}

.aibuy-sheet-reasons {
  display: grid;
  gap: 0;
}

.aibuy-sheet.is-report .aibuy-sheet-reason {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0 2px 0 4px;
  border: 0;
  border-bottom: 1px solid var(--ui-line, #d7e1da);
  border-radius: 0;
  background: transparent;
  color: var(--ui-text, #23392d);
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

.aibuy-sheet.is-report .aibuy-sheet-reason:last-child {
  border-bottom: 0;
}

.aibuy-sheet.is-report .aibuy-sheet-reason:hover:not(:disabled) {
  background: var(--ui-secondary, #edf3ef);
}

.aibuy-sheet.is-report .aibuy-sheet-reason.is-selected {
  background: var(--ui-accent-soft, #e3efe7);
}

.aibuy-sheet-reason-chevron {
  display: grid;
  flex: none;
  place-items: center;
  width: 18px;
  height: 18px;
  color: var(--ui-muted, #62766a);
}

.aibuy-sheet-reason-chevron svg {
  width: 16px;
  height: 16px;
}

.aibuy-sheet:not(.is-report) .aibuy-sheet-reasons {
  display: grid;
  gap: 6px;
}

.aibuy-sheet:not(.is-report) .aibuy-sheet-reason {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--ui-line, #d7e1da);
  border-radius: 10px;
  background: var(--ui-surface, #fff);
  color: var(--ui-text, #23392d);
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

.aibuy-sheet:not(.is-report) .aibuy-sheet-reason:hover:not(:disabled) {
  background: var(--ui-secondary, #edf3ef);
}

.aibuy-sheet:not(.is-report) .aibuy-sheet-reason.is-selected {
  border-color: var(--ui-primary, #2e6b50);
  background: var(--ui-accent-soft, #e3efe7);
}

.aibuy-sheet-reason:disabled {
  opacity: .6;
  cursor: default;
}

.aibuy-sheet-reason-mark {
  flex: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid #b7c6bc;
  border-radius: 99px;
  background: transparent;
  box-sizing: border-box;
}

.aibuy-sheet-reason.is-selected .aibuy-sheet-reason-mark {
  border-color: var(--ui-primary, #2e6b50);
  background: var(--ui-primary, #2e6b50);
  box-shadow: inset 0 0 0 3px var(--ui-accent-soft, #e3efe7);
}

.aibuy-sheet-note {
  display: grid;
  gap: 4px;
}

.aibuy-sheet textarea {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 96px;
  max-height: min(160px, 28vh);
  margin: 0;
  padding: 10px 12px;
  overflow-y: auto;
  border: 1px solid var(--ui-line, #d7e1da);
  border-radius: 10px;
  background: var(--ui-field, #fff);
  color: var(--ui-text, #23392d);
  font: inherit;
  font-size: 13px;
  line-height: 1.55;
  resize: none;
  field-sizing: fixed;
}

.aibuy-sheet textarea:focus {
  outline: 2px solid var(--ui-focus, #397c5b);
  outline-offset: 1px;
}

.aibuy-sheet-count {
  color: var(--ui-muted, #62766a);
  font-size: 11px;
  text-align: right;
}

.aibuy-sheet-error {
  margin: 0 0 8px;
  color: #b64e3b;
  font-size: 12px;
  line-height: 1.5;
}

.aibuy-sheet-error-inline {
  margin: 0 16px 12px;
}

.aibuy-sheet-submit,
.aibuy-sheet-submit-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 42px;
  margin: 0;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--ui-primary, #2e6b50);
  color: var(--ui-on-primary, #fff);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.aibuy-sheet-submit:hover:not(:disabled) {
  background: var(--ui-primary-hover, #25583f);
}

.aibuy-sheet-submit-danger {
  background: #c2473a;
}

.aibuy-sheet-submit-danger:hover:not(:disabled) {
  background: #a83b30;
}

.aibuy-sheet-submit:disabled,
.aibuy-sheet-submit-danger:disabled {
  opacity: .6;
  cursor: wait;
}

.aibuy-sheet :is(button, textarea, [role="radio"]):focus-visible {
  outline: 2px solid var(--ui-focus, #397c5b);
  outline-offset: 2px;
}

@keyframes aibuy-sheet-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes aibuy-sheet-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes aibuy-sheet-pane {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes aibuy-sheet-pane-back {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 700px) {
  .aibuy-sheet-overlay {
    align-items: end;
    padding: 0;
    background: #10271e59;
  }

  .aibuy-sheet,
  .aibuy-sheet-overlay .aibuy-sheet {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: 100%;
    margin: 0;
    max-height: var(--sheet-max, 100dvh);
    border-radius: 16px 16px 0 0;
    overflow: hidden;
  }

  .aibuy-sheet[open],
  .aibuy-sheet-overlay.is-open .aibuy-sheet {
    animation: aibuy-sheet-up .22s ease-out;
  }
}

@media (prefers-reduced-motion: reduce) {
  .aibuy-sheet[open],
  .aibuy-sheet-overlay.is-open .aibuy-sheet,
  .aibuy-sheet.is-report .aibuy-sheet-scroll {
    animation: none;
  }
  .aibuy-sheet {
    transition: none !important;
  }
}

html[data-theme="dark"] .aibuy-sheet {
  border-color: #3b5456;
  background: #1b2b2c;
  color: #e3efed;
  box-shadow: 0 18px 50px #0006;
}

html[data-theme="dark"] .aibuy-sheet-footer {
  background: #1b2b2c;
  box-shadow: 0 -1px 0 #3b5456;
}

html[data-theme="dark"] .aibuy-sheet-header h2,
html[data-theme="dark"] .aibuy-sheet-header h3,
html[data-theme="dark"] .aibuy-sheet-target strong,
html[data-theme="dark"] .aibuy-sheet-preview strong,
html[data-theme="dark"] .aibuy-sheet-reason,
html[data-theme="dark"] .aibuy-sheet-picked {
  color: #e3efed;
}

html[data-theme="dark"] .aibuy-sheet.is-report .aibuy-sheet-reason {
  border-bottom-color: #3b5456;
}

html[data-theme="dark"] .aibuy-sheet.is-report .aibuy-sheet-reason:hover:not(:disabled),
html[data-theme="dark"] .aibuy-sheet-close:hover:not(:disabled),
html[data-theme="dark"] .aibuy-sheet-back:hover:not(:disabled) {
  background: #243738;
  color: #e3efed;
}

html[data-theme="dark"] .aibuy-sheet.is-report .aibuy-sheet-reason.is-selected {
  background: #244236;
}

html[data-theme="dark"] .aibuy-sheet:not(.is-report) .aibuy-sheet-reason {
  border-color: #3b5456;
  background: #1b2b2c;
}

html[data-theme="dark"] .aibuy-sheet:not(.is-report) .aibuy-sheet-reason:hover:not(:disabled) {
  background: #243738;
}

html[data-theme="dark"] .aibuy-sheet:not(.is-report) .aibuy-sheet-reason.is-selected {
  border-color: #7dba98;
  background: #244236;
}

html[data-theme="dark"] .aibuy-sheet-preview,
html[data-theme="dark"] .aibuy-sheet textarea {
  border-color: #3b5456;
  background: #223536;
  color: #cadfdf;
}

html[data-theme="dark"] .aibuy-sheet::backdrop,
html[data-theme="dark"] .aibuy-sheet-overlay,
html[data-theme="dark"] .aibuy-sheet-backdrop {
  background: #0000008c;
}
