.approvalCard {
  background: #ffffff;
  border: 1px solid #e8ecf1;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  /* Fade in + slide up animation */
  animation: fadeInSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);

  &:hover {
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.1);
  }

  :global(.ant-card-body) {
    padding: 16px 20px;
  }
}

@keyframes fadeInSlideUp {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Fade out animation for removal */
.approvalCardExit {
  animation: fadeOutSlideDown 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards;
}

@keyframes fadeOutSlideDown {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
}

.header {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: space-between;

  .titleRow {
    flex: 1;
    display: flex;
    align-items: center;
  }

  .icon {
    color: #f97316;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .title {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
  }

  .timer {
    background: #f7f8fa;
    border-radius: 14px;
    padding: 2px 10px;
    display: flex;
    align-items: center;
    gap: 4px;

    .timerIcon {
      color: #94a3b8;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .timerText {
      font-size: 12px;
      font-weight: 500;
      color: #64748b;
      font-family: "SF Mono", "Monaco", "Consolas", monospace;
    }
  }
}

.content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.infoRow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.label {
  font-size: 12px;
  color: #8c8c8c;
  font-weight: 400;
  min-width: 56px;
  flex-shrink: 0;
}

.value {
  font-size: 13px;
  color: #1a1a1a;
  font-weight: 500;

  &:global(.ant-typography) code {
    background: #f5f7fa;
    border: 1px solid #e8ecf1;
    border-radius: 4px;
    padding: 1px 8px;
    font-size: 12px;
    color: #333;
    font-family: "SF Mono", "Monaco", "Consolas", monospace;
  }
}

.scopeSection {
  background: #fafbfc;
  border: 1px solid #eef0f3;
  border-radius: 6px;
  padding: 12px 14px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scopeLabel {
  font-size: 12px;
  color: #8c8c8c;
  font-weight: 500;
}

.scopeItems {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scopeItem {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scopeItemLabel {
  font-size: 12px;
  color: #555;
  font-weight: 500;
}

.scopeCode {
  background: #ffffff;
  border: 1px solid #e8ecf1;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  color: #333;
  font-family: "SF Mono", "Monaco", "Consolas", monospace;
  word-break: break-all;
  display: block;
  line-height: 1.5;
}

.severityTag {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 4px;
  border: none;
  letter-spacing: 0.02em;
  line-height: 20px;
}

.crossSessionTag {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 8px;
  border-radius: 4px;
  border: none;
  letter-spacing: 0.02em;
  line-height: 20px;
}

.ownerAgentTag {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 8px;
  border-radius: 4px;
  border: none;
  letter-spacing: 0.02em;
  line-height: 20px;
}

.summaryBox {
  background: #fafbfc;
  border-left: 2px solid #d4d9e1;
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
  margin-top: 4px;
  position: relative;

  .summaryText {
    font-size: 12px;
    color: #555;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    padding-right: 28px;
  }
}

.copyButton {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: #888;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;

  &:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: #ccc;
    color: #555;
  }

  &.copied {
    color: #52c41a;
    border-color: #b7eb8f;
  }
}

.paramsCodeWrapper {
  position: relative;
}

.paramsDetails {
  background: #fafbfc;
  border: 1px solid #eef0f3;
  padding: 10px 14px;
  border-radius: 6px;
  margin-top: 4px;
  cursor: pointer;

  summary {
    font-size: 12px;
    font-weight: 500;
    color: #666;
    user-select: none;
    outline: none;
    transition: color 0.2s;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;

    &::before {
      content: "▶";
      font-size: 8px;
      color: #999;
      transition: transform 0.2s ease;
      display: inline-block;
      flex-shrink: 0;
    }

    // Hide default marker in Safari/WebKit
    &::-webkit-details-marker {
      display: none;
    }

    &:hover {
      color: #333;
    }
  }

  &[open] summary {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eef0f3;
    color: #333;

    &::before {
      transform: rotate(90deg);
    }
  }
}

.detailsSection {
  background: #fafbfc;
  border: 1px solid #eef0f3;
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 4px;
  cursor: pointer;

  summary {
    font-size: 12px;
    font-weight: 400;
    color: #888;
    user-select: none;
    outline: none;
    transition: color 0.2s;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;

    svg {
      flex-shrink: 0;
      opacity: 0.7;
    }

    &::before {
      content: "▶";
      font-size: 8px;
      color: #999;
      transition: transform 0.2s ease;
      display: inline-block;
      flex-shrink: 0;
    }

    &::-webkit-details-marker {
      display: none;
    }

    &:hover {
      color: #555;
    }
  }

  &[open] summary {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eef0f3;
    color: #555;

    &::before {
      transform: rotate(90deg);
    }
  }
}

.detailsContent {
  position: relative;
}

.detailsText {
  margin: 0;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid #eef0f3;
  border-radius: 4px;
  color: #555;
  font-family: "SF Mono", "Monaco", "Consolas", monospace;
  font-size: 11px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

.paramsSummary {
  list-style: none;
}

.paramsCode {
  margin: 0;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid #eef0f3;
  border-radius: 4px;
  color: #444;
  font-family: "SF Mono", "Monaco", "Consolas", monospace;
  font-size: 11px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;

  &::-webkit-scrollbar {
    width: 4px;
    height: 4px;
  }

  &::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 2px;
  }

  &::-webkit-scrollbar-thumb {
    background: #d4d4d4;
    border-radius: 2px;

    &:hover {
      background: #aaa;
    }
  }
}

.actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid #f0f2f5;

  button {
    min-width: 88px;
    height: 36px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    padding: 0 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .denyButton {
    background: transparent;
    border: 1.5px solid #e2e8f0;
    color: #64748b;
    margin-right: auto;
    box-shadow: none;

    &:hover:not(:disabled) {
      border-color: #fca5a5;
      background: #fee2e2;
      color: #dc2626;
      box-shadow: 0 2px 6px rgba(220, 38, 38, 0.15);
      transform: translateY(-0.5px);
    }

    &:focus:not(:disabled) {
      border-color: #fca5a5;
      background: #fee2e2;
      color: #dc2626;
      box-shadow: 0 2px 6px rgba(220, 38, 38, 0.15);
    }

    &:active:not(:disabled) {
      transform: translateY(0);
      box-shadow: 0 1px 3px rgba(220, 38, 38, 0.1);
    }
  }

  .approveOnceButton {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    border: none;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.2);

    &:hover:not(:disabled) {
      background: linear-gradient(135deg, #ea6c0e 0%, #dc2626 100%);
      box-shadow: 0 4px 14px rgba(249, 115, 22, 0.35);
      transform: translateY(-1px);
      border: none;
    }

    &:focus:not(:disabled) {
      background: linear-gradient(135deg, #ea6c0e 0%, #dc2626 100%);
      box-shadow: 0 4px 14px rgba(249, 115, 22, 0.35);
      border: none;
    }

    &:active:not(:disabled) {
      transform: translateY(0);
      box-shadow: 0 2px 8px rgba(249, 115, 22, 0.25);
    }
  }

  .approveAlwaysButton {
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    color: #475569;
    box-shadow: none;

    &:hover:not(:disabled) {
      background: #e2e8f0;
      border-color: #cbd5e1;
      color: #1e293b;
      box-shadow: 0 2px 6px rgba(71, 85, 105, 0.12);
      transform: translateY(-0.5px);
    }

    &:focus:not(:disabled) {
      background: #e2e8f0;
      border-color: #cbd5e1;
      color: #1e293b;
      box-shadow: 0 2px 6px rgba(71, 85, 105, 0.12);
    }

    &:active:not(:disabled) {
      transform: translateY(0);
      box-shadow: 0 1px 3px rgba(71, 85, 105, 0.08);
    }
  }
}

.timeoutHint {
  margin-right: auto;
  font-size: 12px;
  color: #cf1322;
  font-weight: 500;
}

/* ─── Dark Mode ──────────────────────────────────────────────────────────── */
:global(.dark-mode) {
  .approvalCard {
    background: #1e1e1e;
    border-color: #333;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);

    &:hover {
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    }
  }

  .header {
    border-bottom-color: #2d2d2d;

    .icon {
      color: #f97316;
    }

    .title {
      color: rgba(255, 255, 255, 0.88);
    }

    .timer {
      background: #2a2a2a;

      .timerIcon {
        color: #666;
      }

      .timerText {
        color: #999;
      }
    }
  }

  .label {
    color: #888;
  }

  .value {
    color: rgba(255, 255, 255, 0.85);

    &:global(.ant-typography) code {
      background: #2a2a2a;
      border-color: #3a3a3a;
      color: #ccc;
    }
  }

  .scopeSection {
    background: #252525;
    border-color: #333;
  }

  .scopeLabel {
    color: #999;
  }

  .scopeItemLabel {
    color: #bbb;
  }

  .scopeCode {
    background: #1a1a1a;
    border-color: #333;
    color: #ccc;
  }

  .summaryBox {
    background: #252525;
    border-left-color: #555;

    .summaryText {
      color: #bbb;
    }
  }

  .copyButton {
    color: #777;
    border-color: #444;

    &:hover {
      background: rgba(255, 255, 255, 0.06);
      border-color: #555;
      color: #bbb;
    }

    &.copied {
      color: #52c41a;
      border-color: #3a6b1e;
    }
  }

  .paramsDetails {
    background: #252525;
    border-color: #333;

    summary {
      color: #999;

      &::before {
        color: #666;
      }

      &:hover {
        color: #ccc;
      }
    }

    &[open] summary {
      border-bottom-color: #333;
      color: #ccc;
    }
  }

  .detailsSection {
    background: #252525;
    border-color: #333;

    summary {
      color: #888;

      svg {
        opacity: 0.6;
      }

      &::before {
        color: #666;
      }

      &:hover {
        color: #bbb;
      }
    }

    &[open] summary {
      border-bottom-color: #333;
      color: #bbb;
    }
  }

  .detailsText {
    background: #1a1a1a;
    border-color: #333;
    color: #bbb;
  }

  .paramsCode {
    background: #1a1a1a;
    border-color: #333;
    color: #bbb;

    &::-webkit-scrollbar-track {
      background: #222;
    }

    &::-webkit-scrollbar-thumb {
      background: #444;

      &:hover {
        background: #555;
      }
    }
  }

  .actions {
    border-top-color: #2d2d2d;

    .timeoutHint {
      color: #ff7875;
    }

    .denyButton {
      background: transparent;
      border-color: #3a3a3a;
      color: #94a3b8;

      &:hover:not(:disabled) {
        background: rgba(220, 38, 38, 0.15);
        border-color: #991b1b;
        color: #fca5a5;
        box-shadow: 0 2px 8px rgba(220, 38, 38, 0.2);
        transform: translateY(-0.5px);
      }

      &:focus:not(:disabled) {
        background: rgba(220, 38, 38, 0.15);
        border-color: #991b1b;
        color: #fca5a5;
        box-shadow: 0 2px 8px rgba(220, 38, 38, 0.2);
      }

      &:active:not(:disabled) {
        transform: translateY(0);
        box-shadow: 0 1px 4px rgba(220, 38, 38, 0.15);
      }
    }

    .approveOnceButton {
      background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
      color: #ffffff;
      box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);

      &:hover:not(:disabled) {
        background: linear-gradient(135deg, #ea6c0e 0%, #dc2626 100%);
        box-shadow: 0 4px 16px rgba(249, 115, 22, 0.45);
        transform: translateY(-1px);
      }

      &:focus:not(:disabled) {
        background: linear-gradient(135deg, #ea6c0e 0%, #dc2626 100%);
        box-shadow: 0 4px 16px rgba(249, 115, 22, 0.45);
      }

      &:active:not(:disabled) {
        transform: translateY(0);
        box-shadow: 0 2px 10px rgba(249, 115, 22, 0.35);
      }
    }

    .approveAlwaysButton {
      background: #2a2a2a;
      border-color: #3a3a3a;
      color: #94a3b8;

      &:hover:not(:disabled) {
        background: #3a3a3a;
        border-color: #4a4a4a;
        color: #e2e8f0;
        box-shadow: 0 2px 8px rgba(148, 163, 184, 0.15);
        transform: translateY(-0.5px);
      }

      &:focus:not(:disabled) {
        background: #3a3a3a;
        border-color: #4a4a4a;
        color: #e2e8f0;
        box-shadow: 0 2px 8px rgba(148, 163, 184, 0.15);
      }

      &:active:not(:disabled) {
        transform: translateY(0);
        box-shadow: 0 1px 4px rgba(148, 163, 184, 0.1);
      }
    }
  }
}

.strictModeHintIcon {
  color: #ff4d4f;
  margin-left: 8px;
  cursor: help;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

@media (max-width: 768px) {
  .approvalCard {
    border-radius: 10px;

    :global(.ant-card-body) {
      padding: 14px 16px;
    }
  }

  .header {
    margin-bottom: 12px;
    padding-bottom: 10px;
  }

  .content {
    gap: 6px;
    margin-bottom: 12px;
  }

  .label {
    min-width: 48px;
  }

  .actions {
    flex-direction: column;
    gap: 8px;

    button {
      width: 100%;
      min-width: auto;
      height: 44px;
    }

    .denyButton {
      margin-right: 0;
      order: 3;
    }

    .approveOnceButton {
      order: 1;
    }

    .approveAlwaysButton {
      order: 2;
    }
  }
}
