/* PermissionCard — Queue + Tool Preview + Feedback + Actions */

.perm-card {
  --perm-accent: var(--island-warning);
  --perm-panel: var(--island-bg);
  --perm-command-bg: color-mix(in srgb, var(--island-card) 82%, var(--perm-accent) 8%);
  --perm-command-border: color-mix(in srgb, var(--island-border) 78%, var(--perm-accent) 22%);
  --perm-text: var(--island-text);
  --perm-text-secondary: var(--island-text-secondary);
  min-height: 0;
}

.overlay-card.overlay-card--permission {
  --perm-accent: var(--island-warning);
  --perm-panel: var(--island-bg);
  --perm-command-bg: color-mix(in srgb, var(--island-card) 82%, var(--perm-accent) 8%);
  --perm-command-border: color-mix(in srgb, var(--island-border) 78%, var(--perm-accent) 22%);
  --perm-text: var(--island-text);
  --perm-text-secondary: var(--island-text-secondary);
  --approval-context-font-size: 12px;
  --approval-context-line-height: 1.18;
  --approval-meta-font-size: 11px;
  --approval-meta-line-height: 1.28;
  --approval-title-font-size: 13px;
  --approval-title-line-height: 1.18;
  --approval-body-font-size: 12px;
  --approval-body-line-height: 1.4;
  --approval-caption-font-size: 11px;
  --approval-control-font-size: 12px;
  gap: 9px;
  width: 100%;
  min-height: 0;
  padding: 12px 16px 14px;
  border: 0;
  border-radius: 0 0 26px 26px;
  background: var(--perm-panel);
  box-shadow: none;
}

.overlay-card.overlay-card--permission-compact {
  gap: 8px;
  padding: 11px 16px 12px;
}

.overlay-card--permission .overlay-card__header {
  align-items: flex-start;
  min-height: 34px;
}

.overlay-card--permission-compact .overlay-card__header {
  min-height: 30px;
}

.overlay-card--permission .overlay-card__close {
  display: none;
}

.overlay-card--permission .overlay-ctx {
  gap: 2px;
}

.overlay-card--permission .overlay-ctx__row1 {
  gap: 7px;
  font-size: var(--approval-context-font-size);
  font-weight: 800;
  line-height: var(--approval-context-line-height);
  color: var(--perm-text);
}

.overlay-card--permission .overlay-ctx__row1 .pixel-indicator {
  margin-right: 3px;
  transform: scale(1.45);
  transform-origin: center;
}

.overlay-card--permission .overlay-ctx__sep,
.overlay-card--permission .overlay-ctx__agent {
  color: var(--island-text-secondary);
  opacity: 1;
}

.overlay-card--permission .overlay-ctx__row2 {
  gap: 4px;
  font-size: var(--approval-meta-font-size);
  font-weight: 700;
  line-height: var(--approval-meta-line-height);
  color: var(--island-text-muted);
}

.overlay-card--permission .overlay-ctx__you {
  color: var(--island-text-secondary);
  font-weight: 800;
}

.overlay-card--permission .overlay-ctx__msg {
  max-width: 430px;
}

.perm-card__scroll {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 9px;
  min-height: 0;
  padding-right: 2px;
  overflow-y: auto;
}

.overlay-card--permission-compact .perm-card__scroll {
  flex: 0 1 auto;
  gap: 8px;
  overflow: visible;
}

.perm-card__scroll::-webkit-scrollbar {
  width: 4px;
}

.perm-card__scroll::-webkit-scrollbar-thumb {
  background: var(--island-scrollbar, rgba(255, 255, 255, 0.15));
  border-radius: 999px;
}

.perm-card__queue {
  flex: 0 0 auto;
}

.perm-card__queue-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.perm-card__queue-text {
  font-size: 10px;
  color: var(--island-text-muted);
}

.perm-card__queue-bar {
  height: 2px;
  width: 100%;
  border-radius: 9999px;
  background: var(--island-btn-bg, rgba(255, 255, 255, 0.08));
}

.perm-card__queue-fill {
  height: 100%;
  border-radius: 9999px;
  background: rgba(245, 158, 11, 0.6);
  transition: width 0.2s;
}

.perm-card__tool-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 0;
}

.perm-card__tool-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 0;
  background: transparent;
  flex-shrink: 0;
}

.perm-card__tool-icon-svg {
  color: var(--perm-accent);
  width: 20px;
  height: 20px;
  fill: currentColor;
  stroke: var(--perm-panel);
}

.perm-card__tool-name {
  color: var(--perm-accent);
  font-size: var(--approval-title-font-size);
  font-weight: 800;
  line-height: var(--approval-title-line-height);
}

/* Detail box */
.perm-card__detail-box {
  background: var(--perm-command-bg);
  border: 1px solid var(--perm-command-border);
  border-radius: 10px;
  padding: 9px 10px 8px;
  flex: 0 0 auto;
  max-height: 250px;
  overflow-y: auto;
}

.overlay-card--permission-compact .perm-card__detail-box {
  max-height: 128px;
  padding: 8px 10px;
  overflow: hidden;
}

.perm-card__detail-tool-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--island-success-text);
  margin-bottom: 6px;
}

/* Tool previews */
.perm-card__preview-desc {
  font-size: var(--approval-caption-font-size);
  font-weight: 650;
  line-height: var(--approval-meta-line-height);
  color: var(--perm-text-secondary);
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.perm-card__preview-code {
  max-height: 230px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  border-radius: 9px;
  background: var(--island-code-block-bg, var(--island-code-bg));
  border: 1px solid var(--island-code-border);
  padding: 10px 12px;
  font-family: var(--font-mono, monospace);
  font-size: 11.5px;
  font-weight: 560;
  line-height: 1.48;
  color: var(--island-code-text);
  margin: 0;
}

.perm-card__preview-code--bash {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: var(--approval-body-font-size);
  font-weight: 650;
  line-height: var(--approval-body-line-height);
}

.perm-card__preview-command {
  max-height: 180px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: var(--font-mono, monospace);
  font-size: var(--approval-body-font-size);
  font-weight: 650;
  line-height: var(--approval-body-line-height);
  color: var(--perm-text);
  margin: 0;
}

.overlay-card--permission-compact .perm-card__preview-command {
  max-height: 68px;
  overflow: hidden;
}

.overlay-card--permission-compact .perm-card__preview-desc {
  margin-top: 4px;
}

.perm-card__preview-command {
  display: block;
}

.perm-card__preview-prompt {
  color: var(--island-warning-text);
  margin-right: 7px;
}

.perm-card__preview-file {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--approval-caption-font-size);
  color: var(--perm-text-secondary);
}

.perm-card__preview-path {
  font-family: var(--font-mono, monospace);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.perm-card__preview-new-badge {
  font-size: 9px;
  font-weight: 500;
  color: var(--island-success-text);
  background: var(--island-success-bg);
  border-radius: 4px;
  padding: 1px 6px;
  flex-shrink: 0;
}

.perm-card__preview-pattern {
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  background: var(--island-inline-code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--island-inline-code-text);
}

.perm-card__preview-diff {
  max-height: 180px;
  overflow-y: auto;
  border-radius: 6px;
  background: var(--island-code-block-bg, var(--island-code-bg));
  padding: 8px;
  font-family: var(--font-mono, monospace);
  font-size: 10.5px;
  line-height: 1.46;
}

.perm-card__preview-diff--remove {
  color: var(--island-danger-text);
}

.perm-card__preview-diff--add {
  color: var(--island-success-text);
  margin-top: 4px;
}

.perm-card__preview-more {
  font-size: 9px;
  color: var(--perm-text-secondary);
  margin-top: 4px;
}

.perm-card__preview-kv {
  border-radius: 6px;
  background: var(--island-code-block-bg, var(--island-code-bg));
  padding: 8px;
  font-size: 10.5px;
  line-height: 1.46;
}

.perm-card__preview-kv-row {
  display: flex;
  gap: 6px;
  color: var(--perm-text);
}

.perm-card__preview-kv-key {
  flex-shrink: 0;
  color: var(--perm-text-secondary);
}

.perm-card__preview-kv-val {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Diff view */
.perm-card__diff {
  flex: 1 1 auto;
  min-height: 120px;
  max-height: 280px;
  overflow-y: auto;
  border-radius: 6px;
}

.perm-card__diff .diff-view {
  margin: 0;
}

/* Feedback */
.perm-card__feedback {
  flex: 0 0 auto;
  margin-top: 2px;
}

.perm-card__feedback-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--island-card);
  border: 1px solid var(--island-border);
  border-radius: 8px;
  color: var(--island-text);
  font-family: var(--font-sans, system-ui);
  font-size: 11px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.perm-card__feedback-input::placeholder {
  color: var(--island-text-muted);
}

.perm-card__feedback-input:focus {
  border-color: rgba(245, 158, 11, 0.5);
}

.perm-card__feedback-input[data-has-draft="true"] {
  border-color: rgba(245, 158, 11, 0.72);
  background:
    linear-gradient(90deg, rgba(245, 158, 11, 0.95) 0 3px, transparent 3px),
    var(--island-card);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.18);
}

/* Actions */
.perm-card__actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: stretch;
  margin-top: 2px;
}

.perm-card__actions--compact {
  justify-content: flex-end;
  padding-top: 5px;
  border-top: 1px solid var(--perm-command-border);
}

.perm-card__actions--compact.perm-card__actions--two .perm-card__btn {
  flex: 0 1 190px;
}

.perm-card__actions--compact.perm-card__actions--two .perm-card__btn--allow {
  flex-basis: 210px;
}

.perm-card__btn {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--island-action-neutral-border);
  border-radius: 8px;
  background: var(--island-action-neutral-bg);
  color: var(--island-action-neutral-text);
  font-family: var(--font-sans, system-ui);
  font-size: var(--approval-control-font-size);
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--island-card) 70%, transparent);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease, filter 0.15s ease;
  white-space: nowrap;
}

.perm-card__btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.perm-card__btn--deny {
  border-color: var(--island-action-deny-border);
  background: var(--island-action-deny-bg);
  color: var(--island-action-deny-text);
}

.perm-card__btn--allow {
  border-color: var(--island-action-allow-border);
  background: var(--island-action-allow-bg);
  color: var(--island-action-allow-text);
}

.perm-card__btn--always {
  border-color: var(--island-action-always-border);
  background: var(--island-action-always-bg);
  color: var(--island-action-always-text);
}

.perm-card__btn--auto {
  border-color: var(--island-action-auto-border);
  background: var(--island-action-auto-bg);
  color: var(--island-action-auto-text);
}

.perm-card__btn--deny:hover {
  background: var(--island-action-deny-bg-hover);
}

.perm-card__btn--allow:hover {
  background: var(--island-action-allow-bg-hover);
}

.perm-card__btn--always:hover {
  background: var(--island-action-always-bg-hover);
}

.perm-card__btn--auto:hover {
  background: var(--island-action-auto-bg-hover);
}

.perm-card__kbd {
  margin-left: 4px;
  font-size: 10px;
  color: inherit;
  opacity: 0.48;
  font-family: var(--font-mono, monospace);
  font-weight: 800;
}


@media (max-width: 760px) {
  .overlay-card.overlay-card--permission {
    padding: 12px 14px 14px;
  }

  .overlay-card--permission .overlay-ctx__row1 {
    font-size: 12px;
  }

  .overlay-card--permission .overlay-ctx__row2,
  .perm-card__preview-desc {
    font-size: 11px;
  }

  .perm-card__tool-name,
  .perm-card__preview-code--bash,
  .perm-card__preview-command {
    font-size: 12px;
  }

  .perm-card__actions {
    gap: 8px;
  }

  .perm-card__btn {
    height: 30px;
    padding: 0 7px;
    font-size: 12px;
    border-radius: 8px;
  }

  .perm-card__actions--compact.perm-card__actions--two .perm-card__btn,
  .perm-card__actions--compact.perm-card__actions--two .perm-card__btn--allow {
    flex: 1 1 0;
  }

  .perm-card__kbd {
    display: none;
  }
}
